Commit c08d6972 authored by Alexandre Delanoë's avatar Alexandre Delanoë Committed by Quentin Lobbé

[PHYLO] cLouvain in IO Monad fix.

parent 044f740c
......@@ -131,7 +131,7 @@ data PhyloGroup =
, _phylo_groupLevelParents :: [Pointer]
, _phylo_groupLevelChilds :: [Pointer]
}
deriving (Generic, Show, Eq)
deriving (Generic, Show, Eq, Ord)
data PhyloBranch =
PhyloBranch { _phylo_branchId :: (Level,Int)
......
......@@ -37,7 +37,7 @@ import qualified Data.Set as Set
-- | To apply a Clustering method to a PhyloGraph
graphToClusters :: (Clustering,[Double]) -> PhyloGraph -> [[PhyloGroup]]
graphToClusters (clust,param) (nodes,edges) = case clust of
Louvain -> louvain (nodes,edges)
Louvain -> undefined -- louvain (nodes,edges)
RelatedComponents -> relatedComp 0 (head nodes) (tail nodes,edges) [] []
......@@ -49,4 +49,4 @@ phyloToClusters lvl (prox,param) (clus,param') p = Map.fromList
in if null (fst graph)
then []
else graphToClusters (clus,param') graph)
(getPhyloPeriods p))
\ No newline at end of file
(getPhyloPeriods p))
......@@ -59,19 +59,20 @@ relatedComp idx curr (nodes,edges) next memo
--------------------------------------
{-
louvain :: (PhyloNodes,PhyloEdges) -> [Cluster]
louvain (nodes,edges) = undefined
-}
-- louvain :: (PhyloNodes,PhyloEdges) -> [Cluster]
-- louvain (nodes,edges) = map (\community -> map (\node -> nodes !! (l_node_id node)) community)
-- $ groupBy (l_community_id)
-- $ cLouvain
-- $ mapKeys (\(x,y) -> (idx x, idx y))
-- $ fromList edges
-- where
-- --------------------------------------
-- idx :: PhyloGroup -> Int
-- idx e = case elemIndex e nodes of
-- Nothing -> panic "[ERR][Gargantext.Viz.Phylo.Metrics.Clustering] a node is missing"
-- Just i -> i
-- --------------------------------------
\ No newline at end of file
louvain :: (PhyloNodes,PhyloEdges) -> IO [[PhyloGroup]]
louvain (nodes,edges) = map (\community -> map (\node -> nodes !! (l_node_id node)) community)
<$> groupBy (\a b -> (l_community_id a) == (l_community_id b))
<$> (cLouvain $ mapKeys (\(x,y) -> (idx x, idx y)) $ fromList edges)
where
--------------------------------------
idx :: PhyloGroup -> Int
idx e = case elemIndex e nodes of
Nothing -> panic "[ERR][Gargantext.Viz.Phylo.Metrics.Clustering] a node is missing"
Just i -> i
--------------------------------------
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