Skip to navigation

Communities

How to create and update communities

In Graphiti, communities (represented as CommunityNode objects) represent groups of related entity nodes. Communities can be generated using the build_communities method on the graphiti class.

await graphiti.build_communities()

Communities are determined using a label-propagation algorithm, which groups strongly connected nodes together. Communities contain a summary field that collates the summaries held on each of its member entities. This allows Graphiti to provide high-level synthesized information about what the graph contains in addition to the more granular facts stored on edges.

After you build communities, set update_communities=True when you call add_episode to assign new entity nodes to existing communities. Rebuild the communities periodically to recalculate all groups. The build_communities method removes the existing communities before it creates new communities.