5.16.1. networkx.generators.community.caveman_graph¶
-
networkx.generators.community.caveman_graph(l, k)[source]¶ Returns a caveman graph of l cliques of size k.
Parameters: l : int
Number of cliques
k : int
Size of cliques
Returns: G : NetworkX Graph
caveman graph
See also
Notes
This returns an undirected graph, it can be converted to a directed graph using
nx.to_directed(), or a multigraph usingnx.MultiGraph(nx.caveman_graph(l, k)). Only the undirected version is described in [R998] and it is unclear which of the directed generalizations is most useful.References
[R998] (1, 2) Watts, D. J. ‘Networks, Dynamics, and the Small-World Phenomenon.’ Amer. J. Soc. 105, 493-527, 1999. Examples
>>> G = nx.caveman_graph(3, 3)