Skip to content

Community Detection

Find clusters and communities within graphs.

Louvain Algorithm

Fast modularity-based community detection.

import grafeo

db = grafeo.GrafeoDB()
algs = db.algorithms()

communities = algs.louvain()
for community_id, members in communities.items():
    print(f"Community {community_id}: {len(members)} members")

Label Propagation

Semi-supervised community detection.

algs = db.algorithms()
communities = algs.label_propagation()

Connected Components

Find disconnected subgraphs.

algs = db.algorithms()
components = algs.connected_components()

print(f"Found {len(components)} components")
for i, comp in enumerate(components):
    print(f"Component {i}: {len(comp)} nodes")

Strongly Connected Components

For directed graphs.

algs = db.algorithms()
sccs = algs.strongly_connected_components()

Weakly Connected Components

For directed graphs, ignoring edge direction.

algs = db.algorithms()
wccs = algs.weakly_connected_components()

Triangle Count

Count triangles for clustering analysis.

algs = db.algorithms()
triangles = algs.triangles()
print(f"Total triangles: {triangles}")

Use Cases

Algorithm Best For
Louvain Large graphs, quality clusters
Label Propagation Fast, scalable
Connected Components Graph structure analysis
Triangle Count Clustering coefficient