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
- Graph
-
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
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
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
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
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
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
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
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
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
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
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
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
Inherited methods
Attributes
- Inherited from:
- Product
Attributes
- Inherited from:
- Product