haskell-dijkstra
haskell-dijkstra copied to clipboard
Add two useful features: fromEdgeList, pathToNodeLength
I suggest you to add two functions to this lib. The names and the implementation can be different, of course, but something as follows:
-- Similar to `fromText`, but the input is list of tuples of a node name pair and the weight of the
-- edge between them instead of the string
fromEdgeList :: [((String, String), Float)] -> Bool -> Graph
fromEdgeList edgeList isDigraph =
let allEs = if isDigraph then edgeList
else appendReversed edgeList
in fromList allEs
and
-- given a Dijkstra solution and a destination node, return the length of path
pathToNodeLength :: [Dnode] -> Node -> Float
pathToNodeLength dnodes dest = fst . snd . dnodeForNode dnodes $ dest