generate_extended_ba#
- graph_tool.generation.generate_extended_ba(N, m, p, q)[git][source]#
Generate a graph with the extended Barabási-Albert model, with edge additions and rewiring.
- Parameters:
- N
int Number of vertices.
- m
int Number of edges added, rewired, or attached by a new vertex in every step.
- p
float Probability of adding \(m\) edges between existing vertices.
- q
float Probability of rewiring \(m\) edges.
- N
- Returns:
- g
Graph The generated undirected graph.
- g
See also
price_networkPrice’s and Barabási-Albert’s preferential attachment
generate_dual_baPreferential attachment with two numbers of edges
generate_holme_kimPreferential attachment with tunable clustering
Notes
In this extension of the Barabási–Albert model by Albert and Barabási [albert-topology-2000], the graph starts with \(m\) isolated vertices, and every step performs one of three operations: 1. with probability \(p\), \(m\) new edges are added, each between a uniformly chosen vertex and one chosen with probability proportional to its degree plus one (if the graph is not complete); 2. with probability \(q\), \(m\) edges are rewired, each by choosing a uniform vertex \(u\) and a random edge \((u, v)\) of it, which is replaced by \((u, w)\), where \(w\) is chosen with probability proportional to its degree plus one; and 3. otherwise, a new vertex is added with \(m\) edges to distinct vertices chosen in the same way. Self-loops and parallel edges are never formed: in operations 1 and 2, the uniformly chosen vertex \(u\) is drawn among the vertices that are not adjacent to all others (and, in operation 2, that have at least one edge), and the preferentially chosen vertex among those different from \(u\) and not adjacent to it. If operation 1 would exceed the number of edges of a complete graph, or if operation 2 is drawn with fewer than \(m\) edges or a complete graph, a new vertex is added instead (operation 3). The process stops when \(N\) vertices are present. The eligible vertices are determined anew for every edge.
References
[albert-topology-2000]Réka Albert and Albert-László Barabási, “Topology of evolving networks: Local events and universality”, Physical Review Letters 85, 5234-5237 (2000), DOI: 10.1103/PhysRevLett.85.5234 [sci-hub, @tor], arXiv: cond-mat/0005085
Examples
>>> g = gt.generate_extended_ba(10000, 2, 0.2, 0.1) >>> print(g.num_edges()) 25696
A smaller instance is drawn as follows:
>>> g = gt.generate_extended_ba(200, 1, 0.2, 0.1) >>> gt.graph_draw(g, pos=gt.sfdp_layout(g), ... output="generate_extended_ba-small.pdf") <...>
Extended Barabási–Albert graph with \(N=200\), \(m=1\), \(p=0.2\), and \(q=0.1\).#