Home | Trees | Indices | Help |
---|
|
object --+ | graph.Graph --+ | Tree
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
Inherited from Inherited from |
|
|||
Inherited from |
|
Initialize Graph. >>> G=Graph(name="empty") creates empty graph G with G.name="empty"
|
Add a single node n to the graph. 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 e.g., though one should be careful the hash doesn't change on mutables. Example: >>> from networkx import * >>> G=Graph() >>> K3=complete_graph(3) >>> G.add_node(1) >>> G.add_node('Hello') >>> G.add_node(K3) >>> G.number_of_nodes() 3
|
Add multiple nodes to the graph. 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. Examples: >>> from networkx import * >>> G=Graph() >>> K3=complete_graph(3) >>> G.add_nodes_from('Hello') >>> G.add_nodes_from(K3) >>> sorted(G.nodes()) [0, 1, 2, 'H', 'e', 'l', 'o']
|
|
Remove nodes in nlist from graph. 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 got deleted and other valid nodes did not.
|
Add a single edge (u,v) to the graph. >> 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. The following examples all add the edge (1,2) to graph G. >>> G=Graph() >>> 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)] ) # add edges from iterable container
|
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.
|
Delete the single edge (u,v). Can be used in two basic forms: >>> G.delete_edge(u,v) and >> G.delete_edge( (u,v) ) are equivalent ways of deleting a single edge between nodes u and v. Return without complaining if the nodes or the edge do not exist.
|
Delete the edges in ebunch from the graph. ebunch: an iterator or iterable of 2-tuples (u,v). Edges that are not in the graph are ignored.
|
Polymorphic helper method for Graph.union(). Required keywords: v_from and v_to, where v_from is the node in self to which v_to should be attached as child. |
Home | Trees | Indices | Help |
---|
Generated by Epydoc 3.0beta1 on Sun Aug 17 12:04:47 2008 | http://epydoc.sourceforge.net |