Skip to content
pubscout

directed_graph

1.2.0, released 2 weeks ago by simphotonics.com

Generic directed and weighted directed graph data structures with algorithms for sorting and paths.

WASM-ready
$ flutter pub add directed_graph
Source repository

What it does

Provides generic directed, multi, weighted, and bidirected graph structures in Dart. Includes algorithms for topological ordering, shortest and lightest paths, cycles, strongly connected components, and graph crawling.

AI-written summary of version 1.2.0, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need to represent and analyze dependencies or relationships between elements.
  • You need to perform topological sorting, find shortest paths, or detect cycles.
  • You are working with network connections, file dependencies, or foreign keys.

Skip it when

  • You are building data visualizations or charts where a charting package like fl_chart or syncfusion_flutter_charts is more appropriate.
  • You only need simple linear lists or standard key-value maps.

Strengths

  • Supports multiple graph types including directed, weighted, multi, and bidirected graphs.
  • Rich set of built-in graph algorithms like topological ordering and path finding.
  • Generic implementation works with any non-nullable object type.

Weaknesses

  • Does not include built-in UI components or renderers for visualizing the graphs.
  • Mutating large graphs can be computationally intensive depending on the algorithm.

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
4
import 'package:directed_graph/directed_graph.dart';

void main() {
  final graph = DirectedGraph<String>({
    'a': {'b', 'c'},
    'b': {'c'},
  });
  print(graph.isAcyclic);
}

Alternatives

Packages that do the same job and could replace directed_graph.

  • graphs

    If you need a different set of graph algorithms or data structures provided by the community.

Works with

Packages commonly used together with directed_graph: ones it builds on, ones built on it, and its own family.