Package networkx :: Package generators :: Module small
[hide private]
[frames] | no frames]

Module small

source code

Various small and named graphs, together with some compact generators.


Date: $Date: 2005-06-15 12:53:08 -0600 (Wed, 15 Jun 2005) $

Author: Aric Hagberg (hagberg@lanl.gov) Pieter Swart (swart@lanl.gov)

Functions [hide private]
 
make_small_graph(graph_description, create_using=None)
Return the small graph described by graph_description.
source code
 
LCF_graph(n, shift_list, repeats)
Return the cubic graph specified in LCF notation.
source code
 
bull_graph()
Return the Bull graph.
source code
 
chvatal_graph()
Return the Chvatal graph.
source code
 
cubical_graph()
Return the 3-regular Platonic Cubical graph.
source code
 
desargues_graph()
Return the Desargues graph.
source code
 
diamond_graph()
Return the Diamond graph.
source code
 
dodecahedral_graph()
Return the Platonic Dodecahedral graph.
source code
 
frucht_graph()
Return the Frucht Graph.
source code
 
heawood_graph()
Return the Heawood graph, a (3,6) cage.
source code
 
house_graph()
Return the House graph (square with triangle on top).
source code
 
house_x_graph()
Return the House graph with a cross inside the house square.
source code
 
icosahedral_graph()
Return the Platonic Icosahedral graph.
source code
 
krackhardt_kite_graph()
Return the Krackhardt Kite Social Network.
source code
 
moebius_kantor_graph()
Return the Moebius-Kantor graph.
source code
 
octahedral_graph()
Return the Platonic Octahedral graph.
source code
 
pappus_graph()
Return the Pappus graph.
source code
 
petersen_graph()
Return the Petersen graph.
source code
 
sedgewick_maze_graph()
Return a small maze with a cycle.
source code
 
tetrahedral_graph()
Return the 3-regular Platonic Tetrahedral graph.
source code
 
truncated_cube_graph()
Return the skeleton of the truncated cube.
source code
 
truncated_tetrahedron_graph()
Return the skeleton of the truncated Platonic tetrahedron.
source code
 
tutte_graph()
Return the Tutte graph.
source code
 
_test_suite()
test hook
source code
Variables [hide private]
  __credits__ = ''
  __revision__ = '$Revision: 1040 $'
Function Details [hide private]

make_small_graph(graph_description, create_using=None)

source code 

Return the small graph described by graph_description.

graph_description is a list of the form [ltype,name,n,xlist]

Here ltype is one of "adjacencylist" or "edgelist", name is the name of the graph and n the number of nodes. This constructs a graph of n nodes with integer labels 1,..,n.

If ltype="adjacencylist" then xlist is an adjacency list with exactly n entries, in with the j'th entry (which can be empty) specifies the nodes connected to vertex j. e.g. the "square" graph C_4 can be obtained by

>>> G=make_small_graph(["adjacencylist","C_4",4,[[2,4],[1,3],[2,4],[1,3]]])

or, since we do not need to add edges twice,

>>> G=make_small_graph(["adjacencylist","C_4",4,[[2,4],[3],[4],[]]])

If ltype="edgelist" then xlist is an edge list written as [[v1,w2],[v2,w2],...,[vk,wk]], where vj and wj integers in the range 1,..,n e.g. the "square" graph C_4 can be obtained by

>>> G=make_small_graph(["edgelist","C_4",4,[[1,2],[3,4],[2,3],[4,1]]])

Use the create_using argument to choose the graph class/type.

LCF_graph(n, shift_list, repeats)

source code 

Return the cubic graph specified in LCF notation.

LCF notation (LCF=Lederberg-Coxeter-Fruchte) is a compressed notation used in the generation of various cubic Hamiltonian graphs of high symmetry. See, for example, dodecahedral_graph, desargues_graph, heawood_graph and pappus_graph below.

n (number of nodes)
The starting graph is the n-cycle with nodes 0,...,n-1. (The null graph is returned if n < 0.)

shift_list = [s1,s2,..,sk], a list of integer shifts mod n,

repeats
integer specifying the number of times that shifts in shift_list are successively applied to each v_current in the n-cycle to generate an edge between v_current and v_current+shift mod n.

For v1 cycling through the n-cycle a total of k*repeats with shift cycling through shiftlist repeats times connect v1 with v1+shift mod n

The utility graph K_{3,3}

>>> G=LCF_graph(6,[3,-3],3)

The Heawood graph

>>> G=LCF_graph(14,[5,-5],7)

See http://mathworld.wolfram.com/LCFNotation.html for a description and references.

frucht_graph()

source code 

Return the Frucht Graph.

The Frucht Graph is the smallest cubical graph whose automorphism group consists only of the identity element.

krackhardt_kite_graph()

source code 

Return the Krackhardt Kite Social Network.

A 10 actor social network introduced by David Krackhardt to illustrate: degree, betweenness, centrality, closeness, etc. The traditional labeling is: Andre=1, Beverley=2, Carol=3, Diane=4, Ed=5, Fernando=6, Garth=7, Heather=8, Ike=9, Jane=10.

sedgewick_maze_graph()

source code 

Return a small maze with a cycle.

This is the maze used in Sedgewick,3rd Edition, Part 5, Graph Algorithms, Chapter 18, e.g. Figure 18.2 and following. Nodes are numbered 0,..,7