determine whether a digraph has a cycle
Definition at line 4 of file graphAlgs.py.
◆ __init__()
def graphAlgs.DirectedCycle.__init__ |
( |
|
self, |
|
|
|
G |
|
) |
| |
Definition at line 7 of file graphAlgs.py.
8 self.onStack = [
False for i
in range(G.V)]
9 self.marked = [
False for i
in range(G.V)]
10 self.edgeTo = [-1
for i
in range(G.V)]
15 if not self.marked[v]:
◆ cycle()
def graphAlgs.DirectedCycle.cycle |
( |
|
self | ) |
|
◆ dfs_()
def graphAlgs.DirectedCycle.dfs_ |
( |
|
self, |
|
|
|
G, |
|
|
|
v |
|
) |
| |
Definition at line 24 of file graphAlgs.py.
25 self.onStack[v] =
True
29 if self.cycle_:
return
30 if not self.marked[w]:
41 self.onStack[v] =
False
◆ has_cycle()
def graphAlgs.DirectedCycle.has_cycle |
( |
|
self | ) |
|
Definition at line 18 of file graphAlgs.py.
19 return len(self.cycle_) > 0
◆ cycle_
graphAlgs.DirectedCycle.cycle_ |
◆ edgeTo
graphAlgs.DirectedCycle.edgeTo |
◆ marked
graphAlgs.DirectedCycle.marked |
◆ onStack
graphAlgs.DirectedCycle.onStack |
The documentation for this class was generated from the following file: