Warning
This documents an unmaintained version of NetworkX. Please upgrade to a maintained version and see the current NetworkX documentation.
random_partition_graph¶
-
random_partition_graph
(sizes, p_in, p_out, seed=None, directed=False)[source]¶ Return 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.
Parameters: Returns: G – random partition graph of size sum(gs)
Return type: NetworkX Graph or DiGraph
Raises: NetworkXError
– If p_in or p_out is not in [0,1]Examples
>>> G = nx.random_partition_graph([10,10,10],.25,.01) >>> len(G) 30 >>> partition = G.graph['partition'] >>> len(partition) 3
Notes
This is a generalization of the planted-l-partition described in [1]. It allows for the creation of groups of any size.
The partition is store as a graph attribute ‘partition’.
References
[1] Santo Fortunato ‘Community Detection in Graphs’ Physical Reports Volume 486, Issue 3-5 p. 75-174. http://arxiv.org/abs/0906.0612 http://arxiv.org/abs/0906.0612