ATLAS Offline Software
Public Member Functions | Public Attributes | List of all members
graphAlgs.DirectedCycle Class Reference
Collaboration diagram for graphAlgs.DirectedCycle:

Public Member Functions

def __init__ (self, G)
 
def has_cycle (self)
 
def cycle (self)
 
def dfs_ (self, G, v)
 

Public Attributes

 onStack
 
 marked
 
 edgeTo
 
 cycle_
 

Detailed Description

determine whether a digraph has a cycle

Definition at line 4 of file graphAlgs.py.

Constructor & Destructor Documentation

◆ __init__()

def graphAlgs.DirectedCycle.__init__ (   self,
  G 
)

Definition at line 7 of file graphAlgs.py.

7  def __init__(self, G):
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)]
11  self.cycle_ = []
12 
13  GV = G.V
14  for v in range(GV):
15  if not self.marked[v]:
16  self.dfs_(G, v)
17 

Member Function Documentation

◆ cycle()

def graphAlgs.DirectedCycle.cycle (   self)

Definition at line 21 of file graphAlgs.py.

21  def cycle(self):
22  return self.cycle_
23 

◆ dfs_()

def graphAlgs.DirectedCycle.dfs_ (   self,
  G,
  v 
)

Definition at line 24 of file graphAlgs.py.

24  def dfs_(self, G, v):
25  self.onStack[v] = True
26  self.marked[v] = True
27 
28  for w in G.adj(v):
29  if self.cycle_: return
30  if not self.marked[w]:
31  self.edgeTo[w] = w
32  self.dfs_(G, w)
33  elif self.onStack[w]:
34  x = v
35  while x != w:
36  self.cycle_.append(x)
37  x = self.edgeTo(x)
38  self.cycle_.append(w)
39  self.cycle_.append(v)
40 
41  self.onStack[v] = False
42 
43 
44 

◆ has_cycle()

def graphAlgs.DirectedCycle.has_cycle (   self)

Definition at line 18 of file graphAlgs.py.

18  def has_cycle(self):
19  return len(self.cycle_) > 0
20 

Member Data Documentation

◆ cycle_

graphAlgs.DirectedCycle.cycle_

Definition at line 11 of file graphAlgs.py.

◆ edgeTo

graphAlgs.DirectedCycle.edgeTo

Definition at line 10 of file graphAlgs.py.

◆ marked

graphAlgs.DirectedCycle.marked

Definition at line 9 of file graphAlgs.py.

◆ onStack

graphAlgs.DirectedCycle.onStack

Definition at line 8 of file graphAlgs.py.


The documentation for this class was generated from the following file:
cycle
double cycle(double a, double b)
Definition: SiHitCollectionCnv_p2.cxx:38
dumpHVPathFromNtuple.append
bool append
Definition: dumpHVPathFromNtuple.py:91
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18