|
Methods defined here:
- __bool__(self)
- Determine the truth of a graph: non-empty graphs are True
- __init__(self, strict=False, initial_graph=None)
- Graph is constructed to store all the nodes and values in initial_graph
(if it is present) otherwise no nodes and edges; a strict graph does not
allow re-adding edges or values (they must be removed before re-adding);
it will raise more exceptions
- __str__(self)
- add_edge(self, e, value)
- Add an edge to the graph
In a strict graph, the node must be in the graph and edge must not be in the graph
- add_node(self, n)
- Add a node to the graph
In a strict graph, it must not already be present
- clear(self)
- Clear the graph of any nodes and values
- degree(self, n)
- Return the degree (number of edges with this node as their origin or destination) of a node
In a strict graph, the node must be in the graph
- edge_count(self)
- Return the number of edges in the graph
- edge_value(self, e)
- Return the value of an edge in the graph
In a strict graph, both nodes and the edge must be in the graph
- edges(self)
- Return an iterator for a copy of all edges in the graph (in no special order)
- has_edge(self, e)
- Return whether the graph stores an edge
- has_node(self, n)
- Return whether the graph stores a node
- in_degree(self, n)
- Return the in-degree (number of edges with this node as their destination) of a node
In a strict graph, the node must be in the graph
- in_edges(self, n)
- Return an iterator for a copy of all in edges with this node as its destination
In a strict graph, the node must be in the graph
- in_nodes(self, n)
- Return an iterator for a copy of all in nodes that have an edge with this node as its destination
In a strict graph, the node must be in the graph
- is_empty(self)
- Return whether the graph is empty (of nodes)
- node_count(self)
- Return the number of nodes in the graph
- nodes(self)
- Return an iterator for a copy of all nodes in the graph (in no special order)
- out_degree(self, n)
- Return the out-degree (number of edges with this node as their origin) of a node
In a strict graph, the node must be in the graph
- out_edges(self, n)
- Return an iterator for a copy of all in edges with this node as its origin
In a strict graph, the node must be in the graph
- out_nodes(self, n)
- Return an iterator for a copy of all in nodes that have an edge with this node as its origin
In a strict graph, the node must be in the graph
- read(self, file, conv=<function <lambda>>, sep=' ')
- Read a graph from a text file; assume sep is separating the nodes and edge values
conv converts the string value of an edge into the appropriate type of value
Graphs written by write should be readable by read
- remove_edge(self, e)
- Remove an edge from the graph
In a strict graph, both nodes and the edge must be in the graph
- remove_node(self, n)
- Remove a node from the graph
In a strict graph, the node must be in the graph
- write(self, file, conv=<class 'str'>, sep=' ')
- Write a graph into a text file; use sep to separate the nodes and edge values
conv converts the value of an edge into the appropriate string (with str the default)
Graphs written by write should be readable by read
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
Data and other attributes defined here:
- NodeInfo = <class 'graph.NodeInfo'>
- NodeInfo stores the set of incoming and outgoing edges for every node
|