| Copyright | Thodoris Papakonstantinou 2017-2026 |
|---|---|
| License | LGPL-3 |
| Maintainer | dev@tpapak.com |
| Stability | experimental |
| Portability | POSIX |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Data.Graph.AdjacencyList.BFS
Contents
Description
Breadth-first search (BFS) for directed graphs represented as adjacency lists. Provides two entry points:
bfs— BFS on a concreteGraphvalueadjBFS— BFS on an implicit graph given as anIntMap [Vertex]adjacency map
Both produce a BFS record containing the level (distance) of every reachable
vertex, the BFS parent map, and a topological ordering of the visited vertices.
Used by the Tide algorithm (Pure) in the
globalRelabel step to compute vertex heights from distances to the source and
sink in the residual graph.
BFS result
Result of a breadth-first search from a single source vertex.
Constructors
| BFS | |
Fields
| |
Running BFS
adjBFS :: IntMap [Vertex] -> Vertex -> BFS Source #
Run BFS on an implicit graph defined by an adjacency map.
adjBFS neimap s performs BFS from vertex s where the neighbors of
each vertex are given by neimap :: IntMap [Vertex]. Vertices not
present in neimap are treated as having no outgoing edges.
This is used by residualDistances
to run BFS on the residual graph (whose edge set changes each tide)
without constructing a full Graph value.