Skip to content

Commit

Permalink
Cancel the form parent node of the root node
Browse files Browse the repository at this point in the history
  • Loading branch information
weilycoder committed Oct 10, 2024
1 parent bfafc1b commit 2a7b7fc
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions cyaron/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,9 @@ def to_tree(self, root = 1, *, container = list, from_weight = lambda w: None):
if u in vis:
continue
vis.add(u)
w = from_weight(_)
tree.append((fa, u) if w is None else (fa, u, w))
if fa != 0:
w = from_weight(_)
tree.append((fa, u) if w is None else (fa, u, w))
for edge in self.edges[u]:
v, w = edge.end, edge.weight
if v in vis:
Expand Down

0 comments on commit 2a7b7fc

Please sign in to comment.