Expand description
§Graaf
Rust-powered directed graphs.
§Table of Contents
§Digraph Types
Graaf provides directed graphs representations. These types eagerly implement digraph operations and algorithms.
adjacency_listrepresents unweighted sparse digraphs.adjacency_matrixrepresents unweighted dense digraphs.adjacency_list_weightedrepresents arc-weighted sparse digraphs.edge_listrepresents unweighted sparse digraphs.
§Creating Digraphs
The gen module provides digraph generators. Each digraph representation
can be constructed with the operations in the op module.
Bicliquegenerates a complete bipartite digraph.Circuitgenerates a circuit digraph.Completegenerates a complete digraph.Cyclegenerates a bidirectional circuit.Emptygenerates a digraph with no arcs.ErdosRenyigenerates a random digraph.RandomTournamentgenerates a random tournament.Stargenerates a star digraph.Pathgenerates a path digraph.
§Operations
The op module provides digraph operation traits. The digraph
types implement these traits. One can implement these
traits for custom digraph types. Operations form the foundation for
algorithms.
AddArcWeightedadds an arc to an arc-weighted digraph.AddArcadds an arc to an unweighted digraph.ArcWeightreturns an arc’s weight.ArcsWeightedreturns a digraph’s weighted arcs.Arcsreturns a digraph’s arcs.Complementreturns a digraph’s complement.Conversereturns a digraph’s converse.DegreeSequencereturns a digraph’s degree sequence.Degreereturns a vertex’s degree.HasArcchecks whether a digraph contains an arc.HasEdgechecks whether a digraph contains an edge.HasWalkchecks whether a digraph contains a walk.InNeighborsreturns a vertex’s in-neighbors.IndegreeSequencereturns a digraph’s indegree sequence.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.OutNeighborsWeightedreturns a vertex’s weighted out-neighbors.OutNeighborsreturns a vertex’s out-neighbors.OutdegreeSequencereturns a digraph’s outdegree sequence.Outdegreereturns a vertex’s outdegree.RemoveArcremoves an arc from a digraph.SemidegreeSequencereturns a digraph’s semidegree sequence.Sinksreturns a digraph’s sinks.Sizereturns the number of arcs in a digraph.Sourcesreturns a digraph’s sources.Verticesreturns a digraph’s vertices.
§Algorithms
The algo module provides digraph algorithms.
§Bellman-Ford-Moore
The Bellman-Ford-Moore algorithm finds the shortest paths in an arc-weighted digraph with negative weights.
single_source_distancesfinds the shortest distances.
§Breadth-First Search (BFS)
A breadth-first search explores the vertices of an unweighted digraph in order of their distance from a source.
bfs::Bfsiterates over the vertices.bfs_dist::Bfsiterates over the vertices and their distance from the source.bfs_pred::Bfsiterates over the vertices and their predecessors.bfs_dist::Bfs::distancesfinds the shortest distances.bfs_pred::Bfs::predecessorsfinds the predecessors.bfs_pred::Bfs::shortest_pathfinds the shortest path.
§Depth-First Search (DFS)
A depth-first search explores the vertices of an unweighted digraph in order of their distance from a source.
dfs::Dfsiterates over the vertices.dfs_dist::Dfsiterates over the vertices and their distance from the source.
§Dijkstra
Dijkstra’s algorithm finds the shortest paths from one or more source vertices in an arc-weighted digraph.
dijkstra::Dijkstraiterates over the vertices.dijkstra_dist::Dijkstraiterates over the vertices and their distance from the source.dijkstra_pred::Dijkstraiterates over the vertices and their predecessors.dijkstra_dist::Dijkstra::distancesfinds the shortest distances.dijkstra_pred::Dijkstra::predecessorsfinds the predecessors.dijkstra_pred::Dijkstra::shortest_pathfinds the shortest path.
§Floyd-Warshall
The Floyd-Warshall algorithm finds the shortest paths between all pairs of vertices in an arc-weighted digraph.
distancesfinds the shortest distances.
§Tarjan
Tarjan’s algorithm finds the strongly connected components in a digraph.
strongly_connected_componentsfinds the strongly connected components.
§Predecessor Tree
A PredecessorTree is the result of a
breadth-first search and contains the predecessors of the vertices on the
shortest paths.
PredecessorTree::searchfinds a vertex by value.PredecessorTree::search_byfinds a vertex by predicate.
These functions produce a predecessor tree.
§Distance Matrix
A DistanceMatrix contains the shortest distances
between all pairs of vertices in a digraph.
DistanceMatrix::centerfinds the center of the digraph.DistanceMatrix::diameterfinds the diameter of the digraph.DistanceMatrix::eccentricitiesreturns the eccentricities of the vertices.DistanceMatrix::is_connectedchecks if the digraph is connected.DistanceMatrix::peripheryfinds the periphery of the digraph.
§Naming Conventions
sdenotes a source vertex.tdenotes a target vertex.udenotes a tail vertex or the first vertex in scope.vdenotes a head vertex or the second vertex in scope.wdenotes the weight of an arc.xdenotes a tail vertex or the third vertex in scope.ydenotes a head vertex or the fourth vertex in scope.
Modules§
- An adjacency list representation of an unweighted digraph
- An adjacency list representation of an arc-weighted digraph
- An adjacency matrix representation of an unweighted digraph
- Digraph algorithms
- An edge list representation of an unweighted digraph
- Digraph generators.
- Operations on digraphs