Give cycle, nothing more
This commit is contained in:
@@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user