Commit 4abc2735 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[FIX] Bridgeness (suite)

parent d584aed7
...@@ -30,7 +30,6 @@ module Gargantext.Prelude ...@@ -30,7 +30,6 @@ module Gargantext.Prelude
, sortWith , sortWith
, module Prelude , module Prelude
, MonadBase(..) , MonadBase(..)
, Map2 , lookup2
) )
where where
...@@ -72,10 +71,7 @@ import Prelude (Enum, Bounded, minBound, maxBound, putStrLn) ...@@ -72,10 +71,7 @@ import Prelude (Enum, Bounded, minBound, maxBound, putStrLn)
-- import Gargantext.Utils.Count -- import Gargantext.Utils.Count
import qualified Data.List as L hiding (head, sum) import qualified Data.List as L hiding (head, sum)
import qualified Control.Monad as M import qualified Control.Monad as M
import Data.Map (Map)
import qualified Data.Map as M import qualified Data.Map as M
import Data.Map.Strict (insertWith) import Data.Map.Strict (insertWith)
import qualified Data.Vector as V import qualified Data.Vector as V
import Safe (headMay, lastMay, initMay, tailMay) import Safe (headMay, lastMay, initMay, tailMay)
......
...@@ -53,7 +53,7 @@ bridgeness b ns = DM.fromList ...@@ -53,7 +53,7 @@ bridgeness b ns = DM.fromList
nodeId2comId :: [LouvainNode] -> Map LouvainNodeId CommunityId nodeId2comId :: [LouvainNode] -> Map LouvainNodeId CommunityId
nodeId2comId ns = fromList [ (nId,cId) | LouvainNode nId cId <- ns] nodeId2comId ns = fromList [(nId,cId) | LouvainNode nId cId <- ns]
groupEdges :: Map LouvainNodeId CommunityId groupEdges :: Map LouvainNodeId CommunityId
...@@ -73,14 +73,16 @@ groupEdges m = fromListWith (<>) ...@@ -73,14 +73,16 @@ groupEdges m = fromListWith (<>)
filterComs :: Bridgeness filterComs :: Bridgeness
-> Map (CommunityId, CommunityId) [((LouvainNodeId, LouvainNodeId), Double)] -> Map (CommunityId, CommunityId) [((LouvainNodeId, LouvainNodeId), Double)]
-> Map (CommunityId, CommunityId) [((LouvainNodeId, LouvainNodeId), Double)] -> Map (CommunityId, CommunityId) [((LouvainNodeId, LouvainNodeId), Double)]
filterComs b m = mapWithKey filter' m filterComs _b m = DM.filter (\n -> length n > 0) $ mapWithKey filter' m
where where
filter' (c1,c2) a filter' (c1,c2) a
| c1 == c2 = a | c1 == c2 = a
| otherwise = take n $ sortOn (Down . snd) a -- TODO use n here
| otherwise = take 1 $ sortOn (Down . snd) a
where where
n = round $ 100 * b * a' / t _n :: Int
_n = round $ 100 * a' / t
a'= fromIntegral $ length a a'= fromIntegral $ length a
t :: Double
t = fromIntegral $ length $ concat $ elems m t = fromIntegral $ length $ concat $ elems m
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