aryagraph.generators.random.powerlaw_cluster#

aryagraph.generators.random.powerlaw_cluster(n: int, m: int, p: float, *, seed: int | Generator | None = None) → Graph[source]#

Holme–Kim model: preferential attachment plus triad formation.

Like barabasi_albert(), but after each preferential link the new node closes a triangle with probability p (links to a random neighbor of the node it just attached to). Starts from m isolated nodes, as networkx does. Each new node gets exactly m edges, so there are m·(n - m) edges (networkx occasionally adds fewer, when a triangle step picks a node it later draws again). Requires 1 <= m < n and 0 <= p <= 1.