A library for creating generic graph data structures and modifying, analyzing, and visualizing them.
This release contains breaking changes to the public API (see "Changed").
Store
interface, introducing support for custom storage implementations.NewWithStore
function for explicitly initializing a graph with a Store
instance.EdgeData
functional option that can be used with AddEdge
, introducing support for arbitrary data.Data
field to EdgeProperties
for retrieving data added using EdgeData
.Order
to additionally return an error instance (breaking change).Size
to additionally return an error instance (breaking change).ErrVertexAlreadyExists
error instance. Use errors.Is
to check for this instance.ErrEdgeAlreadyExists
error instance. Use errors.Is
to check for this instance.ErrEdgeCreatesCycle
error instance. Use errors.Is
to check for this instance.AddVertex
to return ErrVertexAlreadyExists
if the vertex already exists.VertexWithProperties
to return ErrVertexNotFound
if the vertex doesn't exist.AddEdge
to return ErrVertexNotFound
if either vertex doesn't exist.AddEdge
to return ErrEdgeAlreadyExists
if the edge already exists.AddEdge
to return ErrEdgeCreatesCycle
if cycle prevention is active and the edge would create a cycle.Edge
to return ErrEdgeNotFound
if the edge doesn't exist.RemoveEdge
to return the error instances returned by Edge
.ErrVertexNotFound
error instance.TopologicalSort
to fail at runtime when a cycle is detected.TransitiveReduction
to return the transitive reduction as a new graph and fail at runtime when a cycle is detected.Vertex
to return ErrVertexNotFound
if the desired vertex couldn't be found.VertexProperties
type for storing vertex-related properties.VertexWithProperties
method for retrieving a vertex and its properties.VertexWeight
functional option that can be used for AddVertex
.VertexAttribute
functional option that can be used for AddVertex
.draw.DOT
.AddVertex
to accept functional options.PermitCycles
to PreventCycles
. This seems to be the price to pay if English isn't a library author's native language.ShortestPath
when the target vertex is not reachable from one of the visited vertices.PermitCycles
option to explicitly prevent the creation of cycles.Acyclic
option to not implicitly impose cycle checks for operations like AddEdge
. To prevent the creation of cycles, use PermitCycles
.TopologicalSort
to only work for graphs created with PermitCycles
. This is temporary.TransitiveReduction
to only work for graphs created with PermitCycles
. This is temporary.Order
method for retrieving the number of vertices in the graph.Size
method for retrieving the number of edges in the graph.graph
logo.ShortestPath
from O(n) to O(log(n)) by implementing the priority queue as a binary heap. Note that the actual complexity might still be defined by ShortestPath
itself.draw.DOT
to work correctly with vertices that contain special characters and whitespaces.PredecessorMap
method for obtaining a map with all predecessors of each vertex.RemoveEdge
method for removing the edge between two vertices.Clone
method for retrieving a deep copy of the graph.TopologicalSort
function for obtaining the topological order of the vertices in the graph.TransitiveReduction
function for transforming the graph into its transitive reduction.visit
function of DFS
to accept a vertex hash instead of the vertex value (i.e. K
instead of T
).visit
function of BFS
to accept a vertex hash instead of the vertex value (i.e. K
instead of T
).Predecessors
function. Use PredecessorMap
instead and look up the respective vertex.