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)
| 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 | """ |