302 releases (103 breaking)

0.104.0 Oct 8, 2024
0.102.1 Oct 6, 2024
0.75.4 Jul 30, 2024
0.2.3 Mar 31, 2024

#140 in Algorithms

Download history 1627/week @ 2024-06-28 1258/week @ 2024-07-05 1440/week @ 2024-07-12 1579/week @ 2024-07-19 1131/week @ 2024-07-26 468/week @ 2024-08-02 558/week @ 2024-08-09 704/week @ 2024-08-16 939/week @ 2024-08-23 1171/week @ 2024-08-30 1097/week @ 2024-09-06 1700/week @ 2024-09-13 1355/week @ 2024-09-20 1026/week @ 2024-09-27 1530/week @ 2024-10-04 215/week @ 2024-10-11

4,269 downloads per month

MIT/Apache

1MB
16K SLoC

Graaf   Crates.io Build status API reference Coverage Status

Rust-powered directed graphs.

Table of Contents

Installation

Add this to your Cargo.toml:

[dependencies]
graaf = "0.104.0"

Representations

Arc-Weighted Sparse Digraphs

Unweighted Dense Digraphs

Unweighted Sparse Digraphs

Generators

  • Biclique generates a complete bipartite digraph.
  • Circuit generates a circuit digraph.
  • Complete generates a complete digraph.
  • Cycle generates a bidirectional circuit.
  • Empty generates a digraph without arcs.
  • ErdosRenyi generates a random digraph.
  • GrowingNetwork generates a growing network digraph.
  • Path generates a path digraph.
  • RandomTournament generates a random tournament.
  • Star generates a star digraph.
  • Wheel generates a wheel digraph.

Operations

Algorithms

Bellman-Ford-Moore

The Bellman-Ford-Moore algorithm finds the shortest distances from a source vertex to all other vertices in an arc-weighted digraph with negative weights.

A breadth-first search explores an unweighted digraph's vertices in order of their distance from a source.

A depth-first search explores an unweighted digraph's vertices in order of their depth from a source.

  • Dfs iterates the vertices.
  • DfsDist iterates the vertices and their distance from the source.
  • DfsPred iterates the vertices and their predecessors.
  • DfsPred::predecessors finds the predecessors.

Dijkstra

Dijkstra's algorithm finds the shortest paths in an arc-weighted digraph.

Distance Matrix

A DistanceMatrix contains the shortest distances between all vertex pairs in a digraph.

Floyd-Warshall

The Floyd-Warshall algorithm finds the distance between each vertex pair in an arc-weighted digraph.

Johnson's Circuit-Finding Algorithm

Johnson's circuit-finding algorithm finds all circuits in a digraph.

Predecessor Tree

A PredecessorTree contains the vertex predecessors.

Tarjan

Tarjan's algorithm finds strongly connected components in a digraph.

Changelog

See CHANGELOG.md for a list of changes.

License

Licensed under Apache License, Version 2.0 or MIT license at your option.

Contact

Feel free to reach out with questions or suggestions.

No runtime deps