Commit 27811443 authored by Alexandre Delanoë's avatar Alexandre Delanoë

cosmetics

parent e4235d09
......@@ -4,7 +4,7 @@ cabal-version: 1.12
--
-- see: https://github.com/sol/hpack
--
-- hash: 92999c9be9048a97745703a9575dcb38cea579137bd2a893acf77c708290b84e
-- hash: 0eb2bbc80a3d9343540c4d5c0c2ff6adee085a9a75364b8f5344890891c5b781
name: clustering-louvain
version: 0.1.0.0
......@@ -40,6 +40,7 @@ library
Data.Graph.Clustering.Louvain.CplusPlus
other-modules:
Data.Graph.Clustering.Example
Data.Graph.Clustering.FLouvain
Data.Graph.Clustering.HLouvain
Paths_clustering_louvain
default-language: Haskell2010
......@@ -7,14 +7,15 @@ Maintainer : alexandre.delanoe+louvain@iscpif.fr
Stability : experimental
Portability : POSIX
Clustering is not precise enought to work with (kmeans clustering is not
the same methodology than Louvain clustering fo rinstance).
Clustering is not precise enough to work with (kmeans clustering has not
the same methodology than Louvain clustering fo instance, not speaking
about the use of graph or not that is not the point).
Here is a new semantic to change this situation.
glustering vs klustering
glustering: agglomerate according to glue rules (bottom up)
klustering: split in k parts according to klue rules (top down)
klustering: split according to klue rules (top down)
-}
......@@ -65,8 +66,7 @@ comp g' = map sortNodes cs
where
sortNodes ns = case head $ sortOn (Down . (G.deg g)) ns of
Nothing -> []
-- sort nodes by depth first to speed up the glustering
Just n -> G.dfs [n] g
Just n -> G.dfs [n] g -- dfs for glustering, bfs for klustering
cs = G.components g
g = G.undir g'
......@@ -78,7 +78,7 @@ comp g' = map sortNodes cs
-- are glusters with score of glue to build it.
data Dendogram = Gram Node
| Dendogram { gluster :: ![Dendogram]
| Dendogram { dends :: ![Dendogram] -- d-ends ends can be either glusters or klusters
, score :: !Double
}
deriving (Show, Eq)
......@@ -128,20 +128,28 @@ inDendo g d1@(Gram _) d2@(Gram _) = Dendogram n' (hasScore g n')
where
ds = inDendo g d1 (toDendoD g d2)
ss = hasScore g ds
n' | hasScore g d1 + hasScore g d2 > ss = [d1,d2]
| otherwise = [ds]
inDendo g n@(Gram _) d@(Dendogram _ _) = inDendo g (toDendoD g n) d
s1 = hasScore g d1
s2 = hasScore g d2
n' = [d1,d2]
{-
n' | s1 + s2 > ss = [d1,d2]
| otherwise = [ds]
-}
inDendo g d@(Dendogram _ _) n@(Gram _) = inDendo g n d
inDendo g n@(Gram _) d@(Dendogram _ _) = inDendo g (toDendoD g n) d
inDendo g d1@(Dendogram _ _) d2@(Dendogram _ _) = Dendogram n' (hasScore g n')
inDendo g d1@(Dendogram _ s1) d2@(Dendogram _ s2) = Dendogram n' (hasScore g n')
where
ds = inDendo g d1 d2
ss = hasScore g ds
n' | hasScore g [d1, d2] > ss = [d1,d2]
n' = [ds]
{-
n' | s1 + s2 > ss = [d1,d2]
| otherwise = [ds]
-}
-------------------------------------------------------------------
nodesD :: Dendogram -> Set Node
nodesD (Gram n) = Set.singleton n
......
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