add comments

parent caa5dcec
...@@ -15,7 +15,7 @@ def _traversing(to_visit: Union[FIFO, LIFO], graph: Graph, node: Node) -> Iterat ...@@ -15,7 +15,7 @@ def _traversing(to_visit: Union[FIFO, LIFO], graph: Graph, node: Node) -> Iterat
""" """
to_visit.add(node) to_visit.add(node)
visited = set() visited = set()
parent = {} parent = {} # to store for each node from which node it has been discovered
path = [] path = []
while to_visit: while to_visit:
node = to_visit.pop() node = to_visit.pop()
...@@ -29,7 +29,7 @@ def _traversing(to_visit: Union[FIFO, LIFO], graph: Graph, node: Node) -> Iterat ...@@ -29,7 +29,7 @@ def _traversing(to_visit: Union[FIFO, LIFO], graph: Graph, node: Node) -> Iterat
parent[edge.target] = edge parent[edge.target] = edge
to_visit.add(edge.target) to_visit.add(edge.target)
if node in parent: if node in parent:
path.append(parent[node]) path.append(parent[node]) # the starting node has no parent
yield node, path yield node, path
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment