A directed graph abstraction with labeled edges.
Methods
|
|
|
|
__eq__
|
__eq__ ( self, g )
Returns true if g is equal to this graph.
|
|
__init__
|
__init__ ( self, nodes=[] )
Initializes a new Graph object.
|
|
__ne__
|
__ne__ ( self, g )
Returns true if g is not equal to this graph.
|
|
__repr__
|
__repr__ ( self )
Returns an unique string representation of this graph.
|
|
__str__
|
__str__ ( self )
Returns a concise string description of this graph.
|
|
add_edge
|
add_edge (
self,
source,
to,
label=None,
)
Adds an edge to this graph.
Exceptions
|
|
ValueError, "Unknown node: " + str( source )
ValueError, "Unknown node: " + str( to )
ValueError, str( source ) + " -> " + str( to ) + " exists"
|
|
|
add_node
|
add_node ( self, node )
Adds a node to this graph.
|
|
child_edges
|
child_edges ( self, parent )
Returns a list of (child, label) pairs for parent.
Exceptions
|
|
ValueError, "Unknown node: " + str( parent )
|
|
|
children
|
children ( self, parent )
Returns a list of unique children for parent.
|
|
edges
|
edges ( self, label )
Returns a list of all the edges with this label.
Exceptions
|
|
ValueError, "Unknown label: " + str( label )
|
|
|
labels
|
labels ( self )
Returns a list of all the edge labels in this graph.
|
|
nodes
|
nodes ( self )
Returns a list of the nodes in this graph.
|
|
parent_edges
|
parent_edges ( self, child )
Returns a list of (parent, label) pairs for child.
Exceptions
|
|
ValueError, "Unknown node: " + str( child )
|
|
|
parents
|
parents ( self, child )
Returns a list of unique parents for child.
|
|
remove_edge
|
remove_edge (
self,
parent,
child,
label,
)
- Removes edge.
- NOT IMPLEMENTED
Exceptions
|
|
NotImplementedError, "remove_edge is not yet implemented"
|
|
|
remove_node
|
remove_node ( self, node )
Removes node and all edges connected to it.
Exceptions
|
|
ValueError, "Unknown node: " + str( node )
|
|