make_small_graph¶
-
make_small_graph
(graph_description, create_using=None)[source]¶ 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 0,..,n-1.
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=nx.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=nx.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=nx.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.