Skip to content

Commit

Permalink
gh-35170: Fix bug in is_eulerian
Browse files Browse the repository at this point in the history
    
### πŸ“š Description

Fixes #35168.

We set parameter `sort` to `False` when calling `connected_components`.
This fixes the bug as we avoid sorting vertices with different types.

### πŸ“ Checklist

<!-- Put an `x` in all the boxes that apply. -->
<!-- If your change requires a documentation PR, please link it
appropriately -->
<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->

- [x] I have made sure that the title is self-explanatory and the
description concisely explains the PR.
- [x] I have linked an issue or discussion.
- [x] I have created tests covering the changes.
- [x] I have updated the documentation accordingly.

### βŒ› Dependencies
None
    
URL: #35170
Reported by: David Coudert
Reviewer(s): Marc Mezzarobba
  • Loading branch information
Release Manager committed Mar 24, 2023
2 parents 883b993 + d5e6262 commit 81bacf5
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/sage/graphs/generic_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -4213,12 +4213,18 @@ def is_eulerian(self, path=False):

sage: g = Graph({0:[], 1:[], 2:[], 3:[]}); g.is_eulerian()
True
"""

Issue :trac:`35168` is fixed::

sage: Graph([[0, 42, 'John'], [(42, 0)]]).is_eulerian()
False
sage: Graph([[0, 42, 'John'], [(42, 'John')]]).is_eulerian()
False
"""
# unconnected graph can still be Eulerian if all components
# up to one doesn't contain any edge
nontrivial_components = 0
for cc in self.connected_components():
for cc in self.connected_components(sort=False):
if len(cc) > 1:
nontrivial_components += 1
if nontrivial_components > 1:
Expand Down

0 comments on commit 81bacf5

Please sign in to comment.