Algorithm
Label propagation
activeNeeds verification
Near-linear community detection where each node repeatedly adopts the label most common among its neighbours until labels stabilise.
Intuition
Start with every node in its own group; nodes copy the majority label of their neighbours, so dense groups converge on one label.
Pseudocode
label[v] = v for all v
repeat until no label changes:
for v in random order:
label[v] = most frequent label among neighbours(v)
Complexity
| Time | O(E) per iteration |
|---|---|
| Space | O(V) |
Python
import networkx as nx
comms = nx.community.label_propagation_communities(G)Cypher (Neo4j GDS)
CALL gds.labelPropagation.stream('myGraph')
YIELD nodeId, communityId RETURN communityId, count(*) AS sizeProcedure names and options vary between GDS versions; check the GDS docs for your version.
An interactive step-by-step visualizer for this algorithm is planned for phase 3.
Profile
| Time complexity | O(E) per iteration |
|---|---|
| Space complexity | O(V) |
Relationships
- Belongs to
- Prerequisites
- Community structure and modularity(Concept)
- Implemented by
- GraphFrames(Library / framework)
- NetworkX(Library / framework)