Home | Trees | Index | Help |
|
---|
Package NX :: Package generators :: Module classic |
|
Generators for some classic graphs.
The typical graph generator is called as follows:
>>> G=complete_graph(100)
returning the complete graph on n nodes labeled 1,..,100 as a simple graph. Except for empty_graph, all these generators return a Graph class (i.e. a simple undirected graph).
Function Summary | |
---|---|
Return the perfectly balanced r-tree of height h. | |
Return the Barbell Graph: two complete graphs connected by a path. | |
Return the circular ladder graph CL_n of length n. | |
Return the complete bipartite graph K_{n1_n2}. | |
Return the Complete graph K_n with n nodes. | |
Return the cycle graph C_n over n nodes. | |
Return the empty graph with n nodes (with integer labels 1,...,n) and zero edges. | |
Return the 2d grid graph of mxn nodes, each connected to its nearest neighbors. | |
Return the n-dimensional grid graph. | |
return the n-dimensional hypercube. | |
Return the Ladder graph of length n. | |
Return the Lollipop Graph; K_m connected to P_n. | |
Return the Null graph with no nodes or edges. | |
Return the Path graph P_n of n nodes linearly connected by n-1 edges. | |
Return the 2-D Grid Graph of mxn nodes, each connected to its nearest neighbors. | |
Return the Star graph with n+1 nodes: one center node, connected to n outer nodes. | |
Return the Trivial graph with one node (with integer label 1) and no edges. | |
Return the wheel graph: a single hub node connected to each node of the (n-1)-node cycle graph. |
Variable Summary | |
---|---|
str |
__author__ = 'Aric Hagberg (hagberg@lanl.gov)\nPieter Sw...
|
str |
__credits__ = ''
|
str |
__date__ = '$Date: 2005/04/08 19:02:59 $'
|
str |
__revision__ = '$Revision: 1.36 $'
|
Function Details |
---|
balanced_tree(r, h)Return the perfectly balanced r-tree of height h. For r>=2, h>=1, this is the rooted tree where all leaves are at distance h from the root. The root has degree r and all other internal nodes have degree r+1. Graph order=1+r+r**2+...+r**h=(r**(h+1)-1)/(r-1), graph size=order-1. Node labels are integers numbered 1 (the root) up to order. |
barbell_graph(m1, m2)Return the Barbell Graph: two complete graphs connected by a path. For m1>1 and m2>=0. Two complete graphs K_{m1} form the left and right bells, and are connected by a path P_{m2}. The 2*m1+m2 nodes are numbered 1,...,m1 for the left barbell, m1+1,...,m1+m2 for the path, and m1+m2+1,...,2*m1+m2 for the right barbell. The 3 subgraphs are joined via the edges (m1,m1+1) and (m1+m2,m1+m2+1). If m2=0, this is merely two complete graphs joined together. This graph is an extremal example in David Aldous and Jim Fill's etext on Random Walks on Graphs. |
circular_ladder_graph(n)Return the circular ladder graph CL_n of length n. CL_n consists of two concentric n-cycles in which each of the n pairs of concentric nodes are joined by an edge. |
complete_bipartite_graph(n1, n2)Return the complete bipartite graph K_{n1_n2}. Contains n1 nodes in the first subgraph and n2 nodes in the second subgraph. |
complete_graph(n)Return the Complete graph K_n with n nodes. |
cycle_graph(n)Return the cycle graph C_n over n nodes. C_n is P_n with two end-nodes connected. |
empty_graph(n=0, create_using=None, **kwds)Return the empty graph with n nodes (with integer labels 1,...,n) and zero edges. >>> G=empty_graph(n) The variable create_using should point to a "graph"-like object that will be cleaned (nodes and edges will be removed) and refitted as an empty "graph" with n nodes with integer labels. This capability is useful for specifying the class-nature of the resulting empty "graph" (i.e. Graph, DiGraph, MyWeirdGraphClass, etc.). Firstly, the variable create_using can be used to create an empty digraph, network,etc. For example, >>> G=empty_graph(n,create_using=DiGraph()) will create an empty digraph on n nodes, and >>> G=empty_graph(n,create_using=DiGraph()) will create an empty digraph on n nodes. Secondly, one can pass an existing graph (digraph, pseudograph, etc.) via create_using. For example, if G is an existing graph (resp. digraph, pseudograph, etc.), then empty_graph(n,create_using=G) will empty G (i.e. delete all nodes and edges using G.clear() in baseNX) and then add n nodes and zero edges, and return the modified graph (resp. digraph, pseudograph, etc.). WARNING: The graph dna is not scrubbed in this process. See also create_empty_copy(G). |
grid_2d_graph(m, n)Return the 2d grid graph of mxn nodes, each connected to its nearest neighbors. |
grid_graph(dim, periodic=False)Return the n-dimensional grid graph. The dimension is the length of the list 'dim' and the size in each dimension is the value of the list element. E.g. G=grid_graph(dim=[2,3]) produces a 2x3 grid graph. If periodic=True then join grid edges with periodic boundary conditions. |
hypercube_graph(n)return the n-dimensional hypercube. |
ladder_graph(n)Return the Ladder graph of length n. This is two rows of n nodes, each pair connected by a single edge. |
lollipop_graph(m, n)Return the Lollipop Graph; K_m connected to P_n. This is the Barbell Graph without the right barbell. For m>1 and n>=0, the complete graph K_m is connected to the path P_n. The resulting m+n nodes are labelled 1,...,m for the complete graph and m+1,...,m+n for the path. The 2 subgraphs are joined via the edge (m,n). If n=0, this is merely a complete graph. (This graph is an extremal example in David Aldous and Jim Fill's etext on Random Walks on Graphs.) |
null_graph(create_using=None, **kwds)Return the Null graph with no nodes or edges. |
path_graph(n)Return the Path graph P_n of n nodes linearly connected by n-1 edges. |
periodic_grid_2d_graph(m, n, create_using=None, **kwds)Return the 2-D Grid Graph of mxn nodes, each connected to its nearest neighbors. Boundary nodes are identified in a periodic fashion. |
star_graph(n)Return the Star graph with n+1 nodes: one center node, connected to n outer nodes. |
trivial_graph()Return the Trivial graph with one node (with integer label 1) and no edges. |
wheel_graph(n)Return the wheel graph: a single hub node connected to each node of the (n-1)-node cycle graph. |
Variable Details |
---|
__author__
|
__credits__
|
__date__
|
__revision__
|
Home | Trees | Index | Help |
|
---|
Generated by Epydoc 2.1 on Mon Apr 11 10:59:19 2005 | http://epydoc.sf.net |