2 Module : Gargantext.Viz.Phylo.SynchronicClustering
3 Description : Module dedicated to the adaptative synchronic clustering of a Phylo.
4 Copyright : (c) CNRS, 2017-Present
5 License : AGPL + CECILL v3
6 Maintainer : team@gargantext.org
7 Stability : experimental
11 {-# LANGUAGE NoImplicitPrelude #-}
12 {-# LANGUAGE FlexibleContexts #-}
13 {-# LANGUAGE OverloadedStrings #-}
14 {-# LANGUAGE MultiParamTypeClasses #-}
16 module Gargantext.Viz.Phylo.SynchronicClustering where
18 import Gargantext.Prelude
19 import Gargantext.Viz.AdaptativePhylo
20 import Gargantext.Viz.Phylo.PhyloTools
22 import Data.List (foldl', (++), null, intersect, (\\), union, nub, concat)
29 relatedComponents :: Eq a => [[a]] -> [[a]]
30 relatedComponents graphs = foldl' (\mem groups ->
34 let related = filter (\groups' -> (not . null) $ intersect groups groups') mem
37 else (mem \\ related) ++ [union groups (nub $ concat related)] ) [] graphs