# dijkstra-simple: A simpler Dijkstra shortest paths implementation

[ bsd3, dijkstra, graph, library ] [ Propose Tags ]

Provides a simplistic Dijkstra implementation with some useful variations and generalizations.

#### Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.1.0 changelog.md base (>=4.7 && <5), containers (>=0.6.2.1 && <0.7), fingertree (>=0.1.4.0 && <0.1.5) [details] BSD-3-Clause Gautier DI FOLCO Gautier DI FOLCO gautier.difolco@gmail.com graph, dijkstra https://github.com/blackheaven/dijkstra-simple#readme https://github.com/blackheaven/dijkstra-simple/issues head: git clone https://github.com/blackheaven/dijkstra-simple by gdifolco at 2020-06-27T14:35:06Z 307 total (6 in the last 30 days) (no votes yet) [estimated by Bayesian average] λ λ λ Docs available Last success reported on 2020-06-27

[back to package description]

# dijkstra-simple

A simpler Dijkstra shortest paths implementation

## Basic usage

This section contains basic step-by-step usage of the library.

The first step is to build a direct graph:

exampleGraph :: Graph Char Int
exampleGraph = Graph $M.fromList [ ('A', [EdgeTo 'B' 3, EdgeTo 'C' 1]) , ('B', [EdgeTo 'A' 3, EdgeTo 'C' 7, EdgeTo 'D' 5, EdgeTo 'E' 1]) , ('C', [EdgeTo 'A' 1, EdgeTo 'B' 7, EdgeTo 'D' 2]) , ('D', [EdgeTo 'B' 5, EdgeTo 'C' 2, EdgeTo 'E' 5]) , ('E', [EdgeTo 'B' 1, EdgeTo 'D' 7]) ]  Then pick or create a weighter (see Graph.DijkstraSimple.Weighters) and apply it all: lightestPaths exampleGraph 'C' weighter  It will give all the reacheable vertices from 'C' and associated shortest path: Paths$ M.fromList [
('A', Path (fromList "AC") 1)
, ('B', Path (fromList "BAC") 3)
, ('C', Path (fromList "CAC") 1)
, ('D', Path (fromList "DC") 2)
, ('E', Path (fromList "EBAC") 3)
]