networkx 2.8.2 Pypi GitHub Homepage
Other Docs
NotesParametersRaisesReturnsBackRef
random_partition_graph(sizes, p_in, p_out, seed=None, directed=False)

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.

Notes

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'.

Parameters

sizes : list of ints

Sizes of groups

p_in : float

probability of edges with in groups

p_out : float

probability of edges between groups

directed : boolean optional, default=False

Whether to create a directed graph

seed : integer, random_state, or None (default)

Indicator of random number generation state. See Randomness<randomness> .

Raises

NetworkXError

If p_in or p_out is not in [0,1]

Returns

G : NetworkX Graph or DiGraph

random partition graph of size sum(gs)

Returns the random partition graph with a partition of sizes.

Examples

>>> G = nx.random_partition_graph([10, 10, 10], 0.25, 0.01)
... len(G) 30
>>> partition = G.graph["partition"]
... len(partition) 3
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

networkx.generators.community.stochastic_block_model networkx.generators.community.random_partition_graph networkx.generators.community.gaussian_random_partition_graph

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


GitHub : /networkx/generators/community.py#172
type: <class 'function'>
Commit: