generate_bipartite_configuration#
- graph_tool.generation.generate_bipartite_configuration(a_deg, b_deg)[git][source]#
Generate a random bipartite multigraph with given degrees, with the configuration model.
- Parameters:
- a_degiterable of
int Degrees of the vertices of the first part.
- b_degiterable of
int Degrees of the vertices 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
realize_bipartite_degree_sequenceDeterministic bipartite realization
random_rewireRandom rewiring preserving the degrees
Notes
The stubs of both parts are matched uniformly at random [newman-random-2001], as in the configuration model, which may form parallel edges. The algorithm runs in time \(O(N + E)\).
References
[newman-random-2001]M. E. J. Newman, S. H. Strogatz and D. J. Watts, “Random graphs with arbitrary degree distributions and their applications”, Physical Review E 64, 026118 (2001), DOI: 10.1103/PhysRevE.64.026118 [sci-hub, @tor], arXiv: cond-mat/0007235
Examples
>>> g = gt.generate_bipartite_configuration([2, 2, 2], [3, 3]) >>> print(g.get_out_degrees(g.get_vertices())) [2 2 2 3 3]
A larger instance is drawn as follows, with the two parts in different colors:
>>> g = gt.generate_bipartite_configuration([2] * 30, [3] * 20) >>> b = g.new_vp("int", vals=[0] * 30 + [1] * 20) >>> cmap = matplotlib.colors.ListedColormap( ... ["#9bbedc", "#f28c8e"]) >>> gt.graph_draw(g, pos=gt.sfdp_layout(g), vertex_fill_color=b, vcmap=cmap, ... output="generate_bipartite_configuration-large.pdf") <...>
Bipartite configuration model with 30 vertices of degree 2 (blue) and 20 vertices of degree 3 (red).#