Skip to content

Commit

Permalink
Undo change in return type of single_target_shortest_path_length (n…
Browse files Browse the repository at this point in the history
…etworkx#7327)

Fixup tests.
  • Loading branch information
rossbar authored and cvanelteren committed Apr 22, 2024
1 parent 3c7e071 commit 874c623
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
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

0 comments on commit 874c623

Please sign in to comment.