https://github.com/networkx/networkx/commit/ea2c8db07e0047daa649d484c4cf68ec2d9035f7 typo: swap source and target --- networkx/algorithms/shortest_paths/astar.py.orig 2019-04-11 14:52:34.000000000 -0600 +++ networkx/algorithms/shortest_paths/astar.py 2019-09-11 09:22:19.922448001 -0600 @@ -131,7 +131,7 @@ def astar_path(G, source, target, heuris enqueued[neighbor] = ncost, h push(queue, (ncost + h, next(c), neighbor, ncost, curnode)) - raise nx.NetworkXNoPath("Node %s not reachable from %s" % (source, target)) + raise nx.NetworkXNoPath("Node %s not reachable from %s" % (target, source)) def astar_path_length(G, source, target, heuristic=None, weight='weight'): --- networkx/algorithms/shortest_paths/weighted.py.orig 2019-04-11 14:52:34.000000000 -0600 +++ networkx/algorithms/shortest_paths/weighted.py 2019-09-11 09:22:46.694007187 -0600 @@ -1422,7 +1422,7 @@ def bellman_ford_path_length(G, source, return length[target] except KeyError: raise nx.NetworkXNoPath( - "node %s not reachable from %s" % (source, target)) + "node %s not reachable from %s" % (target, source)) def single_source_bellman_ford_path(G, source, weight='weight'): @@ -1597,7 +1597,7 @@ def single_source_bellman_ford(G, source try: return (dist[target], paths[target]) except KeyError: - msg = "Node %s not reachable from %s" % (source, target) + msg = "Node %s not reachable from %s" % (target, source) raise nx.NetworkXNoPath(msg)