diff --git a/package.yaml b/package.yaml index 70bffe50970994e1646eab17976b31197a086a20..9a3d0bd8ab6a92c822e74b4969e920fde32b771f 100644 --- a/package.yaml +++ b/package.yaml @@ -130,7 +130,6 @@ library: - cassava - cereal # (IGraph) - clock - - clustering-louvain - conduit - conduit-extra - containers diff --git a/src/Gargantext/Core/Viz/Graph/Bridgeness.hs b/src/Gargantext/Core/Viz/Graph/Bridgeness.hs index 90b587dc7caa0da8900bf9f5211888d925af9c69..6d9205b27e1fb3cee529106d57b8feca7ba12d46 100644 --- a/src/Gargantext/Core/Viz/Graph/Bridgeness.hs +++ b/src/Gargantext/Core/Viz/Graph/Bridgeness.hs @@ -18,7 +18,6 @@ TODO use Map LouvainNodeId (Map LouvainNodeId) module Gargantext.Core.Viz.Graph.Bridgeness -- (bridgeness) where -import Data.Graph.Clustering.Louvain.Utils (LouvainNode(..)) import Data.List (concat, sortOn) import Data.Map (Map, fromListWith, lookup, toList, mapWithKey, elems) import Data.Maybe (catMaybes) @@ -37,9 +36,6 @@ type NodeId = Int type CommunityId = Int ---------------------------------------------------------------------- -instance ToComId LouvainNode where - nodeId2comId (LouvainNode i1 i2) = (i1, i2) - instance ToComId ClusterNode where nodeId2comId (ClusterNode i1 i2) = (i1, i2) diff --git a/src/Gargantext/Core/Viz/Graph/Tools.hs b/src/Gargantext/Core/Viz/Graph/Tools.hs index e9fbeb214eb0e240709094c6500b8446e0cfb4f7..926a2c54920d43241650f6ccd1a40c88c517452a 100644 --- a/src/Gargantext/Core/Viz/Graph/Tools.hs +++ b/src/Gargantext/Core/Viz/Graph/Tools.hs @@ -15,7 +15,6 @@ module Gargantext.Core.Viz.Graph.Tools where -- import Data.Graph.Clustering.Louvain (hLouvain, {-iLouvainMap-}) -import Data.Graph.Clustering.Louvain.CplusPlus (cLouvain) import Data.HashMap.Strict (HashMap) import Data.Map (Map) import Data.Text (Text) @@ -28,7 +27,7 @@ import Gargantext.Core.Statistics import Gargantext.Core.Viz.Graph import Gargantext.Core.Viz.Graph.Bridgeness (bridgeness, Partitions, ToComId(..)) import Gargantext.Core.Viz.Graph.Index (createIndices, toIndex, map2mat, mat2map, Index, MatrixShape(..)) -import Gargantext.Core.Viz.Graph.Tools.IGraph (mkGraphUfromEdges, spinglass) +import Gargantext.Core.Viz.Graph.Tools.IGraph (mkGraphUfromEdges, spinglass, ClusterNode) import Gargantext.Prelude import IGraph.Random -- (Gen(..)) import qualified Data.HashMap.Strict as HashMap @@ -39,8 +38,15 @@ import qualified Data.Vector.Storable as Vec import qualified IGraph as Igraph import qualified IGraph.Algorithms.Layout as Layout -type Threshold = Double +------------------------------------------------------------- + +defaultClustering :: Map (Int, Int) Double -> IO [ClusterNode] +defaultClustering = spinglass 1 + +------------------------------------------------------------- + +type Threshold = Double cooc2graph' :: Ord t => Distance -> Double @@ -68,7 +74,7 @@ cooc2graphWith :: PartitionMethod -> Threshold -> HashMap (NgramsTerm, NgramsTerm) Int -> IO Graph -cooc2graphWith Louvain = cooc2graphWith' (cLouvain "1") +cooc2graphWith Louvain = undefined -- TODO use IGraph bindings cooc2graphWith Spinglass = cooc2graphWith' (spinglass 1) diff --git a/src/Gargantext/Core/Viz/Phylo/Cluster.hs b/src/Gargantext/Core/Viz/Phylo/Cluster.hs index 5a2f324f9f3dc1228d37288a5e19b3d5cb1f55ba..0e54005b0638053b037ab1bf59895ef7e3a64346 100644 --- a/src/Gargantext/Core/Viz/Phylo/Cluster.hs +++ b/src/Gargantext/Core/Viz/Phylo/Cluster.hs @@ -15,11 +15,11 @@ Portability : POSIX module Gargantext.Core.Viz.Phylo.Cluster where import Control.Parallel.Strategies -import Data.Graph.Clustering.Louvain.CplusPlus -import Data.Graph.Clustering.Louvain.Utils (LouvainNode(..)) import Data.List (null,concat,sort,intersect,(++), elemIndex, groupBy, nub, union, (\\), (!!)) import Data.Map (Map, fromList, mapKeys) import Gargantext.Prelude +import Gargantext.Core.Viz.Graph.Tools (defaultClustering) +import Gargantext.Core.Viz.Graph.Tools.IGraph (ClusterNode(..)) import Gargantext.Core.Viz.Phylo import Gargantext.Core.Viz.Phylo.Tools import Gargantext.Core.Viz.Phylo.Metrics @@ -48,9 +48,9 @@ relatedComp graphs = foldl' (\mem groups -> louvain :: ([GroupNode],[GroupEdge]) -> 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 "0.0001" $ mapKeys (\(x,y) -> (idx x, idx y)) $ fromList edges) +louvain (nodes,edges) = map (\community -> map (\node -> nodes !! (cl_node_id node)) community) + <$> groupBy (\a b -> (cl_community_id a) == (cl_community_id b)) + <$> (defaultClustering $ mapKeys (\(x,y) -> (idx x, idx y)) $ fromList edges) where -------------------------------------- idx :: PhyloGroup -> Int diff --git a/stack.yaml b/stack.yaml index 73b3e69912a0e67681b3bbff5db110b1894a39f3..faaf0d6e37401de277e4c0ff7778e53084f0ca2d 100644 --- a/stack.yaml +++ b/stack.yaml @@ -6,7 +6,6 @@ packages: #- 'deps/patches-class' #- 'deps/patches-map' #- 'deps/servant-job' -#- 'deps/clustering-louvain' #- 'deps/accelerate' #- 'deps/accelerate-utility' @@ -71,8 +70,6 @@ extra-deps: # Graph libs - git: https://github.com/kaizhang/haskell-igraph.git commit: 34553acc4ebdcae7065311dcefb426e0fd58c5a0 -- git: https://gitlab.iscpif.fr/gargantext/clustering-louvain.git - commit: 7d74f96dfea8e51fbab1793cc0429b2fe741f73d # Accelerate Linear Algebra and specific instances # (UndecidableInstances for newer GHC version)