Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undo change in return type of single_target_shortest_path_length #7327

Merged
merged 1 commit into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions networkx/algorithms/shortest_paths/tests/test_unweighted.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ def test_single_target_shortest_path(self):
def test_single_target_shortest_path_length(self):
pl = nx.single_target_shortest_path_length
lengths = {0: 0, 1: 1, 2: 2, 3: 3, 4: 3, 5: 2, 6: 1}
assert pl(self.cycle, 0) == lengths
assert dict(pl(self.cycle, 0)) == lengths
lengths = {0: 0, 1: 6, 2: 5, 3: 4, 4: 3, 5: 2, 6: 1}
assert pl(self.directed_cycle, 0) == lengths
assert dict(pl(self.directed_cycle, 0)) == lengths
# test missing targets
target = 8
with pytest.raises(nx.NodeNotFound, match=f"Target {target} is not in G"):
Expand Down
4 changes: 2 additions & 2 deletions networkx/algorithms/shortest_paths/unweighted.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def single_target_shortest_path_length(G, target, cutoff=None):
Examples
--------
>>> G = nx.path_graph(5, create_using=nx.DiGraph())
>>> length = nx.single_target_shortest_path_length(G, 4)
>>> length = dict(nx.single_target_shortest_path_length(G, 4))
>>> length[0]
4
>>> for node in range(5):
Expand Down Expand Up @@ -151,7 +151,7 @@ def single_target_shortest_path_length(G, target, cutoff=None):
nextlevel = [target]
# for version 3.3 we will return a dict like this:
# return dict(_single_shortest_path_length(adj, nextlevel, cutoff))
return dict(_single_shortest_path_length(adj, nextlevel, cutoff))
return _single_shortest_path_length(adj, nextlevel, cutoff)


@nx._dispatchable
Expand Down