CommunitySummarizer<T>

Models & Types · AiDotNet.RetrievalAugmentedGeneration.Graph.Communities

Generates structured summaries for detected communities in a knowledge graph.

For Beginners

After finding communities, this class describes what each one is about. For example, a community containing “Einstein”, “Bohr”, “Planck” connected by “collaborated_with” and “influenced” relations might be summarized as: “Physics pioneers community: 3 entities centered around Einstein, with key relations: collaborated_with, influenced”

How It Works

For each community, the summarizer collects member entities, identifies central entities by degree centrality, finds dominant relation types, and generates a structured description.

When an IGenerator LLM text generator is injected, the community Description is instead produced by prompting the model to write a natural-language report summarizing the community’s entities and relations (Microsoft GraphRAG “community reports”). If no generator is injected, or if the model returns an empty response, the extractive template description is used as a documented fallback.

Constructors

Constructor Summary
CommunitySummarizer() Initializes a new instance of the CommunitySummarizer class using only the extractive (offline, no-LLM) description template.
CommunitySummarizer(IGenerator<T> generator) Initializes a new instance of the CommunitySummarizer class with an optional LLM text generator.

Methods

Method Summary
List<CommunitySummary> Summarize(KnowledgeGraph<T> graph, LeidenResult leidenResult, int maxKeyEntities, int maxKeyRelations) Generates summaries for all communities in a Leiden result.
List<CommunitySummary> SummarizePartition(KnowledgeGraph<T> graph, Dictionary<string, int> partition, int level, int maxKeyEntities, int maxKeyRelations) Generates summaries for a specific partition (community assignment) at a given hierarchy level.