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

[Path] dir && undir (to test)

parent bca1ac4b
...@@ -38,24 +38,40 @@ data RGraph = Empty | Gr RGraph Double ...@@ -38,24 +38,40 @@ data RGraph = Empty | Gr RGraph Double
-- | -- |
-- 5 -- 5
ns :: [LNode RGraph] spoon :: Gr RGraph Double
ns = zip [1..6] (cycle [Empty]) spoon = mkGraph ns es
where
ns :: [LNode RGraph]
ns = zip [1..6] (cycle [Empty])
es :: [LEdge Double] es :: [LEdge Double]
es = [ (1, 2, 1.0) es = [ (1, 2, 1.0)
, (1, 3, 1.0) , (1, 3, 1.0)
, (2, 4, 1.0) , (2, 4, 1.0)
, (3, 4, 1.0) , (3, 4, 1.0)
, (4, 5, 1.0) , (4, 5, 1.0)
] ]
------------------------------------------------------------------------
-- Paths in the Graph to be tested
-- Directed graph strategy
path_dir :: Graph gr => gr a b -> [[Node]]
path_dir g = map (\xs -> dfs xs g ) (components g)
spoon :: Gr RGraph Double -- UnDirected graph strategy
spoon = mkGraph ns es path :: (DynGraph gr, Eq b) => gr a b -> [[Node]]
path g' = map sortNodes cs
where
sortNodes ns = case head $ sortOn (Down . (deg g)) ns of
Nothing -> []
Just n -> dfs [n] g -- dfs for glustering, bfs for klustering
cs = components g
g = undir g'
------------------------------------------------------------------------ ------------------------------------------------------------------------
-- Path in the Graph
path :: Graph gr => gr a b -> [[Node]]
path g = map (\xs -> dfs xs g ) (components g)
------------------------------------------------------------------------ ------------------------------------------------------------------------
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