graph_tool.generation#
This module contains functions that generate different kinds of graphs.
Random graph generation#
Generate a random graph, with a given degree distribution and (optionally) vertex-vertex correlation. |
|
Shuffle the graph in-place, following a variety of possible statistical models, chosen via the parameter |
|
Return a degree-preserving randomization of a simple undirected graph, optionally keeping it connected. |
|
Return a degree-preserving rewiring of a simple undirected graph towards a ring lattice. |
|
Check whether a degree sequence can be realized by a graph. |
|
Add new edges to a graph, chosen uniformly at random. |
|
Remove edges from the graph, chosen uniformly at random. |
|
Closes open triads in a graph, according to an ego-based process. |
|
Corrupt a graph by removing and adding edges at random. |
|
A generalized version of Price's --- or Barabási-Albert if undirected --- preferential attachment network model. |
|
Generate a random graph with given expected degrees, with the Chung-Lu model or one of its variants. |
|
Generate a random graph with a given number of edges, whose endpoints are chosen with probabilities proportional to vertex fitnesses. |
|
Generate a random graph with power-law degree distributions, with the static model. |
|
Generate a random graph from an inhomogeneous random graph model with a given kernel. |
|
Generate a random intersection graph. |
|
Generate a random simple graph with a given joint degree matrix. |
|
Check whether a joint degree matrix can be realized by a simple graph. |
|
Generate a random graph with approximately the same spectral structure as a given one. |
|
Generate a random shell graph. |
|
Generate a random cograph with \(2^n\) vertices. |
|
Generate a uniformly random tournament. |
|
Generate a random \(k\)-lift of a graph. |
|
Generate a random regular graph that is a (near-)Ramanujan expander. |
|
Generate a random graph of the Internet at the level of autonomous systems. |
|
Generate a random connected simple graph with a given degree sequence. |
|
Generate a multigraph with the clustered configuration model, with given numbers of single edges and triangles at every vertex. |
|
Generate a (generalized) random dot product graph. |
Stochastic block models#
Generate a random graph by sampling from the Poisson or microcanonical stochastic block model. |
|
Generate a random graph by sampling from the maximum-entropy "canonical" stochastic block model. |
|
Generate a random graph with planted communities according to the benchmark of Lancichinetti, Fortunato, and Radicchi (LFR). |
|
Generate a small-world graph with the Watts-Strogatz model. |
|
Generate a graph with the forest fire model. |
|
Generate a graph with the \(\mathbb{S}^1\) geometric model (or its hyperbolic version \(\mathbb{H}^2\)). |
|
Generate a graph with the R-MAT model. |
|
Return a graph with the given degree sequence. |
|
Generate a random graph with the Erdős-Rényi model. |
|
Generate a graph with the power-law out-degree (PLOD) model. |
|
Generate a graph of the SSCA#2 benchmark. |
|
Obtain SBM fugacities, given expected degrees and edge counts between groups. |
|
Generate a simple graph from the planted partition model. |
|
Generate a relaxed caveman graph. |
Growing network models#
Generate a scale-free graph with tunable clustering, with the model of Holme and Kim. |
|
Generate a graph with the dual Barabási-Albert model. |
|
Generate a graph with the extended Barabási-Albert model, with edge additions and rewiring. |
|
Generate a directed multigraph where every vertex has out-degree \(k\), with preferential attachment. |
|
Generate a directed tree with the growing network (GN) model. |
|
Generate a directed tree with the growing network with redirection (GNR) model. |
|
Generate a directed acyclic graph with the growing network with copying (GNC) model. |
|
Generate a directed scale-free multigraph with the model of Bollobás, Borgs, Chayes, and Riordan. |
|
Generate a graph with the establishment model, a growing model with vertex types. |
|
Generate a growing random multigraph. |
|
Generate a multigraph by preferential attachment to the recently gained degree. |
|
Generate a graph with the duplication-divergence model. |
|
Generate a graph with the partial duplication model. |
|
Generate a multigraph by preferential attachment with aging of the vertices. |
|
Generate a citation multigraph in which the citation probabilities depend on vertex types. |
Geometric models#
Generate a graph of k-nearest neighbors (or pairs) from a set of multidimensional points. |
|
Generate a geometric network from a set of N-dimensional points. |
|
Generate a 2D or 3D triangulation graph from a given point set. |
|
Generate a geographical threshold graph. |
|
Generate a Waxman random graph. |
|
Generate a soft random geometric graph. |
|
Generate a thresholded random geometric graph. |
|
Generate a navigable small-world graph with Kleinberg's model. |
|
Return the Gabriel graph of a set of points. |
|
Return the relative neighborhood graph of a set of points. |
|
Return the \(\beta\)-skeleton of a set of points. |
Random trees#
Generate a uniformly random tree. |
|
Generate a uniformly random rooted forest. |
|
Generate a random tree with a power-law degree distribution. |
|
Generate a random lobster graph. |
|
Iterate over all nonisomorphic (unlabeled) trees with \(N\) vertices. |
|
Return the number of nonisomorphic (unlabeled) trees with \(N\) vertices. |
Bipartite graphs#
Generate a random bipartite graph with the Erdős-Rényi model. |
|
Generate a random bipartite multigraph with given degrees, with the configuration model. |
|
Generate a bipartite multigraph with the preferential attachment model of Guillaume and Latapy. |
|
Return a bipartite graph with the given degrees. |
Graph transformations#
Return a graph from a list of predecessors given by the |
|
Return the line graph of the given graph |
|
Obtain the condensation graph, where each vertex with the same 'prop' value is condensed in one vertex. |
|
Contract all parallel edges into simple edges, keeping track of their multiplicities. |
|
Remove all parallel edges from the graph. |
|
Expand edge multiplicities into parallel edges. |
|
Label edges which are parallel, i.e., have the same source and target vertices. |
|
Remove all self-loop edges from the graph. |
|
Label edges which are self-loops, i.e., the source and target vertices are the same. |
|
Remove every edge |
|
Return the projection of selected vertices on the remaining vertices. |
|
Return the root graph of a line graph. |
|
Return the \(k\)-th power of a graph. |
|
Compress a graph by replacing the edges to groups of high-degree vertices with compressor vertices. |
|
Summarize a graph by aggregating its vertices with the SNAP algorithm. |
|
Return the Mycielskian of an undirected graph. |
|
Duplicate the vertices of a graph. |
|
Add edges to the graph to make it maximally planar. |
|
Return the moral graph of a directed acyclic graph. |
Graph set operations#
Merge the edges of graph |
|
Return a graph containing the union of the vertices and edges of graphs |
|
Return a graph containing the differences of the edges of graphs |
|
Return a graph containing the symmetric difference of the edges of graphs |
|
Return a graph containing the intersection of the edges of graphs |
|
Return the product of two graphs. |
|
Return the join of two graphs. |
|
Return the relational composition of two graphs. |
|
Return the complement of a graph. |
Deterministic graphs#
Return a named graph, or a member of a deterministic family of graphs. |
|
Generate an N-dimensional square lattice. |
|
Generate a complete graph. |
|
Generate a circular graph. |
|
Return the interval graph of a set of closed intervals. |
|
Return the natural visibility graph of a time series. |
|
Return a tree with the given degree sequence. |
|
Return the labeled tree with the given Prüfer sequence. |