Skip to main content
Version: 0.0.8 (stable)

agrag.ingestion.community.detect_communities

detect_communities(graph_store:GraphStore, *, schema:GraphSchema, embedder:Embedder, tracer:Tracer | None = None, apply:bool = False, vector_sync:VectorSync | None = None, max_cluster_size:int = 10, resolution:float = 1.0, seed:int | None = 3735928559) -> CommunityDetectionReport

Detect entity communities via hierarchical Leiden.

Reads relationships declared by the active schema between nodes carrying declared entity labels. Stored relationships outside the schema do not affect clustering. 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 and MEMBER_OF edge before it stores the new ones.

Parameters:

  • graph_store (GraphStore) – Where relations and entities are read and communities are written.
  • schema (GraphSchema) – The active entity and relation types for this graph.
  • embedder (Embedder) – Embeds the community summaries.
  • tracer (Tracer | None) – Opens the detection span. None opens no recorded span.
  • apply (bool) – Write the communities. False returns a report only.
  • vector_sync (VectorSync | None) – Mirrors community vectors outside the graph when set.
  • max_cluster_size (int) – Forwarded to compute_communities.
  • resolution (float) – Forwarded to compute_communities.
  • seed (int | None) – Forwarded to compute_communities.

Returns:

Raises: