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

Public Member Functions

def __init__ (self, V=0, fn='')
 
def fromFile (self, fn)
 
def addEdge (self, v, w)
 
def adj (self, v)
 
def reverse (self)
 
def __str__ (self)
 

Public Attributes

 adjTable_
 
 E
 
 V
 

Detailed Description

Digraph is an implementation of digraphs which supports
adding edges and reversal

Definition at line 5 of file Digraph.py.

Constructor & Destructor Documentation

◆ __init__()

def Digraph.Digraph.__init__ (   self,
  V = 0,
  fn = '' 
)

Definition at line 9 of file Digraph.py.

9  def __init__(self, V=0, fn=''):
10  self.adjTable_ = {}
11  self.E = 0
12  if fn:
13  self.fromFile(fn)
14  else:
15  self.V = V
16  for i in range(V):
17  self.adjTable_[i] = []
18 

Member Function Documentation

◆ __str__()

def Digraph.Digraph.__str__ (   self)

Definition at line 62 of file Digraph.py.

62  def __str__(self):
63  lines = ['Digraph. V: '+ str(self.V) + ' E: ' + str(self.E)]
64  for v in range(self.V):
65  for w in self.adj(v):
66  lines.append('%d -> %d' % (v, w))
67 
68  return '\n'.join(lines)

◆ addEdge()

def Digraph.Digraph.addEdge (   self,
  v,
  w 
)

Definition at line 45 of file Digraph.py.

45  def addEdge(self, v, w):
46  assert v < self.V
47  assert w < self.V
48  self.adjTable_[v].append(w)
49  self.E += 1
50 

◆ adj()

def Digraph.Digraph.adj (   self,
  v 
)

Definition at line 51 of file Digraph.py.

51  def adj(self, v):
52  assert v < self.V
53  return self.adjTable_[v]
54 

◆ fromFile()

def Digraph.Digraph.fromFile (   self,
  fn 
)

Definition at line 19 of file Digraph.py.

19  def fromFile(self, fn):
20  state = 'START'
21  with open(fn, 'r') as fh:
22  for ll in fh:
23  l = ll.strip()
24  if not l or l.startswith('#'): continue
25 
26  if state == 'START':
27  self.V = int(l.strip())
28  for i in range(self.V):
29  self.adjTable_[i] = list()
30  state = 'NE'
31  continue
32  if state == 'NE':
33  # self.E = int(l.strip())
34  state = 'EDGES'
35  continue
36 
37  if state == 'EDGES':
38  toks = l.strip().split()
39  assert len(toks) == 2
40  v = int(toks[0])
41  w = int(toks[1])
42  self.addEdge(v, w)
43  continue
44 

◆ reverse()

def Digraph.Digraph.reverse (   self)

Definition at line 55 of file Digraph.py.

55  def reverse(self):
56  R = Digraph(self.V)
57  for v in range(self.V):
58  for w in self.adj(v):
59  R.addEdge(w, v)
60  return R
61 

Member Data Documentation

◆ adjTable_

Digraph.Digraph.adjTable_

Definition at line 10 of file Digraph.py.

◆ E

Digraph.Digraph.E

Definition at line 11 of file Digraph.py.

◆ V

Digraph.Digraph.V

Definition at line 15 of file Digraph.py.


The documentation for this class was generated from the following file:
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
dumpHVPathFromNtuple.append
bool append
Definition: dumpHVPathFromNtuple.py:91
DeMoUpdate.reverse
reverse
Definition: DeMoUpdate.py:563
Digraph
Definition: Digraph.py:1
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
histSizes.list
def list(name, path='/')
Definition: histSizes.py:38
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18
Trk::open
@ open
Definition: BinningType.h:40
str
Definition: BTagTrackIpAccessor.cxx:11
Trk::split
@ split
Definition: LayerMaterialProperties.h:38