]> Git — Sourcephile - gargantext.git/blob - clustering-louvain/src/Data/Utils.hs
[FEAT] adding clustering louvain.
[gargantext.git] / clustering-louvain / src / Data / Utils.hs
1 module Data.Utils where
2
3 import Data.Maybe
4 import Data.Graph.Inductive
5 import Data.List (nub)
6
7
8 label' :: (Graph gr) => gr a b -> Edge -> Maybe b
9 label' gr (u,v) = lookup v (lsuc gr u)
10
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
13
14
15 mkGraph' :: [LEdge b] -> Gr () b
16 mkGraph' es = mkGraph ns es
17 where
18 ns :: [LNode ()]
19 ns = zip [1.. (fromIntegral . length) ns'] (repeat ())
20 where ns' = nub $ concat (Prelude.map edge2nodes es)
21
22 edge2nodes :: LEdge b -> [Node]
23 edge2nodes (a,b,_) = [a,b]
24
25
26