Expand description
§Graaf
Rust-powered directed graphs.
§Table of Contents
§Representations
§Arc-Weighted Sparse Digraphs
AdjacencyListWeightedrepresents a digraph as a vector of maps.
§Unweighted Dense Digraphs
AdjacencyMatrixrepresents a digraph as a matrix using a bit vector.
§Unweighted Sparse Digraphs
AdjacencyListrepresents a digraph as a vector of sets.AdjacencyMaprepresents a digraph as a map of sets.EdgeListrepresents a digraph as a vector of tuples.
§Generators
Bicliquegenerates a complete bipartite digraph.Circuitgenerates a circuit digraph.Completegenerates a complete digraph.Cyclegenerates a bidirectional circuit.Emptygenerates a digraph without arcs.ErdosRenyigenerates a random digraph.GrowingNetworkgenerates a growing network.Pathgenerates a path digraph.RandomTournamentgenerates a random tournament.Stargenerates a star digraph.Wheelgenerates a wheel digraph.
§Operations
AddArcWeightedadds an arc to an arc-weighted digraph.AddArcadds an arc to an unweighted digraph.ArcWeightreturns an arc’s weight.ArcsWeightediterates over a digraph’s weighted arcs.Arcsiterates over a digraph’s arcs.Complementreturns a digraph’s complement.Conversereturns a digraph’s converse.DegreeSequenceiterates over a digraph’s degrees.Degreereturns a vertex’s degree.FilterVerticesfilters a digraph’s vertices.HasArcchecks whether a digraph contains an arc.HasEdgechecks whether a digraph contains an edge.HasWalkchecks whether a digraph contains a walk.InNeighborsiterates over a vertex’s in-neighbors.IndegreeSequenceiterates over a digraph’s indegrees.Indegreea vertex’s indegree.IsBalancedchecks whether a digraph is balanced.IsCompletechecks whether a digraph is complete.IsIsolatedchecks whether a vertex is isolated.IsOrientedchecks whether a digraph is oriented.IsPendantchecks whether a vertex is a pendant.IsRegularchecks whether a digraph is regular.IsSemicompletechecks whether a digraph is semicomplete.IsSimplechecks whether a digraph is simple.IsSpanningSubdigraphchecks whether a digraph spans a superdigraph.IsSubdigraphchecks whether a digraph is a subdigraph.IsSuperdigraphchecks whether a digraph is a superdigraph.IsSymmetricchecks whether a digraph is symmetric.IsTournamentchecks whether a digraph is a tournament.Orderreturns the number of vertices in a digraph.OutNeighborsWeightediterates over a vertex’s weighted out-neighbors.OutNeighborsiterates over a vertex’s out-neighbors.OutdegreeSequenceiterates over a digraph’s outdegrees.Outdegreereturns a vertex’s outdegree.RemoveArcremoves an arc from a digraph.SemidegreeSequenceiterates over a digraph’s semidegrees.Sinksiterates over a digraph’s sinks.Sizereturns the number of arcs in a digraph.Sourcesiterates over a digraph’s sources.Unionreturns the union of two digraphs.Verticesiterates over a digraph’s vertices.
§Algorithms
§Bellman-Ford-Moore
Find the shortest distances from a source vertex to all other vertices in an arc-weighted digraph with negative weights.
BellmanFordMoore::distancesfinds the shortest distances.
§Breadth-First Search
A breadth-first search explores an unweighted digraph’s vertices in order of their distance from a source.
Bfsiterates the vertices.BfsDistiterates the vertices and their distance from the source.BfsPrediterates the vertices and their predecessors.BfsDist::distancesfinds the shortest distances.BfsPred::cyclesreturns the cycles along the shortest path.BfsPred::predecessorsfinds the predecessors.BfsPred::shortest_pathfinds the shortest path.
§Depth-First Search
A depth-first search explores an unweighted digraph’s vertices in order of their distance from a source.
Dfsiterates the vertices.DfsDistiterates the vertices and their distance from the source.DfsPrediterates the vertices and their predecessors.DfsPred::predecessorsfinds the predecessors.
§Dijkstra
Dijkstra’s algorithm finds the shortest paths from one or more source vertices in an arc-weighted digraph.
Dijkstraiterates the vertices.DijkstraDistiterates the vertices and their distance from the source.DijkstraPrediterates the vertices and their predecessors.DijkstraDist::distancesfinds the shortest distances.DijkstraPred::predecessorsfinds the predecessors.DijkstraPred::shortest_pathfinds the shortest path.
§Distance Matrix
A DistanceMatrix contains the shortest distances between all vertex
pairs in a digraph.
DistanceMatrix::centerfinds the digraph’s center.DistanceMatrix::diameterfinds the digraph’s diameter.DistanceMatrix::eccentricitiesthe vertices’ eccentricities.DistanceMatrix::is_connectedchecks the digraph’s connectedness.DistanceMatrix::peripheryfinds the digraph’s periphery.
§Floyd-Warshall
The Floyd-Warshall algorithm finds the distance between each vertex pair in an arc-weighted digraph.
FloydWarshall::distancesfinds the shortest distances.
§Johnson’s Circuit-Finding Algorithm
Johnson’s circuit-finding algorithm finds a digraph’s circuits.
Johnson75::circuitsfinds a digraph’s circuits.
§Predecessor Tree
A PredecessorTree is the result of a search and contains the vertices’
predecessors.
PredecessorTree::searchfinds a vertex by value.PredecessorTree::search_byfinds a vertex by predicate.
§Tarjan
Tarjan’s algorithm finds strongly connected components in a digraph.
Tarjan::componentsfinds strongly connected components.
Re-exports§
pub use repr::AdjacencyList;pub use repr::AdjacencyListWeighted;pub use repr::AdjacencyMap;pub use repr::AdjacencyMatrix;pub use repr::EdgeList;pub use op::AddArc;pub use op::AddArcWeighted;pub use op::ArcWeight;pub use op::Arcs;pub use op::ArcsWeighted;pub use op::Complement;pub use op::Converse;pub use op::Degree;pub use op::DegreeSequence;pub use op::FilterVertices;pub use op::HasArc;pub use op::HasEdge;pub use op::HasWalk;pub use op::InNeighbors;pub use op::Indegree;pub use op::IndegreeSequence;pub use op::IsBalanced;pub use op::IsComplete;pub use op::IsIsolated;pub use op::IsOriented;pub use op::IsPendant;pub use op::IsRegular;pub use op::IsSemicomplete;pub use op::IsSimple;pub use op::IsSpanningSubdigraph;pub use op::IsSubdigraph;pub use op::IsSuperdigraph;pub use op::IsSymmetric;pub use op::IsTournament;pub use op::Order;pub use op::OutNeighbors;pub use op::OutNeighborsWeighted;pub use op::Outdegree;pub use op::OutdegreeSequence;pub use op::RemoveArc;pub use op::SemidegreeSequence;pub use op::Sinks;pub use op::Size;pub use op::Sources;pub use op::Union;pub use op::Vertices;pub use gen::Biclique;pub use gen::Circuit;pub use gen::Complete;pub use gen::Cycle;pub use gen::Empty;pub use gen::ErdosRenyi;pub use gen::GrowingNetwork;pub use gen::Path;pub use gen::RandomTournament;pub use gen::Star;pub use gen::Wheel;pub use algo::bellman_ford_moore::BellmanFordMoore;pub use algo::bfs::Bfs;pub use algo::bfs_dist::BfsDist;pub use algo::bfs_pred::BfsPred;pub use algo::dfs::Dfs;pub use algo::dfs_dist::DfsDist;pub use algo::dfs_pred::DfsPred;pub use algo::dijkstra::Dijkstra;pub use algo::dijkstra_dist::DijkstraDist;pub use algo::dijkstra_pred::DijkstraPred;pub use algo::distance_matrix::DistanceMatrix;pub use algo::floyd_warshall::FloydWarshall;pub use algo::johnson_75::Johnson75;pub use algo::predecessor_tree::PredecessorTree;pub use algo::tarjan::Tarjan;
Modules§
- Digraph algorithms
- Generate parameterized and random digraphs.
- Operations on digraphs
- Digraph representations.
Macros§
- Common tests for unweighted digraphs.