Package io.github.cfraser.graphit

Types

Link copied to clipboard
class AcyclicException(edge: Edge<*>) : GraphException

AcyclicException is thrown when a path between the vertices would violate the acyclic constraint in the graph.

Link copied to clipboard
data class BasicEdge<V : Any>(val source: V, val target: V) : Edge<V>

BasicEdge is an Edge implementation that only stores the source and target vertices.

Link copied to clipboard
class BreadthFirst<V : Any>(vertex: V) : TraversalStrategy<V>

BreadthFirst represents a breadth-first search of the Graph, beginning at the vertex.

Link copied to clipboard
class DepthFirst<V : Any>(vertex: V) : TraversalStrategy<V>

DepthFirst represents a depth-first search of the Graph, beginning at the vertex.

Link copied to clipboard
interface Edge<V : Any>

An Edge connects source and target vertices in a Graph.

Link copied to clipboard
class EdgeAlreadyExists(edge: Edge<*>) : GraphException

EdgeAlreadyExists is thrown when an edge between the vertices already exists in the graph.

Link copied to clipboard
interface EdgeDsl<V : Any>

EdgeDsl empowers the fluent construction of Edge types.

Link copied to clipboard
class EdgeNotFound(source: Any, target: Any) : GraphException

EdgeNotFound is thrown when an edge between the vertices is not found in the graph.

Link copied to clipboard
enum Feature : Enum<Feature>

Feature describes the qualities supported and enforced by a Graph. A Graph may have any combination of feature(s) or none.

Link copied to clipboard
interface Generic<T : Any>

Generic specifies that the edges in a Graph contain arbitrary attributes.

Link copied to clipboard
data class GenericEdge<V : Any, T : Any>(    val source: V,     val target: V,     val attributes: T) : Edge<V> , Generic<T>

GenericEdge is an Edge implementation which enables the storage of arbitrary attributes, in addition to the source and target vertices.

Link copied to clipboard
interface Graph<V : Any, E : Edge<V>>

Graph is a generic immutable graph data structure consisting of vertices and edges.

Link copied to clipboard
interface GraphBuilder<V : Any, E : Edge<V>> : EdgeDsl<V>

GraphBuilder enables the addition of vertices and edges to a Graph.

Link copied to clipboard
sealed class GraphException : RuntimeException

GraphException is the base RuntimeException type representing erroneous Graph operations.

Link copied to clipboard
object LoopException : GraphException

LoopException is thrown when an edge connects a vertex to itself.

Link copied to clipboard
class NoPathExists(source: Any, target: Any) : GraphException

NoPathExists is thrown when no path between the vertices exists in the graph.

Link copied to clipboard
sealed class TraversalStrategy<V : Any>

TraversalStrategy determines the order in which the vertices in a Graph are traversed.

Link copied to clipboard
object UndirectedException : GraphException

UndirectedException is thrown when an undirected graph attempts to find strongly connected components.

Link copied to clipboard
class VertexNotFound(vertex: Any) : GraphException

VertexNotFound is thrown when an expected vertex is not found in the graph.

Link copied to clipboard
typealias Vertices<V> = Pair<V, V>

Vertices is a vertex Pair which may, or may not, be connected by an Edge.

In a directed Graph, the order of the Vertices is consequential. Specifically, the Pair.first corresponds to the Edge.source, while Pair.second corresponds to the Edge.target.

Link copied to clipboard
interface Weighted

Weighted specifies that the edges in a Graph are weighted.

Link copied to clipboard
data class WeightedEdge<V : Any>(    val source: V,     val target: V,     val weight: Int) : Edge<V> , Weighted

WeightedEdge is an Edge implementation that captures a weight for the source to target connection.

Link copied to clipboard
data class WeightedGenericEdge<V : Any, T : Any>(    val source: V,     val target: V,     val weight: Int,     val attributes: T) : Edge<V> , Weighted, Generic<T>

WeightedGenericEdge is an Edge implementation that is a combination of WeightedEdge and GenericEdge.

Functions

Link copied to clipboard
fun <V : Any, E : Edge<V>> buildGraph(vararg features: Feature = arrayOf(), builder: GraphBuilder<V, E>.() -> Unit): Graph<V, E>

Build a Graph instance.

Properties

Link copied to clipboard
val Graph<*, *>.isAcyclic: Boolean

isAcyclic returns true if Feature.ACYCLIC is in the Graph.features.

Link copied to clipboard
val Graph<*, *>.isDirected: Boolean

isDirected returns true if Feature.DIRECTED is in the Graph.features.

Link copied to clipboard
val Graph<*, *>.isUndirected: Boolean

isUndirected returns true if Feature.DIRECTED is not in the Graph.features.