Commit 1ad3f20
Release Manager
gh-40717: Fix enumerating the same cycle twice in undirected graph
<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes #12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes #12345". -->
The output for `algorithm="A"` and `algorithm="B"` in
all_cycles_iterator function is inconsistent as below.
This happens when a graph is undirected. `algorithm="A"` outputs the
same cycle in reverse order, while `algorithm="B"` does not.
```python
sage: g = Graph({0: [1, 2], 1: [0, 2], 2: [0, 1]})
sage: list(g.all_cycles_iterator(algorithm='A', simple=True))
[[0, 1, 2, 0], [0, 2, 1, 0]]
sage: list(g.all_cycles_iterator(algorithm='B', simple=True))
[[0, 1, 2, 0]]
```
This PR fixes this issue by changing the current bahavior of
`algorithm="A"` and output each cycle once.
### 📝 Checklist
<!-- Put an `x` in all the boxes that apply. -->
- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [x] I have created tests covering the changes.
- [ ] I have updated the documentation and checked the documentation
preview.
### ⌛ Dependencies
<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - #12345: short description why this is a dependency -->
<!-- - #34567: ... -->
URL: #40717
Reported by: Yuta Inoue
Reviewer(s): David Coudert, Yuta Inoue
1 file changed
+29
-14
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
156 | 156 | | |
157 | 157 | | |
158 | 158 | | |
159 | | - | |
| 159 | + | |
| 160 | + | |
160 | 161 | | |
161 | 162 | | |
162 | 163 | | |
163 | 164 | | |
164 | 165 | | |
165 | 166 | | |
166 | 167 | | |
167 | | - | |
168 | 168 | | |
169 | 169 | | |
170 | 170 | | |
| 171 | + | |
171 | 172 | | |
172 | 173 | | |
173 | 174 | | |
174 | | - | |
175 | 175 | | |
176 | 176 | | |
177 | 177 | | |
| |||
195 | 195 | | |
196 | 196 | | |
197 | 197 | | |
| 198 | + | |
| 199 | + | |
198 | 200 | | |
199 | 201 | | |
200 | 202 | | |
| |||
212 | 214 | | |
213 | 215 | | |
214 | 216 | | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
221 | 235 | | |
222 | 236 | | |
223 | 237 | | |
| |||
559 | 573 | | |
560 | 574 | | |
561 | 575 | | |
562 | | - | |
| 576 | + | |
563 | 577 | | |
564 | 578 | | |
565 | 579 | | |
| |||
569 | 583 | | |
570 | 584 | | |
571 | 585 | | |
572 | | - | |
| 586 | + | |
| 587 | + | |
573 | 588 | | |
574 | 589 | | |
575 | 590 | | |
576 | 591 | | |
577 | 592 | | |
578 | | - | |
579 | 593 | | |
580 | 594 | | |
581 | 595 | | |
| |||
872 | 886 | | |
873 | 887 | | |
874 | 888 | | |
875 | | - | |
| 889 | + | |
| 890 | + | |
876 | 891 | | |
877 | 892 | | |
878 | 893 | | |
879 | | - | |
| 894 | + | |
880 | 895 | | |
881 | 896 | | |
882 | 897 | | |
| |||
0 commit comments