GraphEngine

org.llm4s.knowledgegraph.engine.GraphEngine
class GraphEngine(graph: Graph)

Engine for traversing and querying the Knowledge Graph.

Value parameters

graph

The graph to traverse

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

def findAllPaths(startNodeId: String, endNodeId: String, maxLength: Int): List[List[Edge]]

Finds all paths between two nodes up to a maximum length.

Finds all paths between two nodes up to a maximum length.

Value parameters

endNodeId

The ID of the target node

maxLength

Maximum path length (number of edges)

startNodeId

The ID of the starting node

Attributes

Returns

List of all paths found

def findShortestPath(startNodeId: String, endNodeId: String): Option[List[Edge]]

Finds the shortest path between two nodes using BFS.

Finds the shortest path between two nodes using BFS.

Value parameters

endNodeId

The ID of the target node

startNodeId

The ID of the starting node

Attributes

Returns

Option containing the list of edges representing the path, or None if no path found

def getNodesAtDistance(startNodeId: String, distance: Int): Set[Node]

Gets all nodes within a certain distance.

Gets all nodes within a certain distance.

Value parameters

distance

Exact distance (number of hops)

startNodeId

The ID of the starting node

Attributes

Returns

Set of nodes at the specified distance

def traverse(startNodeId: String, maxDepth: Int, filter: (Node, Edge) => Boolean): Set[Node]

Traverses the graph starting from a given node using Breadth-First Search (BFS).

Traverses the graph starting from a given node using Breadth-First Search (BFS).

Value parameters

filter

A predicate to filter nodes and edges during traversal. Returns true if the traversal should continue through this edge to the target node.

maxDepth

The maximum depth of traversal

startNodeId

The ID of the starting node

Attributes

Returns

A Set of visited Nodes

def traverseDFS(startNodeId: String, maxDepth: Int, filter: (Node, Edge) => Boolean): Set[Node]

Traverses the graph using Depth-First Search (DFS).

Traverses the graph using Depth-First Search (DFS).

Value parameters

filter

A predicate to filter nodes and edges during traversal

maxDepth

The maximum depth of traversal

startNodeId

The ID of the starting node

Attributes

Returns

A Set of visited Nodes