Fix all_cycles_iterator for immutable graphs#41488
Conversation
A mutable copy is required for `hh.delete_edge(e)`.
|
Documentation preview for this PR (built with commit 799842a; changes) is ready! 🎉 |
|
A better solution is to add parameter immutable to methods For undirected graph, we can do it in #40965 if needed. |
|
Do you mean adding parameter I'm not following how the extra parameter would help to avoid copies. The cycle finding algorithm needs each component |
|
no, I mean to use in Your solution is fine. My proposal is more general and can be useful for other methods. |
|
See #41493. |
sagemathgh-41493: add parameter immutable to `(bi_|strongly_)connected_components_subgraphs` This PR adds parameter immutable to methods `connected_components_subgraphs`, `biconnected_components_subgraphs` and `strongly_connected_components_subgraphs`. This way, we can choose whether the returned subgraphs should behave as the input graph (`None`) or be mutable (`False`) or immutable (`True`). This was discussed in sagemath#41488. ### 📝 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. - [x] I have updated the documentation and checked the documentation preview. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - sagemath#12345: short description why this is a dependency --> <!-- - sagemath#34567: ... --> sagemath#40965: add parameter `forbidden_vertices` to methods related to biconnected components URL: sagemath#41493 Reported by: David Coudert Reviewer(s): David Coudert, Lennard Hofmann, Martin Rubey
sagemathgh-41493: add parameter immutable to `(bi_|strongly_)connected_components_subgraphs` This PR adds parameter immutable to methods `connected_components_subgraphs`, `biconnected_components_subgraphs` and `strongly_connected_components_subgraphs`. This way, we can choose whether the returned subgraphs should behave as the input graph (`None`) or be mutable (`False`) or immutable (`True`). This was discussed in sagemath#41488. ### 📝 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. - [x] I have updated the documentation and checked the documentation preview. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - sagemath#12345: short description why this is a dependency --> <!-- - sagemath#34567: ... --> sagemath#40965: add parameter `forbidden_vertices` to methods related to biconnected components URL: sagemath#41493 Reported by: David Coudert Reviewer(s): David Coudert, Lennard Hofmann, Martin Rubey
This small PR fixes
TypeError: this graph is immutable and so cannot be changedwhen callingG.all_simple_cycles(), whereGis a non-empty immutable graph.See also #41487