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.RandomRecursiveTreegenerates a random recursive tree.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 a digraph’s weighted arcs.Arcsiterates a digraph’s arcs.Complementreturns a digraph’s complement.ContiguousOrderreturns a contiguous digraph’s order.Conversereturns a digraph’s converse.DegreeSequenceiterates 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 a vertex’s in-neighbors.IndegreeSequenceiterates 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.Ordercounts the vertices in a digraph.OutNeighborsWeightediterates a vertex’s weighted out-neighbors.OutNeighborsiterates a vertex’s out-neighbors.OutdegreeSequenceiterates a digraph’s outdegrees.Outdegreereturns a vertex’s outdegree.RemoveArcremoves an arc from a digraph.SemidegreeSequenceiterates a digraph’s semidegrees.Sinksiterates a digraph’s sinks.Sizecounts the arcs in a digraph.Sourcesiterates a digraph’s sources.Unionreturns the union of two digraphs.Verticesiterates a digraph’s vertices.
§Algorithms
§Bellman-Ford-Moore
BellmanFordMoore::distancesfinds the shortest distances from a source vertex to all other vertices in an arc-weighted digraph with negative weights.
§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
FloydWarshall::distancesfinds the distance between each vertex pair in an arc-weighted digraph.
§Johnson’s Circuit-Finding Algorithm
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::componentsfinds strongly connected components in a digraph.
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::ContiguousOrder;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::Path;pub use gen::RandomRecursiveTree;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§
- algo
- Digraph algorithms
- gen
- Generate parameterized and random digraphs.
- op
- Operations on digraphs
- repr
- Digraph representations.
Macros§
- proptest_
add_ arc AddArcproptests- proptest_
add_ arc_ weighted AddArcWeightedproptests- proptest_
biclique Bicliqueproptests- proptest_
circuit Circuitproptests- proptest_
complete Completeproptests- proptest_
contiguous_ order ContiguousOrderproptests- proptest_
cycle Cycleproptests- proptest_
empty Emptyproptests- proptest_
empty_ complement Emptyproptests withComplement- proptest_
empty_ complete Emptyproptests withComplementandComplete- proptest_
erdos_ renyi ErdosRenyiproptests- proptest_
has_ arc HasArcproptests- proptest_
path Pathproptests- proptest_
random_ recursive_ tree RandomRecursiveTreeproptests- proptest_
random_ tournament RandomTournamentproptests- proptest_
star Starproptests- proptest_
union Unionproptests- proptest_
wheel Wheelproptests- test_
add_ arc_ out_ of_ bounds AddArcout-of-bounds tests- test_
add_ arc_ self_ loop AddArcself-loop tests- test_
arcs Arcstests- test_
biclique Bicliquetests- test_
circuit Circuittests- test_
complete Completetests- test_
converse Conversetests- test_
cycle Cycletests- test_
degree Degreetests- test_
degree_ sequence DegreeSequencetests- test_
empty Emptytests- test_
erdos_ renyi ErdosRenyitests- test_
has_ walk HasWalktests- test_
in_ neighbors InNeighborstests- test_
indegree Indegreetests- test_
indegree_ sequence IndegreeSequencetests- test_
is_ balanced IsBalancedtests- test_
is_ complete IsCompletetests- test_
is_ isolated IsIsolatedtests- test_
is_ oriented IsOrientedtests- test_
is_ pendant IsPendanttests- test_
is_ regular IsRegulartests- test_
is_ semicomplete IsSemicompletetests- test_
is_ simple IsSimpletests- test_
is_ symmetric IsSymmetrictests- test_
is_ tournament IsTournamenttests- test_
order Ordertests- test_
out_ neighbors OutNeighborstests- test_
outdegree Outdegreetests- test_
outdegree_ sequence OutdegreeSequencetests- test_
path Pathtests- test_
random_ recursive_ tree RandomRecursiveTreetests- test_
random_ tournament RandomTournamenttests- test_
remove_ arc RemoveArctests- test_
semidegree_ sequence SemidegreeSequencetests- test_
sinks Sinkstests- test_
size Sizetests- test_
sources Sourcestests- test_
star Startests- test_
wheel Wheeltests