more compact

main
Antonio De Lucreziis 4 weeks ago
parent 7301e7f145
commit d05f03394b

@ -53,8 +53,6 @@ def classify_iter(g):
('node:start', u, None), ('node:start', u, None),
] ]
print("Stack:", continuations)
while len(continuations) > 0: while len(continuations) > 0:
state, u, more = continuations.pop() state, u, more = continuations.pop()
@ -63,20 +61,16 @@ def classify_iter(g):
parent = more parent = more
print("Recurse:", u, parent)
visited.add(u) visited.add(u)
t += 1 t += 1
start_time[u] = t start_time[u] = t
if parent is not None: if parent is not None:
edges[(parent, u)] = 'tree' edges[(parent, u)] = 'tree'
continuations.append(('node:neighbors', u, 0)) continuations.append(('node:neighbors', u, 0))
elif state == 'node:neighbors': elif state == 'node:neighbors':
i = more i = more
print("Remaining Neighbors:", g.neighbors(u)[i:])
neighbors = g.neighbors(u)[i:] neighbors = g.neighbors(u)[i:]
for i in range(len(neighbors)): for i in range(len(neighbors)):
@ -97,11 +91,6 @@ def classify_iter(g):
t += 1 t += 1
finish_time[u] = t finish_time[u] = t
print("Stack:", continuations)
return edges return edges
# Graph structure # Graph structure

Loading…
Cancel
Save