]> Git — Sourcephile - gargantext.git/blob - src/Gargantext/Viz/Phylo/Aggregates/Cluster.hs
[MERGE] Fix warnings.
[gargantext.git] / src / Gargantext / Viz / Phylo / Aggregates / Cluster.hs
1 {-|
2 Module : Gargantext.Viz.Phylo.Tools
3 Description : Phylomemy Tools to build/manage it
4 Copyright : (c) CNRS, 2017-Present
5 License : AGPL + CECILL v3
6 Maintainer : team@gargantext.org
7 Stability : experimental
8 Portability : POSIX
9
10
11 -}
12
13 {-# LANGUAGE NoImplicitPrelude #-}
14 {-# LANGUAGE FlexibleContexts #-}
15 {-# LANGUAGE OverloadedStrings #-}
16
17 module Gargantext.Viz.Phylo.Aggregates.Cluster
18 where
19
20
21 import Data.List (head,null,tail)
22 import Data.Map (Map)
23 import Data.Tuple (fst)
24 import Gargantext.Prelude hiding (head)
25 import Gargantext.Viz.Phylo
26 import Gargantext.Viz.Phylo.Tools
27 import Gargantext.Viz.Phylo.BranchMaker
28 import Gargantext.Viz.Phylo.Metrics.Clustering
29 import qualified Data.Map as Map
30
31
32 -- | To apply a Clustering method to a PhyloGraph
33 graphToClusters :: Cluster -> GroupGraph -> [PhyloCluster]
34 graphToClusters clust (nodes,edges) = case clust of
35 Louvain (LouvainParams _) -> undefined -- louvain (nodes,edges)
36 RelatedComponents (RCParams _) -> relatedComp 0 (head nodes) (tail nodes,edges) [] []
37 _ -> panic "[ERR][Viz.Phylo.Aggregates.Cluster.graphToClusters] not implemented"
38
39 -- | To transform a Phylo into Clusters of PhyloGroups at a given level
40 phyloToClusters :: Level -> Proximity -> Cluster -> Phylo -> Map (Date,Date) [PhyloCluster]
41 phyloToClusters lvl prox clus p = Map.fromList
42 $ zip (getPhyloPeriods p)
43 (map (\prd -> let graph = groupsToGraph prox (getGroupsWithFilters lvl prd p) p
44 in if null (fst graph)
45 then []
46 else graphToClusters clus graph)
47 (getPhyloPeriods p))