org.llm4s.knowledgegraph.storage

Members list

Type members

Classlikes

sealed trait Direction

Represents the direction of graph traversal.

Represents the direction of graph traversal.

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object Both
object Incoming
object Outgoing
object Direction

Attributes

Companion
trait
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
Direction.type
case class EdgeNodePair(edge: Edge, node: Node)

Represents a pair of an edge with its target node during traversal.

Represents a pair of an edge with its target node during traversal.

Value parameters

edge

The edge traversed

node

The target node

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
case class GraphFilter(nodeLabel: Option[String], relationshipType: Option[String], propertyKey: Option[String], propertyValue: Option[String])

Filter criteria for graph queries.

Filter criteria for graph queries.

Value parameters

nodeLabel

Optional filter by node label

propertyKey

Optional property name to filter by

propertyValue

Optional property value to filter by (compared as string)

relationshipType

Optional filter by relationship type

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
case class GraphStats(nodeCount: Long, edgeCount: Long, averageDegree: Double, densestNodeId: Option[String])

Statistics about a graph.

Statistics about a graph.

Value parameters

averageDegree

Average number of connections per node

densestNodeId

Node with the most connections (if any)

edgeCount

Total number of edges

nodeCount

Total number of nodes

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
trait GraphStore

Abstract interface for persisting and querying Knowledge Graphs.

Abstract interface for persisting and querying Knowledge Graphs.

All implementations must:

  • Return consistent results for the same operations
  • Use BFS-based traversal by default for consistent result ordering
  • Return Left(Error) consistently for missing nodes/edges
  • Support property filtering uniformly or document limitations
  • Be thread-safe or explicitly document thread-safety guarantees

This trait is designed to be engine-agnostic, allowing implementations for various graph databases (Neo4j, TinkerPop, SPARQL, etc.) while maintaining a consistent interface.

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
class InMemoryGraphStore(initialGraph: Graph) extends GraphStore

In-memory implementation of GraphStore using atomic references for thread-safe updates.

In-memory implementation of GraphStore using atomic references for thread-safe updates.

Thread-safety: This implementation is thread-safe via CAS (Compare-And-Swap) atomic operations. All mutations use linearizable atomic updates to ensure consistency under concurrent access.

Performance: Optimal for testing and small to medium graphs (<100k nodes). Not suitable for graphs requiring persistence.

Value parameters

initialGraph

Optional initial graph state (defaults to empty)

Attributes

Supertypes
trait GraphStore
class Object
trait Matchable
class Any
class JsonGraphStore(path: Path) extends GraphStore

JSON-based implementation of GraphStore.

JSON-based implementation of GraphStore.

Thread-safety note: This implementation is NOT thread-safe. For concurrent access, wrap with synchronization or use a thread-safe alternative.

Value parameters

path

The file path to save/load the graph

Attributes

Supertypes
trait GraphStore
class Object
trait Matchable
class Any
case class TraversalConfig(maxDepth: Int, direction: Direction, visitedNodeIds: Set[String])

Configuration for graph traversal operations.

Configuration for graph traversal operations.

Value parameters

direction

Direction of traversal (Outgoing, Incoming, Both). Controls whether traversal follows outgoing, incoming, or all edges from each node.

maxDepth

Maximum number of hops/edges to traverse from the start node (inclusive)

visitedNodeIds

Optional set of already-visited nodes to exclude

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all