Commit 9027ce27 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[HyperGraph] functions properties (mv).

parent 2bb0ebb2
...@@ -194,7 +194,7 @@ modularity gr ns = coverage - edgeDensity ...@@ -194,7 +194,7 @@ modularity gr ns = coverage - edgeDensity
coverage = sizeSubGraph / sizeAllGraph coverage = sizeSubGraph / sizeAllGraph
where where
sizeSubGraph :: Double sizeSubGraph :: Double
sizeSubGraph = fromIntegral ( G.size $ subgraph ns gr ) sizeSubGraph = fromIntegral ( G.size $ subgraph' ns gr )
sizeAllGraph :: Double sizeAllGraph :: Double
sizeAllGraph = fromIntegral (G.size gr) sizeAllGraph = fromIntegral (G.size gr)
...@@ -208,8 +208,8 @@ modularity gr ns = coverage - edgeDensity ...@@ -208,8 +208,8 @@ modularity gr ns = coverage - edgeDensity
links :: Double links :: Double
links = fromIntegral (2 * (G.size gr)) links = fromIntegral (2 * (G.size gr))
subgraph :: DynGraph gr => Set Node -> gr a b -> gr a b subgraph' :: DynGraph gr => Set Node -> gr a b -> gr a b
subgraph ns = G.subgraph (Set.toList ns) subgraph' ns = G.subgraph (Set.toList ns)
exclusion :: Ord a => Set a -> Set a -> Set a exclusion :: Ord a => Set a -> Set a -> Set a
exclusion a b = (Set.\\) b a exclusion a b = (Set.\\) b a
......
...@@ -27,7 +27,10 @@ import Data.Graph.Inductive ...@@ -27,7 +27,10 @@ import Data.Graph.Inductive
------------------------------------------------------------------------ ------------------------------------------------------------------------
-- 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
-- TODO Later (hypothesis still)
-- type StreamGraph a b = Gr a (Gr () b)
------------------------------------------------------------------------ ------------------------------------------------------------------------
-- Spoon Graph -- Spoon Graph
-- 1 -- 1
...@@ -52,12 +55,45 @@ spoon = mkGraph ns es ...@@ -52,12 +55,45 @@ spoon = mkGraph ns es
, (4, 5, 1.0) , (4, 5, 1.0)
] ]
-- | Work in progress: -- | Needed functions (WIP)
mvNode :: HyperGraph a a -> Node -> Node -> HyperGraph a a -- mv: a Node elsewhere in the HyperGraph
mvNode g n1 n2 = buildGr $ catMaybes [c1, c2]
-- Move Properties:
-- mv Node into another Node and remove it again should be equal to
-- identity
-- property test:
-- mv (mv g [a] [b]) [b,a] [] = identity
-- mv g [a] [] == g
-- mv g [a,b] [] /= g
-- mv (mv spoon [1] [4]) [4,1] [] = identity
-- Move target type
mv' :: HyperGraph a a
-> [Node] -> [Node]
-> HyperGraph a a
mv' g [] [] = g
mv' g [_] [] = g
mv' g (x:xs) [] = undefined
-- | Start simple (without path)
mv :: HyperGraph a a
-> Node -> Node
-> HyperGraph a a
mv g n1 n2 = delNode n1 g
-- buildGr $ catMaybes [c1, c2]
where where
(c1, g1) = match n1 g (c1, g1) = match n1 g
(c2, g2) = match n2 g1
{-
insertContext :: HyperContext a b
-> HyperContext a b
-> HyperContext a b
insertContext (a1,n,l,a2) (a1',n',l',a2') = (a1,n,l&l',a2)
--}
------------------------------------------------------------------------ ------------------------------------------------------------------------
-- | Recursive Node of Graph -- | Recursive Node of 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