Home | Trees | Indices | Help |
---|
|
object --+ | Graph
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
Inherited from |
|
|||
Inherited from |
|
Initialize Graph. >>> G=Graph(name="empty") creates empty graph G with G.name="empty"
|
|
Return an iterator over the nodes in G. This is the iterator for the underlying adjacency dict. (Allows the expression 'for n in G') |
Return True if n is a node in graph. Allows the expression 'n in G'. Testing whether an unhashable object, such as a list, is in the dict datastructure (self.adj) will raise a TypeError. Rather than propagate this to the calling method, just return False. |
Return the neighbors of node n as a list. This provides graph G the natural property that G[n] returns the neighbors of G. |
Return a sequence (or iterator) of nodes contained in nbunch which are also in the graph. The input nbunch can be a single node, a sequence or iterator of nodes or None (omitted). If None, all nodes in the graph are returned. Note: This routine exhausts any iterator nbunch. Note: To test whether nbunch is a single node, one can use "if nbunch in self:", even after processing with this routine. Note: This routine returns an empty list if nbunch is not either a node, sequence, iterator, or None. You can catch this exception if you want to change this behavior. |
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. |
Return True if graph has node n. (duplicates self.__contains__) "n in G" is a more readable version of "G.has_node(n)"? |
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. |
Return True if node u has neighbor v. This is equivalent to has_edge(u,v). |
|
Return iterator that iterates once over each edge adjacent to nodes in nbunch, or over all edges in graph if no nodes are specified. If nbunch is None return all edges in the graph. The argument nbunch can be any single node, or any sequence or iterator of nodes. Nodes in nbunch that are not in the graph will be (quietly) ignored. |
Return list of all edges that are adjacent to a node in nbunch, or a list of all edges in graph if no nodes are specified. If nbunch is None return all edges in the graph. The argument nbunch can be any single node, or any sequence or iterator of nodes. Nodes in nbunch that are not in the graph will be (quietly) ignored. For digraphs, edges=out_edges |
Return list of edges (n1,n2) with n1 in nbunch1 and n2 in nbunch2. If nbunch2 is omitted or nbunch2=None, then nbunch2 is all nodes not in nbunch1. Nodes in nbunch1 and nbunch2 that are not in the graph are ignored. nbunch1 and nbunch2 are usually meant to be disjoint, but in the interest of speed and generality, that is not required here. This routine is faster if nbunch1 is smaller than nbunch2. |
Return list of all nodes on external boundary of nbunch1 that are in nbunch2. If nbunch2 is omitted or nbunch2=None, then nbunch2 is all nodes not in nbunch1. Note that by definition the node_boundary is external to nbunch1. Nodes in nbunch1 and nbunch2 that are not in the graph are ignored. nbunch1 and nbunch2 are usually meant to be disjoint, but in the interest of speed and generality, that is not required here. This routine is faster if nbunch1 is smaller than nbunch2. |
Return degree of single node or of nbunch of nodes. If nbunch is omitted or nbunch=None, then return degrees of all nodes. The degree of a node is the number of edges attached to that node. Can be called in three ways: G.degree(n): return the degree of node n G.degree(nbunch): return a list of values, one for each n in nbunch (nbunch is any iterable container of nodes.) G.degree(): same as nbunch = all nodes in graph. If with_labels==True, then return a dict that maps each n in nbunch to degree(n). Any nodes in nbunch that are not in the graph are (quietly) ignored. |
Return iterator that return degree(n) or (n,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,degree(n)) tuple of node and degree. Any nodes in nbunch that are not in the graph are (quietly) ignored. |
Return a (shallow) copy of the graph. Identical to dict.copy() of adjacency dict adj, with name copied as well. |
Return the undirected representation of the graph G. This graph is undirected, so merely return a copy. |
Return a directed representation of the graph G. A new digraph is returned with the same name, same nodes and with each edge u-v represented by two directed edges u->v and v->u. |
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 the 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 number of edges between nodes u and v. If u and v are not specified return the number of edges in the entire graph. The edge argument e=(u,v) can be specified as G.number_of_edges(u,v) or G.number_of_edges(e) |
Home | Trees | Indices | Help |
---|
Generated by Epydoc 3.0beta1 on Sun Aug 17 12:04:45 2008 | http://epydoc.sourceforge.net |