Commit a20e2ec7 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[TEST] hLouvain

parent 5993a1f3
...@@ -38,11 +38,11 @@ type Community = [Node] ...@@ -38,11 +38,11 @@ type Community = [Node]
type Reverse = Bool type Reverse = Bool
------------------------------------------------------------------------ ------------------------------------------------------------------------
iLouvain :: I.MaxIterations iLouvainMap :: I.MaxIterations
-> I.MaxSize -> I.MaxSize
-> Map (Node, Node) Double -> Map (Node, Node) Double
-> [LouvainNode] -> [LouvainNode]
iLouvain x s m = concat iLouvainMap x s m = concat
$ toLouvainNode $ toLouvainNode
$ I.toNodes $ I.toNodes
$ I.iLouvain x s I.DfsNodes g $ I.iLouvain x s I.DfsNodes g
...@@ -55,11 +55,16 @@ flouvain n g = map (comNodes . snd) $ labNodes g' ...@@ -55,11 +55,16 @@ flouvain n g = map (comNodes . snd) $ labNodes g'
where where
g' = louvainFirstStepIterate n (toFGraph g) g' = louvainFirstStepIterate n (toFGraph g)
------------------------------------------------------------------------ ------------------------------------------------------------------------
hLouvain :: (Eq b, DynGraph gr)
hLouvain :: Map (Node, Node) Double
-> [LouvainNode]
hLouvain m = hLouvain' False $ undir $ map2graph m
hLouvain' :: (Eq b, DynGraph gr)
=> Reverse => Reverse
-> gr a b -> gr a b
-> [LouvainNode] -> [LouvainNode]
hLouvain r g = concat $ toLouvainNode (bestpartition r g) hLouvain' r g = concat $ toLouvainNode (bestpartition r g)
toLouvainNode :: [[Node]] -> [[LouvainNode]] toLouvainNode :: [[Node]] -> [[LouvainNode]]
toLouvainNode ns = zipWith (\cId ns' -> map (\n -> LouvainNode n cId) ns') toLouvainNode ns = zipWith (\cId ns' -> map (\n -> LouvainNode n cId) ns')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment