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

[HyperGraph] merge fun

parent 2e1077dd
......@@ -196,7 +196,8 @@ delta com ki kiin m = DeltaQ $ acc - dec
-- We could avoid the higher complexity, eg. by precomputing the whole graph
-- into a HashMap Node [Edge].
iteration :: FGraph a b -> CGr -> CGr
iteration gr cs = xdfsFoldWith suc' (\(_, v, _, _) -> step gw $ context gr $ v) cs (nodes gr) gr
iteration gr cs = xdfsFoldWith suc' (\(_, v, _, _)
-> step gw $ context gr $ v) cs (nodes gr) gr
where
gw = graphWeight gr
--weightSum = ufold weightSum' 0 gr
......@@ -219,7 +220,8 @@ step gw ctx@(p, v, l, s) cgr = newCgr
else
cgr
(bestFitCom, DeltaQ bestFitdq) = maximumBy (\(_, deltaq1) (_, deltaq2) -> compare deltaq1 deltaq2) deltas
(bestFitCom, DeltaQ bestFitdq) =
maximumBy (\(_, deltaq1) (_, deltaq2) -> compare deltaq1 deltaq2) deltas
mNc :: Maybe (LNode Community)
mNc = nodeCommunity v cgr
......
......@@ -47,7 +47,6 @@ toSupra = undefined
-- 4
-- |
-- 5
spoon :: HyperGraph Double Double
spoon = mkGraph ns es
where
......@@ -80,14 +79,14 @@ spoon = mkGraph ns es
mv :: HyperGraph a a
-> [Node] -> [Node]
-> HyperGraph a a
mv g [] [] = g
mv g [_] [] = g
mv g [] [_] = g
mv g [ ] [ ] = g
mv g [_] [ ] = g
mv g [ ] [_] = g
mv g [a] [b] = mv' g a b
mv g [a,b] [] = undefined
mv g [a] [b] = mv' g a b
mv g [a,b] [ ] = undefined
mv g (x:xs) (y:ys) = panic "mv path too long"
mv g (x:xs) (y:ys) = panic "mv: path too long"
-- | Start simple (without path)
mv' :: HyperGraph a a
......@@ -102,7 +101,7 @@ mvMContext :: Maybe (HyperContext a a)
-> Maybe (HyperContext a a)
-> HyperContext a a
mvMContext (Just (a1 ,n ,l ,a2 ))
(Just (a1',n',l',a2')) = (a1',n',c'&l,a2')
(Just (a1',n',l',a2')) = (a1',n', merge l (c' & l'),a2')
where
c' = (a1, n, (), a2)
......@@ -110,6 +109,10 @@ mvMContext _ (Just _) = panic "First Node does not exist"
mvMContext (Just _) _ = panic "Snd Node does not exist"
mvMContext _ _ = panic "Both Nodes do not exist"
merge :: (Graph gr, DynGraph gr)
=> gr a b -> gr a b -> gr a b
merge = ufold (&)
------------------------------------------------------------------------
-- | 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