main
Antonio De Lucreziis 4 weeks ago
parent 42c34a577f
commit 7301e7f145

@ -53,9 +53,7 @@ def classify_iter(g):
('node:start', u, None), ('node:start', u, None),
] ]
print("Stack:") print("Stack:", continuations)
for cont in continuations:
print("-", cont)
while len(continuations) > 0: while len(continuations) > 0:
state, u, more = continuations.pop() state, u, more = continuations.pop()
@ -99,10 +97,7 @@ def classify_iter(g):
t += 1 t += 1
finish_time[u] = t finish_time[u] = t
print("Stack:") print("Stack:", continuations)
for cont in continuations:
print("-", cont)
@ -128,26 +123,26 @@ class Graph:
# Example usage: # Example usage:
g = Graph() g = Graph()
g.add_edge(0, 1) # g.add_edge(0, 1)
g.add_edge(1, 2) # g.add_edge(1, 2)
g.add_edge(2, 3) # g.add_edge(2, 3)
g.add_edge(3, 0) # g.add_edge(3, 0)
g.add_edge(3, 4) # g.add_edge(3, 4)
g.add_edge(4, 5) # g.add_edge(4, 5)
g.add_edge(5, 0) # g.add_edge(5, 0)
g.add_edge(4, 2) # g.add_edge(4, 2)
# g.add_edge(0, 1) # g.add_edge(0, 1)
# g.add_edge(1, 2) # g.add_edge(1, 2)
# g.add_edge(0, 2) # g.add_edge(0, 2)
# g.add_edge("u", "v") g.add_edge("u", "v")
# g.add_edge("u", "x") g.add_edge("u", "x")
# g.add_edge("v", "y") g.add_edge("v", "y")
# g.add_edge("y", "x") g.add_edge("y", "x")
# g.add_edge("x", "v") g.add_edge("x", "v")
# g.add_edge("w", "y") g.add_edge("w", "y")
# g.add_edge("w", "z") g.add_edge("w", "z")
# Running DFS # Running DFS
# results = dfs(g) # results = dfs(g)

Loading…
Cancel
Save