Module
Data.Graph.Pathfinding
- Package
- purescript-hylograph-graph
- Repository
- afcondon/purescript-hylograph-graph
Pathfinding Algorithms
Pure implementations of graph traversal and shortest path algorithms.
For visualization-friendly traced variants, see Data.Graph.Pathfinding.Traced.
#dijkstra Source
dijkstra :: NodeId -> Graph -> SearchResultDijkstra's algorithm: find shortest paths from a source to all reachable nodes
Returns distances and parent pointers for path reconstruction.
let result = dijkstra (NodeId "A") graph
-- result.distances: Map from each node to its distance from A
-- result.parents: Map from each node to its parent in shortest path tree
#shortestPath Source
shortestPath :: NodeId -> NodeId -> Graph -> PathResultFind shortest path between two nodes using Dijkstra's algorithm
This is the main pathfinding function for weighted graphs.
#findPath Source
findPath :: NodeId -> NodeId -> Graph -> PathResultAlias for shortestPath (backwards compatibility with A* demo)
#bfs Source
bfs :: NodeId -> Graph -> SearchResultBFS from a starting node
Returns all reachable nodes with their depths and parent pointers. Useful for unweighted shortest paths.
#dfs Source
dfs :: NodeId -> Graph -> SearchResultDFS from a starting node
Returns all reachable nodes with discovery times and parent pointers.