networkx.generators.community.relaxed_caveman_graph

relaxed_caveman_graph(l, k, p, seed=None)[source]

Returns a relaxed caveman graph.

A relaxed caveman graph starts with l cliques of size k. Edges are then randomly rewired with probability p to link different cliques.

Parameters
lint

Number of groups

kint

Size of cliques

pfloat

Probabilty of rewiring each edge.

seedinteger, random_state, or None (default)

Indicator of random number generation state. See Randomness.

Returns
GNetworkX Graph

Relaxed Caveman Graph

Raises
NetworkXError

If p is not in [0,1]

References

1

Santo Fortunato, Community Detection in Graphs, Physics Reports Volume 486, Issues 3-5, February 2010, Pages 75-174. https://arxiv.org/abs/0906.0612

Examples

>>> G = nx.relaxed_caveman_graph(2, 3, 0.1, seed=42)