1 module Data.Utils where
4 import Data.Graph.Inductive
8 label' :: (Graph gr) => gr a b -> Edge -> Maybe b
9 label' gr (u,v) = lookup v (lsuc gr u)
11 shortest_path :: (Real b, Graph gr) => gr a b -> Node -> Node -> Maybe Path
12 shortest_path graph node_1 node_2= sp node_1 node_2 graph
15 mkGraph' :: [LEdge b] -> Gr () b
16 mkGraph' es = mkGraph ns es
19 ns = zip [1.. (fromIntegral . length) ns'] (repeat ())
20 where ns' = nub $ concat (Prelude.map edge2nodes es)
22 edge2nodes :: LEdge b -> [Node]
23 edge2nodes (a,b,_) = [a,b]