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

Class UndirectedGraph

source code

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

This class defines the Undirected Graph. The Undirected Graph class extends the Graph class, and has some behaviour customised for an undirected graph.

Nested Classes [hide private]

Inherited from Graph: __metaclass__

Instance Methods [hide private]
 
defaultConnector(self, i, j)
The default connector of an undirected graph is an edge.
source code
integer
inDegree(self, i)
Returns the degree of vertex i, since indegree and outdegree are equivalent in a directed graph.
source code
integer
size(self)
Returns the number of edges of this graph.
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]

defaultConnector(self, i, j)

source code 

The default connector of an undirected graph is an edge.

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

inDegree(self, i)

source code 

Returns the degree of vertex i, since indegree and outdegree are equivalent in a directed graph.

Parameters:
  • i - The label of a vertex in this graph
Returns: integer
the degree of vertex 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 edges of this graph.

The size of an undirected graph is defined as the number of edges. Since the inner representation object only stores the number of arcs, this number of arcs must be halved. However, self-arcs are NOT counted twice, and halving this number leads to errors. Therefore, the number of edges is equal to half the number of non-self arcs, plus the self-arc.

Returns: integer
the number of edges
Overrides: Graph.size