aryagraph.algorithms.community.label_propagation_communities#

aryagraph.algorithms.community.label_propagation_communities(g: Any, seed: Any = None, weight: str | Callable[[Hashable, Hashable, dict], float] | None = None, max_iter: int | None = None) → list[set][source]#

Asynchronous label propagation (Raghavan, Albert & Kumara 2007).

Every node starts with its own label; in each sweep (random order from seed) a node adopts the label carrying the largest (weighted) share of its neighbours, keeping its current label when that is among the best and otherwise picking one of the best at random. The run ends when no node changes (or after max_iter sweeps). Directed graphs are read as undirected; networkx follows successors only, which can oscillate. Linear time per sweep.