- random_partition_graph(sizes, p_in, p_out, seed=None, directed=False)#
Returns the random partition graph with a partition of sizes.
A partition graph is a graph of communities with sizes defined by s in sizes. Nodes in the same group are connected with probability p_in and nodes of different groups are connected with probability p_out.
- sizeslist of ints
Sizes of groups
probability of edges with in groups
probability of edges between groups
- directedboolean optional, default=False
Whether to create a directed graph
- seedinteger, random_state, or None (default)
Indicator of random number generation state. See Randomness.
- GNetworkX Graph or DiGraph
random partition graph of size sum(gs)
If p_in or p_out is not in [0,1]
This is a generalization of the planted-l-partition described in . It allows for the creation of groups of any size.
The partition is store as a graph attribute ‘partition’.
>>> G = nx.random_partition_graph([10, 10, 10], 0.25, 0.01) >>> len(G) 30 >>> partition = G.graph["partition"] >>> len(partition) 3