Commit 15a3031c authored by Alexandre Delanoë's avatar Alexandre Delanoë

[:)] almost

parent 94be2a54
...@@ -151,11 +151,11 @@ nodesD (Gram n) = Set.singleton n ...@@ -151,11 +151,11 @@ nodesD (Gram n) = Set.singleton n
nodesD (Dendogram [] _) = Set.empty nodesD (Dendogram [] _) = Set.empty
nodesD (Dendogram s _) = Set.unions $ map nodesD s nodesD (Dendogram s _) = Set.unions $ map nodesD s
deg :: Graph gr => gr a b -> Dendogram -> Int hdeg :: Graph gr => gr a b -> Dendogram -> Int
deg g d = Set.size (neighbors g d) hdeg g d = Set.size (hneighbors g d)
neighbors :: Graph gr => gr a b -> Dendogram -> Set Node hneighbors :: Graph gr => gr a b -> Dendogram -> Set Node
neighbors g d = exclusion inNodes ouNodes hneighbors g d = exclusion inNodes ouNodes
where where
inNodes :: Set Node inNodes :: Set Node
inNodes = nodesD d inNodes = nodesD d
......
...@@ -8,7 +8,6 @@ Stability : experimental ...@@ -8,7 +8,6 @@ Stability : experimental
Portability : POSIX Portability : POSIX
ILouvain: really inductive Graph ILouvain: really inductive Graph
-} -}
module Data.Graph.Clustering.ILouvain module Data.Graph.Clustering.ILouvain
...@@ -25,25 +24,59 @@ import qualified Data.Graph.Clustering.HLouvain as H ...@@ -25,25 +24,59 @@ import qualified Data.Graph.Clustering.HLouvain as H
-- HyperGraph Definition -- HyperGraph Definition
type HyperGraph a b = Gr (Gr () a) b type HyperGraph a b = Gr (Gr () a) b
type HyperContext a b = Context (Gr () a) b type HyperContext a b = Context (Gr () a) b
-- TODO Later (hypothesis still) -- TODO Later (hypothesis still)
-- type StreamGraph a b = Gr a (Gr () b) -- type StreamGraph a b = Gr a (Gr () b)
{-
convergence :: HyperGraph a b -> HyperGraph a b
convergence g = if m - m' > 0.1 then g else g'
where
m = modularity g (hnodes g )
m' = modularity g' (hnodes g')
g' = step g
-}
steps :: HyperGraph a a -> [Node] -> HyperGraph a a
steps g [ ] = g
steps g [_] = g
steps g ns = foldl' (\g1 n -> step' g g1 n $ neighbors g1 n) g ns
step' :: HyperGraph a b
-> HyperGraph a a
-> Node
-> [Node]
-> HyperGraph a a
step' g g' n ns = foldl' (\g1 n' -> step g g1 n n') g' ns
step :: HyperGraph a b
-> HyperGraph a a
-> Node
-> Node
-> HyperGraph a a
step g g' n1 n2 =
if s2 > 0 && s2 > s1
then mv g' [n1] [n2]
else g'
where
s1 = imodularity g [n1]
s2 = imodularity g [n1,n2]
------------------------------------------------------------------------
hnodes :: HyperGraph a b -> Node -> [Node] hnodes :: HyperGraph a b -> Node -> [Node]
hnodes g n = case match n g of hnodes g n = case match n g of
(Nothing, _) -> [] (Nothing, _) -> []
(Just (p, n, l, s), _) -> n : nodes l (Just (p, n, l, s), _) -> n : nodes l
hedges :: HyperGraph a b -> Node -> [Edge] hdeg :: Graph gr => gr a b -> Node -> Maybe Int
hedges = undefined hdeg = undefined
hneighbors :: HyperGraph a b -> Node -> [Node]
hneighbors = undefined
------------------------------------------------------------------------ ------------------------------------------------------------------------
modularity :: HyperGraph a b -> [Node] -> Double -- TODO go depth in HyperGraph (modularity at level/depth)
modularity g ns = H.modularity g (fromList ns) imodularity :: HyperGraph a b -> [Node] -> Double
imodularity g ns = H.modularity g (fromList ns)
------------------------------------------------------------------------ ------------------------------------------------------------------------
-- Spoon Graph -- Spoon Graph
......
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