Represents a Knowledge Graph containing nodes and edges.
Value parameters
- edges
-
List of Edges in the graph
- nodes
-
Map of Node ID to Node object
Attributes
- Example
-
val alice = Node("alice", "Person", Map("name" -> ujson.Str("Alice"))) val acme = Node("acme", "Organization", Map("name" -> ujson.Str("Acme Corp"))) val edge = Edge("alice", "acme", "WORKS_FOR") val graph = Graph.empty .addNode(alice) .addNode(acme) .addEdge(edge) graph.getNeighbors("alice") // Set(acme) graph.findNodesByLabel("Person") // List(alice) - Companion
- object
- Source
- KnowledgeGraph.scala
- Graph
-
- Supertypes
Members list
Value members
Concrete methods
Adds an edge to the graph.
Adds an edge to the graph.
Value parameters
- edge
-
The edge to add
Attributes
- Returns
-
A new graph with the edge appended
- Source
- KnowledgeGraph.scala
Adds a node to the graph. If a node with the same ID exists, it is replaced.
Adds a node to the graph. If a node with the same ID exists, it is replaced.
Value parameters
- node
-
The node to add
Attributes
- Returns
-
A new graph with the node added
- Source
- KnowledgeGraph.scala
Finds nodes by label.
Finds nodes by label.
Value parameters
- label
-
The label to match (e.g., "Person")
Attributes
- Returns
-
All nodes with the given label
- Source
- KnowledgeGraph.scala
Finds nodes by property value. Compares against the JSON string representation of the value.
Finds nodes by property value. Compares against the JSON string representation of the value.
Attributes
- Source
- KnowledgeGraph.scala
Gets all edges connected to a node (both incoming and outgoing).
Gets all edges connected to a node (both incoming and outgoing).
Value parameters
- nodeId
-
The ID of the node
Attributes
- Returns
-
All edges where the node is either source or target
- Source
- KnowledgeGraph.scala
Gets incoming edges to a node.
Gets incoming edges to a node.
Value parameters
- nodeId
-
The ID of the target node
Attributes
- Returns
-
All edges pointing to the specified node
- Source
- KnowledgeGraph.scala
Gets neighbor nodes (both incoming and outgoing).
Gets neighbor nodes (both incoming and outgoing).
Value parameters
- nodeId
-
The ID of the node
Attributes
- Returns
-
All nodes directly connected to the specified node
- Source
- KnowledgeGraph.scala
Gets outgoing edges from a node.
Gets outgoing edges from a node.
Value parameters
- nodeId
-
The ID of the source node
Attributes
- Returns
-
All edges originating from the specified node
- Source
- KnowledgeGraph.scala
Checks if an edge exists between two nodes.
Checks if an edge exists between two nodes.
Value parameters
- relationship
-
Optional relationship type filter
- source
-
The source node ID
- target
-
The target node ID
Attributes
- Returns
-
True if a matching edge exists
- Source
- KnowledgeGraph.scala
Checks if a node exists in the graph.
Checks if a node exists in the graph.
Value parameters
- nodeId
-
The ID of the node to check
Attributes
- Returns
-
True if a node with the given ID exists
- Source
- KnowledgeGraph.scala
Merges another graph into this one. Nodes are merged by ID; duplicate edges are removed.
Merges another graph into this one. Nodes are merged by ID; duplicate edges are removed.
Value parameters
- other
-
The graph to merge in
Attributes
- Returns
-
A new graph containing nodes and edges from both graphs
- Source
- KnowledgeGraph.scala
Validates graph integrity - ensures all edge endpoints exist in node set.
Validates graph integrity - ensures all edge endpoints exist in node set.
Attributes
- Returns
-
Right(()) if valid, Left(error) if invalid
- Source
- KnowledgeGraph.scala
