generate_bipartite_preferential#
- graph_tool.generation.generate_bipartite_preferential(a_deg, p)[git][source]#
Generate a bipartite multigraph with the preferential attachment model of Guillaume and Latapy.
- Parameters:
- a_degiterable of
int Degrees of the vertices of the first part.
- p
float Probability of creating a new vertex of the second part.
- a_degiterable of
- Returns:
- g
Graph The generated undirected multigraph, where the vertices of the first part are \(0,\dots,N_a-1\), followed by those of the second part.
- g
See also
generate_bipartite_configurationRandom bipartite configuration model
price_networkPreferential attachment
graph_projectionProjection of a bipartite graph
Notes
In the model of Guillaume and Latapy [guillaume-bipartite-2006], the stubs of the vertices of the first part are processed in order, and each is connected, with probability \(p\) (or if the second part is empty), to a new vertex of the second part, and otherwise to an existing one chosen with probability proportional to its degree. The degrees of the second part follow a power law with exponent \(1 + 1/(1-p)\). The algorithm runs in time \(O(N + E)\).
References
[guillaume-bipartite-2006]Jean-Loup Guillaume and Matthieu Latapy, “Bipartite graphs as models of complex networks”, Physica A 371, 795-813 (2006), DOI: 10.1016/j.physa.2006.04.047 [sci-hub, @tor]
Examples
>>> g = gt.generate_bipartite_preferential([3] * 1000, 0.5) >>> print(g.num_vertices(), g.num_edges()) 2534 3000
A smaller instance is drawn as follows, with the two parts in different colors:
>>> g = gt.generate_bipartite_preferential([2] * 50, 0.5) >>> b = g.new_vp("int", vals=np.arange(g.num_vertices()) >= 50) >>> cmap = matplotlib.colors.ListedColormap( ... ["#9bbedc", "#f28c8e"]) >>> gt.graph_draw(g, pos=gt.sfdp_layout(g), vertex_fill_color=b, vcmap=cmap, ... output="generate_bipartite_preferential-small.pdf") <...>
Bipartite preferential attachment graph with 50 vertices of degree 2 in the first part (blue) and \(p=0.5\), with the second part in red.#