Commit 94be2a54 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[ILouvain] some functions (hnodes, modularity)

parent a268fd35
......@@ -14,25 +14,37 @@ ILouvain: really inductive Graph
module Data.Graph.Clustering.ILouvain
where
import Data.Set (fromList)
import Data.Maybe (catMaybes)
import Data.List (zip, cycle)
import Protolude hiding (empty, (&))
import Data.Graph.Inductive
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)
toInfra :: Gr (Gr () a) b -> Gr () a
toInfra = undefined
toSupra :: Gr () a -> Gr (Gr () a) b
toSupra = undefined
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
------------------------------------------------------------------------
modularity :: HyperGraph a b -> [Node] -> Double
modularity g ns = H.modularity g (fromList ns)
-- TODO Later (hypothesis still)
-- type StreamGraph a b = Gr a (Gr () b)
------------------------------------------------------------------------
-- Spoon Graph
-- 1
......@@ -79,7 +91,7 @@ mv g [_] [ ] = g
mv g [ ] [_] = g
mv g [a] [b] = case a == b of
True -> panic "mv: same nodes, impossible mv"
True -> panic "mv, impossible: moved node is same as destination"
False -> mv' g a b
mv g [a,b] [ ] = case match a g of
(Nothing, _) -> panic "mv: fst Node of Path does not exist"
......
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