case class SourceTrackedGraph(graph: Graph, sources: Seq[DocumentSource], nodeSources: Map[String, Set[String]], edgeSources: Map[(String, String, String), Set[String]])
A graph with source provenance tracking.
Wraps a standard Graph with metadata about which documents contributed each node and edge. The underlying Graph remains a pure data structure; provenance is tracked externally.
Value parameters
edgeSources
Mapping of (source, target, relationship) to the set of source document IDs
graph
The underlying knowledge graph
nodeSources
Mapping of node ID to the set of source document IDs that contributed it
sources
All document sources that contributed to this graph
Adds a document's extracted graph to this tracked graph, merging nodes/edges and recording provenance.
Adds a document's extracted graph to this tracked graph, merging nodes/edges and recording provenance.
Node IDs are namespaced with the document source ID before merging to prevent silent overwrites when two documents produce the same LLM-generated IDs. Entity linking (run afterwards by MultiDocumentGraphBuilder) is responsible for collapsing semantically equivalent nodes across documents.
Value parameters
docGraph
The graph extracted from the document
source
The document source metadata
Attributes
Returns
A new SourceTrackedGraph with the document incorporated
Replaces the underlying graph (e.g., after entity linking) while preserving source tracking. Node/edge source mappings are preserved as-is; callers performing node merges should update the mappings via withUpdatedNodeSources / withUpdatedEdgeSources.
Replaces the underlying graph (e.g., after entity linking) while preserving source tracking. Node/edge source mappings are preserved as-is; callers performing node merges should update the mappings via withUpdatedNodeSources / withUpdatedEdgeSources.