Package graphadt :: Module graphtypes :: Class DirectedGraph
[hide private]
[frames] | no frames]

Class DirectedGraph

source code

object --+    
         |    
     Graph --+
             |
            DirectedGraph
Known Subclasses:

This class defines a Directed Graph. The Directed Graph class extends the Graph class and enables the creation of directed arcs.

This class provides several methods for modifying and accessing arcs, as well as extending certain accessors to provide more accurate functionality.

Mutators: -addArc(n) -removeArc(i, j)

Accessors: -isArc(i, j) -inDegree(i) -size()

If a Directed Graph contains two symmetric arcs, it is considered to contain the edge.

Nested Classes [hide private]

Inherited from Graph: __metaclass__

Instance Methods [hide private]
 
addArc(self, i, j)
Creates an arc from i to j
source code
 
removeArc(self, i, j)
Removes an arc from i to j
source code
boolean
isArc(self, i, j)
Returns True if and only if j is adjacent to i.
source code
number
inDegree(self, i)
Returns the number of arcs and edges going into i.
source code
integer
size(self)
Returns the number of arcs in this graph.
source code
 
defaultConnector(self, i, j)
The default connector of this graph is the arc.
source code

Inherited from Graph: __init__, __repr__, addEdge, addVertices, degree, isEdge, neighbors, neighbours, order, removeEdge, removeVertex

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Methods [hide private]

Inherited from Graph: copy, read

Class Variables [hide private]
  __abstractmethods__ = frozenset([])
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

addArc(self, i, j)

source code 

Creates an arc from i to j

This method creates an arc from i to j. Arcs are uni-directional, and so the order of the parameters i and j does matter. Self-loops, i.e. arcs where i == j, are allowed, but are indistinguishable from edges.

Parameters:
  • i (integer) - The label of a vertex in this graph
  • j (integer) - The label of a vertex in this graph
Raises:
  • ValueError - if either i or j is not a valid vertex label in this graph.

removeArc(self, i, j)

source code 

Removes an arc from i to j

This method removes an arc from i to j. Note that if an edge between i and j exists, this method can 'split' the edge and remove the outbound arc, so that the arc (j, i) in the other direction, is left.

isArc(self, i, j)

source code 

Returns True if and only if j is adjacent to i.

This method returns true if there is an arc from i to j. However, it also returns true if there is an edge between i and j.

Parameters:
  • i (integer) - The label of a vertex in this graph
  • j (integer) - The label of a vertex in this graph
Returns: boolean
True iff there is an arc between i and j
Raises:
  • ValueError - if either i or j is not a valid vertex label in this graph.

inDegree(self, i)

source code 

Returns the number of arcs and edges going into i.

Parameter: i -- a non-negative integer representing a vertex in this graph

Raises : ValueError if either i or j is not a valid vertex label in this graph.

Parameters:
  • i - The label of a vertex in this graph
Returns: number
the indegree of vertex with label i.
Raises:
  • ValueError - if i is not a valid vertex label in this graph.
Overrides: Graph.inDegree

size(self)

source code 

Returns the number of arcs in this graph.

This method returns the number of arcs in this graph. An edge counts as two arcs.

Returns: integer
the number of arcs in this graph
Overrides: Graph.size

defaultConnector(self, i, j)

source code 

The default connector of this graph is the arc.

Parameters:
  • i - The label of the vertex from which the connection will be made
  • j - The label of the vertex to which the connection will be made (order is only important if the defaultConnector is an arc)
Overrides: Graph.defaultConnector