Graph generators#
Atlas#
Generators for the small graph atlas.
|
Returns graph number |
Returns the list of all graphs with up to seven nodes named in the Graph Atlas. |
Classic#
Generators for some classic graphs.
The typical graph builder function is called as follows:
>>> G = nx.complete_graph(100)
returning the complete graph on n nodes labeled 0, .., 99
as a simple graph. Except for empty_graph
, all the functions
in this module return a Graph class (i.e. a simple, undirected graph).
|
Returns the perfectly balanced |
|
Returns the Barbell Graph: two complete graphs connected by a path. |
|
Returns the Binomial Tree of order n. |
|
Return the complete graph |
|
Returns the complete multipartite graph with the specified subset sizes. |
|
Returns the circular ladder graph \(CL_n\) of length n. |
|
Returns the circulant graph \(Ci_n(x_1, x_2, ..., x_m)\) with \(n\) nodes. |
|
Returns the cycle graph \(C_n\) of cyclically connected nodes. |
|
Returns the hierarchically constructed Dorogovtsev--Goltsev--Mendes graph. |
|
Returns the empty graph with n nodes and zero edges. |
|
Creates a full r-ary tree of |
|
Returns the Kneser Graph with parameters |
|
Returns the Ladder graph of length n. |
|
Returns the Lollipop Graph; |
|
Returns the Null graph with no nodes or edges. |
|
Returns the Path graph |
|
Return the star graph |
|
Returns the (m,n)-tadpole graph; |
|
Return the Trivial graph with one node (with label 0) and no edges. |
|
Return the Turan Graph |
|
Return the wheel graph |
Expanders#
Provides explicit constructions of expander graphs.
|
Returns the Margulis-Gabber-Galil undirected MultiGraph on |
|
Returns the chordal cycle graph on |
|
Returns the Paley \(\frac{(p-1)}{2}\) -regular graph on \(p\) nodes. |
|
Utility for creating a random regular expander. |
|
Determines whether the graph G is a regular expander. |
|
Returns a random regular expander graph on \(n\) nodes with degree \(d\). |
Lattice#
Functions for generating grid graphs and lattices
The grid_2d_graph()
, triangular_lattice_graph()
, and
hexagonal_lattice_graph()
functions correspond to the three
regular tilings of the plane, the square, triangular, and hexagonal
tilings, respectively. grid_graph()
and hypercube_graph()
are similar for arbitrary dimensions. Useful relevant discussion can
be found about Triangular Tiling, and Square, Hex and Triangle Grids
|
Returns the two-dimensional grid graph. |
|
Returns the n-dimensional grid graph. |
|
Returns an |
Returns the n-dimensional hypercube graph. |
|
|
Returns the \(m\) by \(n\) triangular lattice graph. |
Small#
Various small and named graphs, together with some compact generators.
|
Return the cubic graph specified in LCF notation. |
|
Returns the Bull Graph |
|
Returns the Chvátal Graph |
|
Returns the 3-regular Platonic Cubical Graph |
|
Returns the Desargues Graph |
|
Returns the Diamond graph |
|
Returns the Platonic Dodecahedral graph. |
|
Returns the Frucht Graph. |
|
Returns the Heawood Graph, a (3,6) cage. |
Returns the Hoffman-Singleton Graph. |
|
|
Returns the House graph (square with triangle on top) |
|
Returns the House graph with a cross inside the house square. |
|
Returns the Platonic Icosahedral graph. |
|
Returns the Krackhardt Kite Social Network. |
|
Returns the Moebius-Kantor graph. |
|
Returns the Platonic Octahedral graph. |
Returns the Pappus graph. |
|
|
Returns the Petersen graph. |
|
Return a small maze with a cycle. |
|
Returns the 3-regular Platonic Tetrahedral graph. |
|
Returns the skeleton of the truncated cube. |
|
Returns the skeleton of the truncated Platonic tetrahedron. |
|
Returns the Tutte graph. |
Random Graphs#
Generators for random graphs.
|
Returns a \(G_{n,p}\) random graph, also known as an Erdős-Rényi graph or a binomial graph. |
|
Returns a \(G_{n,p}\) random graph, also known as an Erdős-Rényi graph or a binomial graph. |
|
Returns a \(G_{n,m}\) random graph. |
|
Returns a \(G_{n,m}\) random graph. |
|
Returns a \(G_{n,p}\) random graph, also known as an Erdős-Rényi graph or a binomial graph. |
|
Returns a \(G_{n,p}\) random graph, also known as an Erdős-Rényi graph or a binomial graph. |
|
Returns a Newman–Watts–Strogatz small-world graph. |
|
Returns a Watts–Strogatz small-world graph. |
|
Returns a connected Watts–Strogatz small-world graph. |
|
Returns a random \(d\)-regular graph on \(n\) nodes. |
|
Returns a random graph using Barabási–Albert preferential attachment |
|
Returns a random graph using dual Barabási–Albert preferential attachment |
|
Returns an extended Barabási–Albert model graph. |
|
Holme and Kim algorithm for growing graphs with powerlaw degree distribution and approximate average clustering. |
|
Returns an random graph based on the specified kernel. |
|
Returns a random lobster graph. |
|
Returns a random shell graph for the constructor given. |
|
Returns a tree with a power law degree distribution. |
|
Returns a degree sequence for a tree with a power law distribution. |
|
Returns an random graph based on the specified kernel. |
Duplication Divergence#
Functions for generating graphs based on the “duplication” method.
These graph generators start with a small initial graph then duplicate nodes and (partially) duplicate their edges. These functions are generally inspired by biological networks.
|
Returns an undirected graph using the duplication-divergence model. |
|
Returns a random graph using the partial duplication model. |
Degree Sequence#
Generate graphs with a given degree sequence or expected degree sequence.
|
Returns a random graph with the given degree sequence. |
|
Returns a directed_random graph with the given degree sequences. |
|
Returns a random graph with given expected degrees. |
|
Returns a simple graph with given degree sequence constructed using the Havel-Hakimi algorithm. |
|
Returns a directed graph with the given degree sequences. |
|
Make a tree for the given degree sequence. |
|
Returns a simple random graph with the given degree sequence. |
Random Clustered#
Generate graphs with given degree and triangle sequence.
|
Generate a random graph with the given joint independent edge degree and triangle degree sequence. |
Directed#
Generators for some directed graphs, including growing network (GN) graphs and scale-free graphs.
|
Returns the growing network (GN) digraph with |
|
Returns the growing network with redirection (GNR) digraph with |
|
Returns the growing network with copying (GNC) digraph with |
|
Returns a random |
|
Returns a scale-free directed graph. |
Geometric#
Generators for geometric graphs.
|
Returns edge list of node pairs within |
|
Returns a geographical threshold graph. |
|
Returns a navigable small-world graph. |
|
Returns a random geometric graph in the unit cube of dimensions |
|
Returns a soft random geometric graph in the unit cube. |
|
Returns a thresholded random geometric graph in the unit cube. |
|
Returns a Waxman random graph. |
|
Returns a random graph from the geometric soft configuration model. |
Line Graph#
Functions for generating line graphs.
|
Returns the line graph of the graph or digraph |
Returns the inverse line graph of graph G. |
Ego Graph#
Ego graph.
|
Returns induced subgraph of neighbors centered at node n within a given radius. |
Stochastic#
Functions for generating stochastic graphs from a given weighted directed graph.
|
Returns a right-stochastic representation of directed graph |
AS graph#
Generates graphs resembling the Internet Autonomous System network
|
Generates a random undirected graph resembling the Internet AS network |
Intersection#
Generators for random intersection graphs.
|
Returns a uniform random intersection graph. |
|
Returns a intersection graph with randomly chosen attribute sets for each node that are of equal size (k). |
|
Returns a random intersection graph with independent probabilities for connections between node and attribute sets. |
Community#
Generators for classes of graphs used in studying social networks.
|
Returns a caveman graph of |
|
Returns a connected caveman graph of |
|
Generate a Gaussian random partition graph. |
|
Returns the LFR benchmark graph. |
|
Returns the planted l-partition graph. |
|
Returns the random partition graph with a partition of sizes. |
|
Returns a relaxed caveman graph. |
|
Defines a "ring of cliques" graph. |
|
Returns a stochastic block model graph. |
|
Generate a windmill graph. |
Spectral#
Generates graphs with a given eigenvector structure
|
Returns a random simple graph with spectrum resembling that of |
Trees#
Functions for generating trees.
The functions sampling trees at random in this module come in two variants: labeled and unlabeled. The labeled variants sample from every possible tree with the given number of nodes uniformly at random. The unlabeled variants sample from every possible isomorphism class of trees with the given number of nodes uniformly at random.
To understand the difference, consider the following example. There are two isomorphism classes of trees with four nodes. One is that of the path graph, the other is that of the star graph. The unlabeled variant will return a line graph or a star graph with probability 1/2.
The labeled variant will return the line graph with probability 3/4 and the star graph with probability 1/4, because there are more labeled variants of the line graph than of the star graph. More precisely, the line graph has an automorphism group of order 2, whereas the star graph has an automorphism group of order 6, so the line graph has three times as many labeled variants as the star graph, and thus three more chances to be drawn.
Additionally, some functions in this module can sample rooted trees and forests uniformly at random. A rooted tree is a tree with a designated root node. A rooted forest is a disjoint union of rooted trees.
|
Creates a directed prefix tree from a list of paths. |
|
Returns a labeled tree on |
|
Returns a labeled rooted tree with |
|
Returns a labeled rooted forest with |
|
Returns a tree or list of trees chosen randomly. |
|
Returns a number of unlabeled rooted trees uniformly at random |
|
Returns a forest or list of forests selected at random. |
Non Isomorphic Trees#
Implementation of the Wright, Richmond, Odlyzko and McKay (WROM) algorithm for the enumeration of all non-isomorphic free trees of a given order. Rooted trees are represented by level sequences, i.e., lists in which the i-th element specifies the distance of vertex i to the root.
|
Generates lists of nonisomorphic trees |
Returns the number of nonisomorphic trees |
Triads#
Functions that generate the triad graphs, that is, the possible digraphs on three nodes.
|
Returns the triad graph with the given name. |
Joint Degree Sequence#
Generate graphs with a given joint degree and directed joint degree
|
Checks whether the given joint degree dictionary is realizable. |
|
Generates a random simple graph with the given joint degree dictionary. |
|
Checks whether the given directed joint degree input is realizable |
|
Generates a random simple directed graph with the joint degree. |
Mycielski#
Functions related to the Mycielski Operation and the Mycielskian family of graphs.
|
Returns the Mycielskian of a simple, undirected graph G |
Generator for the n_th Mycielski Graph. |
Harary Graph#
Generators for Harary graphs
This module gives two generators for the Harary graph, which was introduced by the famous mathematician Frank Harary in his 1962 work [H]. The first generator gives the Harary graph that maximizes the node connectivity with given number of nodes and given number of edges. The second generator gives the Harary graph that minimizes the number of edges in the graph with given node connectivity and number of nodes.
References#
Harary, F. “The Maximum Connectivity of a Graph.” Proc. Nat. Acad. Sci. USA 48, 1142-1146, 1962.
|
Returns the Harary graph with given numbers of nodes and edges. |
|
Returns the Harary graph with given node connectivity and node number. |
Cographs#
Generators for cographs
A cograph is a graph containing no path on four vertices. Cographs or \(P_4\)-free graphs can be obtained from a single vertex by disjoint union and complementation operations.
References#
D.G. Corneil, H. Lerchs, L.Stewart Burlingham, “Complement reducible graphs”, Discrete Applied Mathematics, Volume 3, Issue 3, 1981, Pages 163-174, ISSN 0166-218X.
|
Returns a random cograph with \(2 ^ n\) nodes. |
Interval Graph#
Generators for interval graph.
|
Generates an interval graph for a list of intervals given. |
Sudoku#
Generator for Sudoku graphs
This module gives a generator for n-Sudoku graphs. It can be used to develop algorithms for solving or generating Sudoku puzzles.
A completed Sudoku grid is a 9x9 array of integers between 1 and 9, with no number appearing twice in the same row, column, or 3x3 box.
8 6 4
3 2 5
9 7 1
|
3 7 1
8 4 9
2 6 5
|
2 5 9
7 6 1
8 4 3
|
4 3 6
1 9 8
2 5 7
|
1 9 2
6 5 7
4 8 3
|
5 8 7
4 3 2
9 1 6
|
6 8 9
7 1 3
5 4 2
|
7 3 4
5 2 8
9 1 6
|
1 2 5
6 9 4
3 7 8
|
The Sudoku graph is an undirected graph with 81 vertices, corresponding to the cells of a Sudoku grid. It is a regular graph of degree 20. Two distinct vertices are adjacent if and only if the corresponding cells belong to the same row, column, or box. A completed Sudoku grid corresponds to a vertex coloring of the Sudoku graph with nine colors.
More generally, the n-Sudoku graph is a graph with n^4 vertices, corresponding to the cells of an n^2 by n^2 grid. Two distinct vertices are adjacent if and only if they belong to the same row, column, or n by n box.
References#
Herzberg, A. M., & Murty, M. R. (2007). Sudoku squares and chromatic polynomials. Notices of the AMS, 54(6), 708-717.
Sander, Torsten (2009), “Sudoku graphs are integral”, Electronic Journal of Combinatorics, 16 (1): Note 25, 7pp, MR 2529816
Wikipedia contributors. “Glossary of Sudoku.” Wikipedia, The Free Encyclopedia, 3 Dec. 2019. Web. 22 Dec. 2019.
|
Returns the n-Sudoku graph. |
Time Series#
Time Series Graphs
|
Return a Visibility Graph of an input Time Series. |