This abstract class specifies the interface for the representation of
the state within a graph.
The state of a graph is defined to be the vertices contained within
it, as well as the arcs between those vertices. Vertices are always
numbered consecutively, starting from zero. Deleting a vertex causes all
higher numbered vertices to be renumbered.
Arcs are two-ary relations upon the set of vertices, and are directed.
Arcs retain their meaning during deletion, i.e. they must be renumbered
along with the vertices. An arc incident or outgoing from a deleted
vertex is also deleted.
Edges are not explicitly modelled by this representation. However, by
convention, the user may choose to represent an edge by a pair of
symmetric arcs together represents an edge.
This class is meant to be used internally within the pyGraphADT
package only. If you want to model a graph, used a subclass of the Graph
type in graphadt.graphtypes.
|
read(self,
stream,
defaultConstructor)
Sets the state of this representation to the data contained in some
stream s. |
source code
|
|
|
|
|
|
|
removeVertex(self,
i)
This method deletes the record of vertex labelled i, and all arcs
connected to it. |
source code
|
|
|
addArc(self,
i,
j)
Records that in this state there is an arc from vertex with label i
to vertex with label j |
source code
|
|
|
removeArc(self,
i,
j)
Removes a directional connection from vertex i to vertex j, from the
state of this representation if it exists. |
source code
|
|
boolean
|
isArc(self,
i,
j)
Returns True if and only if there is an arc connecting i to j. |
source code
|
|
number
|
|
number Raises: ValueError if no such label i exists.
|
degree(self,
i)
Returns the number of vertices to which vertex i connects |
source code
|
|
list
|
neighbours(self,
i)
Returns an iterable collection of all the vertices to which the
vertex with index i connects |
source code
|
|
number
|
size(self)
Returns the number of arcs in this graph, as an integer. |
source code
|
|
number
|
selfEdges(self)
Returns the number of arcs in this representation from any vertex to
itself, as an integer. |
source code
|
|
number
|
|
string
|
|
Inherited from object :
__delattr__ ,
__format__ ,
__getattribute__ ,
__hash__ ,
__init__ ,
__new__ ,
__reduce__ ,
__reduce_ex__ ,
__repr__ ,
__setattr__ ,
__sizeof__ ,
__subclasshook__
|