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

[:)] almost

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