Commit 89f88ad5 authored by delanoe's avatar delanoe

[FUNC] uniq -> nub

parent e11beb6a
module Data.Louvain where module Data.Louvain where
import Data.Utils import Data.Utils
import Data.List (maximumBy) import Data.List (maximumBy,nub)
import Data.Graph.Inductive import Data.Graph.Inductive
type Modularity = Double type Modularity = Double
...@@ -13,11 +13,12 @@ inducedGraph gr (a,b) = delNodes b (insEdges newEdges gr') ...@@ -13,11 +13,12 @@ inducedGraph gr (a,b) = delNodes b (insEdges newEdges gr')
gr' = undir gr gr' = undir gr
newEdges = Prelude.map (\(n,l) -> (a,n,l)) ( uniq $ concat $ Prelude.map (lsuc gr') b ) newEdges = Prelude.map (\(n,l) -> (a,n,l)) ( uniq $ concat $ Prelude.map (lsuc gr') b )
-- | TODO exducedGraph (inverse for tests with quickCheck)
inducedGraph' :: (Ord b, DynGraph gr) => gr a b -> [(Node, [Node])] -> gr a b inducedGraph' :: (Ord b, DynGraph gr) => gr a b -> [(Node, [Node])] -> gr a b
inducedGraph' gr ns = Prelude.foldl (\gr' n -> inducedGraph gr' n) gr ns inducedGraph' gr ns = Prelude.foldl (\gr' n -> inducedGraph gr' n) gr ns
neighbors'' :: DynGraph gr => gr a b -> [Node] -> [Node] neighbors'' :: DynGraph gr => gr a b -> [Node] -> [Node]
neighbors'' gr ns = uniq $ concat (Prelude.map (neighbors gr) ns) neighbors'' gr ns = nub $ concat (Prelude.map (neighbors gr) ns)
neighcom :: DynGraph gr => gr a b -> Node -> [[Node]] neighcom :: DynGraph gr => gr a b -> Node -> [[Node]]
neighcom gr n = scanl (\x y -> take 1 x ++ [y]) [n] (neighbors gr n) neighcom gr n = scanl (\x y -> take 1 x ++ [y]) [n] (neighbors gr n)
......
...@@ -2,11 +2,9 @@ module Data.Utils where ...@@ -2,11 +2,9 @@ module Data.Utils where
import Data.Graph.Inductive import Data.Graph.Inductive
import Data.Set as S (toList, fromList) import Data.Set as S (toList, fromList)
import qualified Data.List (nub)
uniq :: Ord a => [a] -> [a]
uniq = toList . fromList
label' :: (Graph gr) => gr a b -> Edge -> Maybe b label' :: (Graph gr) => gr a b -> Edge -> Maybe b
label' gr (u,v) = lookup v (lsuc gr u) label' gr (u,v) = lookup v (lsuc gr u)
...@@ -19,7 +17,7 @@ mkGraph' es = mkGraph ns es ...@@ -19,7 +17,7 @@ mkGraph' es = mkGraph ns es
where where
ns :: [LNode ()] ns :: [LNode ()]
ns = zip [1.. (fromIntegral . length) ns'] (repeat ()) ns = zip [1.. (fromIntegral . length) ns'] (repeat ())
where ns' = uniq $ concat (Prelude.map edge2nodes es) where ns' = nub $ concat (Prelude.map edge2nodes es)
edge2nodes :: LEdge b -> [Node] edge2nodes :: LEdge b -> [Node]
......
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