Give cycle, nothing more

This commit is contained in:
Bahadır Kandemir
2007-02-27 11:28:59 +00:00
parent 820e3691b8
commit a9226a442a
+2
View File
@@ -124,6 +124,8 @@ class Digraph(object):
while self.p[u]: while self.p[u]:
u = self.p[u] u = self.p[u]
cycle.append(u) cycle.append(u)
if self.has_edge(cycle[0], u):
break
cycle.reverse() cycle.reverse()
raise CycleException(cycle) raise CycleException(cycle)
self.color[u] = 'b' # mark black (completed) self.color[u] = 'b' # mark black (completed)