All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
Are you using graph? Check out the graph user survey
- Added the
AllPathsBetween
function for computing all paths between two vertices.
- Changed
StableTopologicalSort
to invoke theless
function as few as possible, reducing comparisons. - Changed
CreatesCycle
to use an optimized path if the default in-memory store is being used. - Changed map allocations to use pre-defined memory sizes.
- Fixed the major performance issues of
StableTopologicalSort
.
- Fixed
TopologicalSort
to retain its original performance.
- Added the
StableTopologicalSort
function for deterministic topological orderings. - Added the
VertexAttributes
functional option for setting an entire vertex attributes map.
- Added the
BFSWithDepth
function for performing a BFS with depth information.
- Fixed false positives of
ErrVertexHasEdges
when removing a vertex.
Release post: graph Version 0.20 Is Out
- Added the
Graph.AddVerticesFrom
method for adding all vertices from another graph. - Added the
Graph.AddEdgesFrom
method for adding all edges from another graph. - Added the
Graph.Edges
method for obtaining all edges as a slice. - Added the
Graph.UpdateEdge
method for updating the properties of an edge. - Added the
Store.UpdateEdge
method for updating the properties of an edge. - Added the
NewLike
function for creating a new graph that is "like" the given graph. - Added the
EdgeAttributes
functional option for setting an entire edge attributes map.
- Changed
Graph.Clone
to use the built-in in-memory store for storing vertices and edges for cloned graphs.
- Added the
MinimumSpanningTree
function for finding a minimum spanning tree. - Added the
MaximumSpanningTree
function for finding a maximum spanning tree.
- Added the
Graph.RemoveVertex
method for removing a vertex. - Added the
Store.RemoveVertex
method for removing a vertex. - Added the
ErrVertexHasEdges
error instance. - Added the
Union
function for combining two graphs into one.
- Added the
draw.GraphAttributes
functional option fordraw.DOT
for rendering graph attributes.
- Changed the library's GoDoc documentation.
- Fixed
ShortestPath
for an edge case.
- Fixed
TransitiveReduction
not to incorrectly report cycles.
This release contains breaking changes of the public API (see "Changed").
- Added the
Store
interface, introducing support for custom storage implementations. - Added the
NewWithStore
function for explicitly initializing a graph with aStore
instance. - Added the
EdgeData
functional option that can be used withAddEdge
, introducing support for arbitrary data. - Added the
Data
field toEdgeProperties
for retrieving data added usingEdgeData
.
- Changed
Order
to additionally return an error instance (breaking change). - Changed
Size
to additionally return an error instance (breaking change).
- Changed
ShortestPath
to returnErrTargetNotReachable
if the target vertex is not reachable.
- Fixed
ShortestPath
to return correct results for large unweighted graphs.
- Added the
ErrVertexAlreadyExists
error instance. Useerrors.Is
to check for this instance. - Added the
ErrEdgeAlreadyExists
error instance. Useerrors.Is
to check for this instance. - Added the
ErrEdgeCreatesCycle
error instance. Useerrors.Is
to check for this instance.
- Changed
AddVertex
to returnErrVertexAlreadyExists
if the vertex already exists. - Changed
VertexWithProperties
to returnErrVertexNotFound
if the vertex doesn't exist. - Changed
AddEdge
to returnErrVertexNotFound
if either vertex doesn't exist. - Changed
AddEdge
to returnErrEdgeAlreadyExists
if the edge already exists. - Changed
AddEdge
to returnErrEdgeCreatesCycle
if cycle prevention is active and the edge would create a cycle. - Changed
Edge
to returnErrEdgeNotFound
if the edge doesn't exist. - Changed
RemoveEdge
to return the error instances returned byEdge
.
- Added the
ErrVertexNotFound
error instance.
- Changed
TopologicalSort
to fail at runtime when a cycle is detected. - Changed
TransitiveReduction
to return the transitive reduction as a new graph and fail at runtime when a cycle is detected. - Changed
Vertex
to returnErrVertexNotFound
if the desired vertex couldn't be found.
- Added the
VertexProperties
type for storing vertex-related properties. - Added the
VertexWithProperties
method for retrieving a vertex and its properties. - Added the
VertexWeight
functional option that can be used forAddVertex
. - Added the
VertexAttribute
functional option that can be used forAddVertex
. - Added support for rendering vertices with attributes using
draw.DOT
.
- Changed
AddVertex
to accept functional options. - Renamed
PermitCycles
toPreventCycles
. This seems to be the price to pay if English isn't a library author's native language.
- Fixed the behavior of
ShortestPath
when the target vertex is not reachable from one of the visited vertices.
- Added the
PermitCycles
option to explicitly prevent the creation of cycles.
- Changed the
Acyclic
option to not implicitly impose cycle checks for operations likeAddEdge
. To prevent the creation of cycles, usePermitCycles
. - Changed
TopologicalSort
to only work for graphs created withPermitCycles
. This is temporary. - Changed
TransitiveReduction
to only work for graphs created withPermitCycles
. This is temporary.
- Added the
Order
method for retrieving the number of vertices in the graph. - Added the
Size
method for retrieving the number of edges in the graph.
- Changed the
graph
logo. - Changed an internal operation of
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 byShortestPath
itself.
- Fixed
draw.DOT
to work correctly with vertices that contain special characters and whitespaces.
- Added the
PredecessorMap
method for obtaining a map with all predecessors of each vertex. - Added the
RemoveEdge
method for removing the edge between two vertices. - Added the
Clone
method for retrieving a deep copy of the graph. - Added the
TopologicalSort
function for obtaining the topological order of the vertices in the graph. - Added the
TransitiveReduction
function for transforming the graph into its transitive reduction.
- Changed the
visit
function ofDFS
to accept a vertex hash instead of the vertex value (i.e.K
instead ofT
). - Changed the
visit
function ofBFS
to accept a vertex hash instead of the vertex value (i.e.K
instead ofT
).
- Removed the
Predecessors
function. UsePredecessorMap
instead and look up the respective vertex.
- Added the
Graph.AddVertex
method for adding a vertex. This replacesGraph.Vertex
. - Added the
Graph.AddEdge
method for creating an edge. This replacesGraph.Edge
. - Added the
Graph.Vertex
method for retrieving a vertex by its hash. This is not to be confused with the oldGraph.Vertex
function for adding vertices that got replaced withGraph.AddVertex
. - Added the
Graph.Edge
method for retrieving an edge. This is not to be confused with the oldGraph.Edge
function for creating an edge that got replaced withGraph.AddEdge
. - Added the
Graph.Predecessors
function for retrieving a vertex' predecessors. - Added the
DFS
function. - Added the
BFS
function. - Added the
CreatesCycle
function. - Added the
StronglyConnectedComponents
function. - Added the
ShortestPath
function. - Added the
ErrEdgeNotFound
error indicating that a desired edge could not be found.
- Removed the
Graph.EdgeByHashes
method. UseGraph.AddEdge
instead. - Removed the
Graph.GetEdgeByHashes
method. UseGraph.Edge
instead. - Removed the
Graph.DegreeByHash
method. UseGraph.Degree
instead. - Removed the
Graph.Degree
method. - Removed the
Graph.DFS
andGraph.DFSByHash
methods. UseDFS
instead. - Removed the
Graph.BFS
andGraph.BFSByHash
methods. UseBFS
instead. - Removed the
Graph.CreatesCycle
andGraph.CreatesCycleByHashes
methods. UseCreatesCycle
instead. - Removed the
Graph.StronglyConnectedComponents
method. UseStronglyConnectedComponents
instead. - Removed the
Graph.ShortestPath
andGraph.ShortestPathByHash
methods. UseShortestPath
instead.
- Added the
EdgeWeight
andEdgeAttribute
functional options. - Added the
Properties
field toEdge
.
- Changed
Edge
to accept a variadicoptions
parameter. - Changed
EdgeByHashes
to accept a variadicoptions
parameter. - Renamed
draw.Graph
todraw.DOT
for more clarity regarding the rendering format.
- Removed the
WeightedEdge
function. UseEdge
with theEdgeWeight
functional option instead. - Removed the
WeightedEdgeByHashes
function. UseEdgeByHashes
with theEdgeWeight
functional option instead.
- Fixed missing edge attributes when drawing a graph using
draw.DOT
.
- Added
draw
package for graph visualization using DOT-compatible renderers. - Added
Traits
function for retrieving the graph's traits.
- Added
AdjacencyMap
function for retrieving an adjancency map for all vertices.
- Removed the
AdjacencyList
function.
- Added
AdjacencyList
function for retrieving an adjacency list for all vertices.
- Updated the examples in the documentation.
- Added
ShortestPath
function for computing shortest paths.
- Changed the term "properties" to "traits" in the code and documentation.
- Don't traverse all vertices in disconnected graphs by design.
- Added
StronglyConnectedComponents
function for detecting SCCs. - Added various images to usage examples.
- Added
Degree
andDegreeByHash
functions for determining vertex degrees. - Added cycle checks when adding an edge using the
Edge
functions.
- Added
CreatesCycle
andCreatesCycleByHashes
functions for predicting cycles.
- Introduced dedicated types for directed and undirected graphs, making
Graph[K, T]
an interface.
- Introduced core types and methods.