agrag.ingestion.community.detect_communities
detect_communities(graph_store:GraphStore, *, vector_store:VectorStore | None, embedder:Embedder, settings:RetrievalSettings, tracer:Tracer | None = None, apply:bool = False, max_cluster_size:int = 10, resolution:float = 1.0, seed:int | None = 3735928559) -> CommunityDetectionReport
Detect entity communities via hierarchical Leiden.
Reads every live domain relation across the whole graph, not only one
entity label, because community structure spans entity types. It builds a
weighted edge list and runs hierarchical Leiden off the event loop. With
apply=True the run is a full recompute: it deletes every earlier
Community node, MEMBER_OF edge and community vector before it stores the
new ones.
Parameters:
- graph_store (
GraphStore) – Where relations and entities are read and communities are written. - vector_store (
VectorStore | None) – Holds the community vectors. None skips vector writes. - embedder (
Embedder) – Embeds the community summaries. - settings (
RetrievalSettings) – Names the community vector collection. - tracer (
Tracer | None) – Opens the detection span. None opens no recorded span. - apply (
bool) – Write the communities. False returns a report only. - max_cluster_size (
int) – Forwarded tocompute_communities. - resolution (
float) – Forwarded tocompute_communities. - seed (
int | None) – Forwarded tocompute_communities.
Returns:
CommunityDetectionReport– A report of every community found, applied or not. A vector store orCommunityDetectionReport– community report failure appears infailures.
Raises:
CommunityDetectionMissingExtraError– graspologic-native is not installed.