directed_graph
Generic directed graph and weighted directed graph with algorithms enabling sorting and topological ordering of vertices.
0.5.6
14K downloads/mo
#2553 most downloaded on pub.dev
simphotonics/directed_graph
What this package is like to depend on
Last release 2 months ago
27 May 2026
Ships fairly regularly
a new release about every 6 months
Nearly every release is documented
notes for 42 of 42 stable releases
Nothing withdrawn
no release was ever pulled
6 years old
42 releases · first in 2020
7 releases in the last 12 months
see the full history below
Release timeline
42 releases · Apr 2020 to May 2026Releases
latest 42-
0.5.627 May 2026Release notes
Open source →- Added the graph method
sort, to enable the sorting of vertices and edges. The vertices must be comparable or a suitable comparator must be provided.- By default, vertices are stored (and printed) in insertion order.
- Subsequent insertion of vertices and edges might invalidate the sorting.
- Added the graph method
-
0.5.526 Feb 2026Release notes
Open source →- Added [
DirectedGraph][DirectedGraph], [WeightedDirectedGraph][WeightedDirectedGraph] methodremoveEdge.
- Added [
-
0.5.425 Feb 2026Release notes
Open source →- Fixed the documentation of the graph method
clear. This method removes all graph vertices. The resulting graph will be empty. - Added the graph method
clearEdges. This method removes only the graph edges, leaving the graph vertices in place.
- Fixed the documentation of the graph method
-
0.5.325 Feb 2026Release notes
Open source →- Added
WeightedDirectedGraphmethods:weightedEdgesandupdateEdgeWeight. - Updated docs and examples.
- Added
-
0.5.222 Jan 2026Release notes
Open source →- Fixed grammar in CHANGELOG entry below.
- Moved [
GraphCrawler][GraphCrawler] to a separate folder. - Added function
defaultComparator<T>()which returns a function of typeComparator<T>. - When constructing a
graph with vertices of type
Tand no explicit comparator is provided, then the functiondefaultComparator<T>()is provided instead. - If a user explicitly sets the graph
comparatorto null, then vertices and edges will not be sorted. To restore the default see below:final graph = DirectedGraph<String>({a: {b}}); // Has default comparator. print(graph.hasComparator); // Prints true. graph.comparator = graph.inverseComparator; // Has explicitly set comparator. print(graph.hasComparator); // Prints true. graph.comparator = null; print(graph.hasComparator); // Prints false; graph.comparator = defaultComparator<String>(); // Restoring the default comp. - The graph method
contains, now explicitly uses the keys of the underlying map to calculate its result.
-
0.5.120 Jan 2026Release notes
Open source →- The graph
lengthis now calculated using an efficient length iterable (the keys of the map storing the graph edges). The functionreachableVerticeswas moved fromDirectedGraphBaseto [GraphCrawler][GraphCrawler]. It is now using a more efficient recursive algorithm. - Extended the definition of a quasi-topological ordering in section
Usage. - Lowered the required SDK version to ^3.5.0.
- The graph
-
0.5.012 Oct 2025Release notes
Open source →-
Breaking changes: The following getters have been converted to functions, to reflect the fact that a potentially long computation is be needed to calculate the result:
stronglyConnectedComponents({bool sorted, Comparator <T> comparator})and the function return type has been changed toList<Set>to show the fact that each scc is a set of vertices and to make searching a component for a specify vertex more efficient,topologicalOrdering({bool sorted}),cycle(),localSource().
-
The getters
cycleVertexandisAcyclicwere kept, but are now cached and only updated if vertices or edges are added/removed. -
The getter
sortedTopologicalOrderingwas removed. To get the equivalent result calltopologicalOrdering(sorted:true). -
New additions:
addEdge({vertex, connectedVertex})was added toDirectedGraphandBiDirectedGraphto make it consistent withWeightedDirectedGraph,reverseTopologicalOrdering({bool sorted}), for the meaning of quasi-topological ordering see Section Terminology of README.md.quasiTopologicalOrdering({bool sorted}),reverseQuasiTopologicalOrdering({bool sorted}).
-
Fixed a bug related to the addition of a default comparator if the generic type
TofDirectedGraph<T>isComparable<T>. -
Updated dependencies.
-
-
0.4.524 Apr 2025 -
0.4.431 Oct 2024Release notes
Open source →- Fixed bug where cache was updated after calling the method
addEdgeon an instance of typeWeightedDirectedGraph. - Updated dependencies.
- Updated benchmark_runner version and benchmark report.
- Fixed bug where cache was updated after calling the method
-
0.4.304 Apr 2024 -
0.4.204 Apr 2024 -
0.4.103 Apr 2024 -
0.4.018 Sep 2023Release notes
Open source →- Updated dependencies.
- Library now uses latest version of [
lazy_memo][lazy_memo]. - Removed dependency on [
graphs][graphs]. - Benchmarks now using [
benchmark_runner][benchmark_runner].
-
0.3.901 Apr 2023Release notes
Open source →- Updated dependencies.
- Amended extensions in
sort.dart. - Sorting is now possible without specifying a
Comparatoras long as the the vertex typeTimplementsComparable. - Added tests.
-
0.3.821 Feb 2023 -
0.3.702 Mar 2022 -
0.3.616 Nov 2021 -
0.3.526 Mar 2021 -
0.3.419 Mar 2021Release notes
Open source →- Eliminated cyclic dependency between class [
WeightedDirectedGraph][WeightedDirectedGraph] and extensionGraphUtils. - Added getter
crawler. - Added the method
clear()to classes [DirectedGraph][DirectedGraph] and [WeightedDirectedGraph][WeightedDirectedGraph].
- Eliminated cyclic dependency between class [
-
0.3.319 Mar 2021Release notes
Open source →- Added weighted graph getter
transitiveWeightedEdgesand methodaddEdge().
- Added weighted graph getter
-
0.3.218 Mar 2021 -
0.3.118 Mar 2021 -
0.3.018 Mar 2021Release notes
Open source →- Added null-safety features.
- Tightened the definition of path. A path [v<sub>i</sub>, ..., v<sub>n</sub>] is an ordered list of at least two connected vertices where each inner vertex is distinct.
- Functions returning a topological ordering now return an ordered set of vertices, reflecting the fact that in a topological ordering each vertex must be distinct.
- Added the classes [
WeightedDirectedGraph][WeightedDirectedGraph] andBiDirectedGraph. - Complete overhaul of the class
GraphCrawler.
-
0.2.307 Sep 2020Release notes
Open source →Added [
GraphCrawler][GraphCrawler] methodtree. Amended methodspathandpaths. -
0.2.222 Aug 2020 -
0.2.122 Aug 2020 -
0.2.017 Aug 2020 -
0.1.917 Aug 2020Release notes
Open source →- Moved [
GraphCrawler][GraphCrawler] to a separate file. - Amended graph crawler method
paths. - Added [
DirectedGraph][DirectedGraph] constructor.fromData.
- Moved [
-
0.1.829 Jul 2020 -
0.1.721 Jul 2020 -
0.1.608 Jul 2020 -
0.1.508 Jul 2020 -
0.1.406 Jun 2020Release notes
Open source →Added class [
GraphCrawler][GraphCrawler].Converted the following [
DirectedGraph][DirectedGraph] methods to getters:isAcyclic,localSources,outDegreeMap,sortedTopologicalOrdering,stronglyConnectedComponents,topologicalOrdering.
Added methods for finding cycles in cyclic graphs:
cyclefindCycle()
-
0.1.306 May 2020Release notes
Open source →Specified type of the parameter
comparatorin [DirectedGraph][DirectedGraph] constructor. -
0.1.208 Apr 2020 -
0.1.106 Apr 2020 -
0.1.006 Apr 2020Release notes
Open source →Fixed logic in
removeEdges(). The field comparator is no longer final, it can be set to trigger a resort of the graph vertices. -
0.0.506 Apr 2020 -
0.0.406 Apr 2020 -
0.0.301 Apr 2020 -
0.0.201 Apr 2020 -
0.0.101 Apr 2020