Skip to content

Handle duplicate edges in graph construction #3

Description

@DhanushNehru

The current graph.rs doesn't deduplicate edges. If file A imports module B twice (e.g., in different scopes), two identical edges are created. This inflates degree counts and affects god node analysis.

What needs to change:

  • In KnowledgeGraph::from_extractions() in src/graph.rs, track existing edges using a HashSet<(String, String, EdgeKind)>
  • Before adding an edge, check if a (source_id, target_id, kind) triple already exists
  • If the edge exists, optionally increment its weight instead of adding a duplicate
  • Add a unit test that verifies duplicate edges are merged

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationenhancementNew feature or requesthelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions