Home | Trees | Indices | Help |
---|
|
object --+ | graph.Graph --+ | DiGraph
A graph with directed edges. Subclass of Graph.
DiGraph inherits from Graph, overriding the following methods:
Digraph adds the following methods to those of Graph:
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
Inherited from Inherited from |
|
|||
Inherited from |
|
Initialize Graph. >>> G=Graph(name="empty") creates empty graph G with G.name="empty"
|
Add a single node to the digraph. The node n can be any hashable object except None. A hashable object is one that can be used as a key in a Python dictionary. This includes strings, numbers, tuples of strings and numbers, etc. On many platforms this also includes mutables such as Graphs, though one should be careful that the hash doesn't change on mutables. >>> from networkx import * >>> G=DiGraph() >>> K3=complete_graph(3) >>> G.add_nodes_from(K3) # add the nodes from K3 to G >>> G.nodes() [0, 1, 2] >>> G.clear() >>> G.add_node(K3) # add the graph K3 as a node in G. >>> G.number_of_nodes() 1
|
Add multiple nodes to the digraph. nlist: A container of nodes that will be iterated through once (thus it should be an iterator or be iterable). Each element of the container should be a valid node type: any hashable type except None. See add_node for details.
|
|
Remove nodes in nlist from the digraph. nlist: an iterable or iterator containing valid node names. Attempting to delete a non-existent node will raise an exception. This could mean some nodes in nlist were deleted and some valid nodes were not!
|
Add a single directed edge (u,v) to the digraph. >> G.add_edge(u,v) and >>> G.add_edge( (u,v) ) are equivalent forms of adding a single edge between nodes u and v. The nodes u and v will be automatically added if not already in the graph. They must be a hashable (except None) Python object. For example, the following examples all add the edge (1,2) to the digraph G. >>> G=DiGraph() >>> G.add_edge( 1, 2 ) # explicit two node form >>> G.add_edge( (1,2) ) # single edge as tuple of two nodes >>> G.add_edges_from( [(1,2)] ) # list of edges form
|
Add all the edges in ebunch to the graph. ebunch: Container of 2-tuples (u,v). The container must be iterable or an iterator. It is iterated over once. Adding the same edge twice has no effect and does not raise an exception. See add_edge for an example.
|
Delete the single directed edge (u,v) from the digraph. Can be used in two basic forms >>> G.delete_edge(u,v) and G.delete_edge( (u,v) ) are equivalent ways of deleting a directed edge u->v. If the edge does not exist return without complaining.
|
Delete the directed edges in ebunch from the digraph. ebunch: Container of 2-tuples (u,v). The container must be iterable or an iterator. It is iterated over once. Edges that are not in the digraph are ignored.
|
Return iterator that iterates once over each edge pointing out of nodes in nbunch, or over all edges in digraph if no nodes are specified. See edges() for definition of nbunch. Nodes in nbunch that are not in the graph will be (quietly) ignored. |
Return iterator that iterates once over each edge adjacent to nodes in nbunch, or over all edges in digraph if no nodes are specified. See edges() for definition of nbunch. Nodes in nbunch that are not in the graph will be (quietly) ignored. |
Return iterator that iterates once over each edge pointing out of nodes in nbunch, or over all edges in digraph if no nodes are specified. See edges() for definition of nbunch. Nodes in nbunch that are not in the graph will be (quietly) ignored.
|
Return list of all edges that point out of nodes in nbunch, or a list of all edges in graph if no nodes are specified. See edges() for definition of nbunch. Nodes in nbunch that are not in the graph will be (quietly) ignored. |
Return list of all edges that point in to nodes in nbunch, or a list of all edges in graph if no nodes are specified. See edges() for definition of nbunch. Nodes in nbunch that are not in the graph will be (quietly) ignored. |
|
|
Return iterator that returns in_degree(n)+out_degree(n) or (n,in_degree(n)+out_degree(n)) for all n in nbunch. If nbunch is ommitted, then iterate over all nodes. Can be called in three ways: G.degree_iter(n): return iterator the degree of node n G.degree_iter(nbunch): return a list of values, one for each n in nbunch (nbunch is any iterable container of nodes.) G.degree_iter(): same as nbunch = all nodes in graph. If with_labels=True, iterator will return an (n,in_degree(n)+out_degree(n)) tuple of node and degree. Any nodes in nbunch but not in the graph will be (quietly) ignored.
|
Return iterator for in_degree(n) or (n,in_degree(n)) for all n in nbunch. If nbunch is ommitted, then iterate over all nodes. See degree_iter method for more details. |
Return iterator for out_degree(n) or (n,out_degree(n)) for all n in nbunch. If nbunch is ommitted, then iterate over all nodes. See degree_iter method for more details. |
Return out-degree of single node or of nbunch of nodes. If nbunch is omitted or nbunch=None, then return out-degrees of all nodes. |
Return in-degree of single node or of nbunch of nodes. If nbunch is omitted or nbunch=None, then return in-degrees of all nodes. |
|
Return a (shallow) copy of the digraph. Identical to dict.copy() of adjacency dicts pred and succ, with name copied as well.
|
Return the subgraph induced on nodes in nbunch. nbunch: can be a single node or any iterable container of of nodes. (It can be an iterable or an iterator, e.g. a list, set, graph, file, numeric array, etc.) Setting inplace=True will return the induced subgraph in original graph by deleting nodes not in nbunch. This overrides create_using. Warning: this can destroy the graph. Unless otherwise specified, return a new graph of the same type as self. Use (optional) create_using=R to return the resulting subgraph in R. R can be an existing graph-like object (to be emptied) or R can be a call to a graph object, e.g. create_using=DiGraph(). See documentation for empty_graph() Note: use subgraph(G) rather than G.subgraph() to access the more general subgraph() function from the operators module.
|
|
Return the undirected representation of the digraph. A new graph is returned (the underlying graph). The edge u-v is in the underlying graph if either u->v or v->u is in the digraph.
|
Return a directed representation of the digraph. This is already directed, so merely return a copy.
|
Home | Trees | Indices | Help |
---|
Generated by Epydoc 3.0beta1 on Sun Aug 17 12:04:45 2008 | http://epydoc.sourceforge.net |