PersistentDirectedGraph

data class PersistentDirectedGraph<T>(val vertices: PersistentSet<T> = persistentSetOf(), adjacency: PersistentMap<T, PersistentSet<T>> = persistentMapOf()) : Graph<T>

An immutable directed graph using persistent data structures. Updates return new instances that share structure with the original, providing O(log n) time complexity per operation.

Parameters

T

the type of vertices in the graph

vertices

the set of vertices in the graph

adjacency

a map from each vertex to its set of neighbors (outgoing edges)

Constructors

Link copied to clipboard
constructor(vertices: PersistentSet<T> = persistentSetOf(), adjacency: PersistentMap<T, PersistentSet<T>> = persistentMapOf())

Properties

Link copied to clipboard
open override val edges: Set<Pair<T, T>>

The set of edges in the graph, represented as pairs of vertices.

Link copied to clipboard
open override val vertices: PersistentSet<T>
Link copied to clipboard

Converts a Graph into a VisitableOnceGraph which allows visiting each vertex only once.

Functions

Link copied to clipboard
open fun addEdge(pair: Pair<T, T>): Graph<T>

open override fun addEdge(from: T, to: T): PersistentDirectedGraph<T>

Adds an edge from one vertex to another.

Link copied to clipboard
open override fun addVertex(value: T): PersistentDirectedGraph<T>

Adds a vertex to the graph.

Link copied to clipboard
open override fun addVertexAndEdge(vertex: T, edgeFrom: T, edgeTo: T): PersistentDirectedGraph<T>

Adds a vertex and an edge in a single operation.

Link copied to clipboard

Finds a Subdocument.Resource vertex in the graph by its absolute path.

Link copied to clipboard
open override fun getNeighbors(vertex: T): Sequence<T>