pub fn cluster_incremental(
graph: &KnowledgeGraph,
prev_communities: &HashMap<usize, Vec<String>>,
changed_files: &[String],
) -> HashMap<usize, Vec<String>>Expand description
Incrementally re-cluster only the communities affected by changed files.
Instead of re-running Leiden on the entire graph, this:
- Identifies nodes belonging to
changed_files - Finds which communities are affected (contain changed nodes or their neighbors)
- Re-runs Leiden only on the affected subgraph
- Merges with unchanged communities
Falls back to full cluster() if > 50% of communities are affected.