Repository navigation
graphs: Return no path in edge_disjoint_paths when the target is unreachable - #42903
Merged
Merged
Conversation
vbraun
pushed a commit
to vbraun/sage
that referenced
this pull request
Oct 4, 2026
sagemathgh-42903: graphs: Return no path in edge_disjoint_paths when the target is unreachable `edge_disjoint_paths(s, t)` raises a misleading `ValueError` when `t` is not reachable from `s`: ``` sage: DiGraph([(0, 1)]).edge_disjoint_paths(1, 0) Traceback (most recent call last): ... ValueError: vertex '1' is not in the (di)graph ``` Vertex 1 is in the digraph, and the expected answer is `[]`. The flow graph returned by `flow(..., value_only=False)` only contains the edges carrying flow, so when the flow is 0 it does not contain `s`, and `shortest_path(s, t)` raises. This PR returns `[]` when the flow is 0, as `vertex_disjoint_paths` already does, and adds doctests for a digraph and for a disconnected graph. This was noticed in sagemath#42846. ### 📝 Checklist - [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 None. URL: sagemath#42903 Reported by: Muhammet Doğukan Bingöl Reviewer(s): David Coudert
vbraun
pushed a commit
to vbraun/sage
that referenced
this pull request
Oct 6, 2026
sagemathgh-42903: graphs: Return no path in edge_disjoint_paths when the target is unreachable `edge_disjoint_paths(s, t)` raises a misleading `ValueError` when `t` is not reachable from `s`: ``` sage: DiGraph([(0, 1)]).edge_disjoint_paths(1, 0) Traceback (most recent call last): ... ValueError: vertex '1' is not in the (di)graph ``` Vertex 1 is in the digraph, and the expected answer is `[]`. The flow graph returned by `flow(..., value_only=False)` only contains the edges carrying flow, so when the flow is 0 it does not contain `s`, and `shortest_path(s, t)` raises. This PR returns `[]` when the flow is 0, as `vertex_disjoint_paths` already does, and adds doctests for a digraph and for a disconnected graph. This was noticed in sagemath#42846. ### 📝 Checklist - [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 None. URL: sagemath#42903 Reported by: Muhammet Doğukan Bingöl Reviewer(s): David Coudert
vbraun
pushed a commit
to vbraun/sage
that referenced
this pull request
Oct 8, 2026
sagemathgh-42903: graphs: Return no path in edge_disjoint_paths when the target is unreachable `edge_disjoint_paths(s, t)` raises a misleading `ValueError` when `t` is not reachable from `s`: ``` sage: DiGraph([(0, 1)]).edge_disjoint_paths(1, 0) Traceback (most recent call last): ... ValueError: vertex '1' is not in the (di)graph ``` Vertex 1 is in the digraph, and the expected answer is `[]`. The flow graph returned by `flow(..., value_only=False)` only contains the edges carrying flow, so when the flow is 0 it does not contain `s`, and `shortest_path(s, t)` raises. This PR returns `[]` when the flow is 0, as `vertex_disjoint_paths` already does, and adds doctests for a digraph and for a disconnected graph. This was noticed in sagemath#42846. ### 📝 Checklist - [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 None. URL: sagemath#42903 Reported by: Muhammet Doğukan Bingöl Reviewer(s): David Coudert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
edge_disjoint_paths(s, t)raises a misleadingValueErrorwhentis not reachable froms:Vertex 1 is in the digraph, and the expected answer is
[]. The flow graph returned byflow(..., value_only=False)only contains the edges carrying flow, so when the flow is 0 it does not contains, andshortest_path(s, t)raises.This PR returns
[]when the flow is 0, asvertex_disjoint_pathsalready does, and adds doctests for a digraph and for a disconnected graph. This was noticed in #42846.📝 Checklist
⌛ Dependencies
None.