Skip to content

API Reference parrot.knowledge.graphindex.inter_community

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.knowledge.graphindex.inter_community

View source

Inter-community relations for GraphIndex (FEAT-401).

Models the meta-graph of relationships between the communities detected by :func:parrot.knowledge.graphindex.communities.detect_communities (Leiden or Louvain, FEAT-191/FEAT-401): which community pairs are connected, how tightly coupled they are (coupling ratio), and in which direction information flows between them (directed edge counts + weights).

The meta-graph is computed in-memory from the assembled rustworkx.PyDiGraph + the CommunitiesResult partition — it is not persisted separately; callers render it into reports/exports (FEAT-401 Modules 3-4) or query it on demand via the CLI (Module 5).

Alias CommunitiesResult

Re-exported from parrot.knowledge.graphindex.communities.CommunitiesResult.

Class InterCommunityGraph

Meta-graph of community-to-community relationships.

Fields:

Field Type Default Description
relations list[InterCommunityRelation]
community_count int
connected_pairs int
total_possible_pairs int
density float

Class InterCommunityRelation

A directed relationship between two communities.

source_community_id / target_community_id are the pair in deterministic (lexicographically sorted) order; the directed counts and weights distinguish traffic in each direction between them.

Fields:

Field Type Default Description
source_community_id str
target_community_id str
source_label str
target_label str
directed_edge_count int
reverse_edge_count int
total_weight float
reverse_weight float
coupling_ratio float

Function compute_inter_community_graph

Compute the inter-community meta-graph for a partition.

Iterates every edge in graph; edges whose endpoints fall in different communities are accumulated per (source_community, target_community) pair — directed counts and weights are kept separate per direction so callers can see asymmetric information flow. Edges whose endpoints share a community are internal and only contribute to that community's incident-edge total (used for the coupling ratio denominator).

compute_inter_community_graph(graph: rustworkx.PyDiGraph, communities_result: CommunitiesResult) -> InterCommunityGraph

Parameter Type Default Description
graph rustworkx.PyDiGraph The assembled PyDiGraph the partition was computed over.
communities_result CommunitiesResult A :class:CommunitiesResult from :func:parrot.knowledge.graphindex.communities.detect_communities (Leiden or Louvain — the algorithm that produced it is irrelevant here, only the partition matters).

Returns: InterCommunityGraph — class:InterCommunityGraph with one relation per connected community pair, plus summary density statistics.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally