MCPcopy Index your code
hub / github.com/OmkarPathak/pygorithm / reverse_path

Method reverse_path

pygorithm/pathfinding/dijkstra.py:26–38  ·  view source on GitHub ↗

Walks backward from an end node to the start node and reconstructs a path. Meant for internal use. :param node: dict containing { 'vertex': any hashable, 'parent': dict or None } :return: a list of vertices ending on the node

(node)

Source from the content-addressed store, hash-verified

24
25 @staticmethod
26 def reverse_path(node):
27 """
28 Walks backward from an end node to the start
29 node and reconstructs a path. Meant for internal
30 use.
31 :param node: dict containing { 'vertex': any hashable, 'parent': dict or None }
32 :return: a list of vertices ending on the node
33 """
34 result = []
35 while node is not None:
36 result.insert(0, node['vertex'])
37 node = node['parent']
38 return result
39
40 def find_path(self, graph, start, end):
41 """

Callers 1

find_pathMethod · 0.95

Calls 1

insertMethod · 0.45

Tested by

no test coverage detected