stacked-dag 0.1.0.0 → 0.1.0.1
raw patch · 2 files changed
+23/−4 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- src/StackedDag/Base.hs +21/−2
- stacked-dag.cabal +2/−2
src/StackedDag/Base.hs view
@@ -57,6 +57,8 @@ type DepthGroup = M.Map Depth [NodeId] +type NodeDepth = M.Map NodeId Depth+ type DepthGroup' = M.Map Depth ([NodeId],[NodeId]) type DepthGroup'' = M.Map Depth ([(NodeId,Cur,Dest)],[(NodeId,Cur,Dest)])@@ -119,6 +121,10 @@ (n,d):_ -> (n,sort' $ S.fromList $ map snd a): loop ax [] -> loop ax +getNodeDepth :: DepthGroup -> NodeDepth+getNodeDepth dg = M.fromList $ concat $ map (\(d,nodes) -> map (\node -> (node,d)) nodes) $ M.toList dg++ pairs edges = do (p, c) <- M.toList edges child <- S.toList c@@ -294,6 +300,10 @@ -- fromList [(0,([3],[])),(1,([2],[])),(2,([1],[0])),(3,([0],[]))] -- >>> addBypassNode'' 2 edges (M.fromList [(0,([3],[])),(1,([2],[])),(2,([1],[0])),(3,([0],[]))]) -- fromList [(0,([3],[])),(1,([2],[0])),(2,([1],[0])),(3,([0],[]))]+--+-- >>> edges = mkEdges [(0,[1,2]),(1,[4]),(2,[3]),(3,[4])]+-- >>> addBypassNode'' 2 edges (M.fromList [(0,([4],[])),(1,([3,1],[])),(2,([2],[0])),(3,([0],[]))])+-- fromList [(0,([4],[])),(1,([3,1],[])),(2,([2],[0])),(3,([0],[]))] addBypassNode'' :: Depth -> Edges -> DepthGroup' -> DepthGroup' addBypassNode'' d edges dg | d < 2 = error $ "depth " ++ show d ++ " must be greater than 2" | otherwise =@@ -302,10 +312,15 @@ (Just (nids0,skipnids0),Nothing) -> dg (Nothing,_) -> dg where+ nd = getNodeDepth $ getDepthGroup edges+ getDepth :: NodeId -> Depth+ getDepth nid = maybe 0 id $ M.lookup nid nd+ edges' :: Edges+ edges' = M.fromList $ map (\(n,nids) -> (n, S.fromList (filter (\nid -> getDepth nid < d) (S.toList nids)))) $ M.toList edges elem :: NodeId -> [NodeId] -> Bool elem nid nids =- case M.lookup nid edges of- Just m -> all id (map (\n -> L.elem n nids) (S.toList m))+ case M.lookup nid edges' of+ Just m -> all id $ map (\n -> L.elem n nids) $ (S.toList m) Nothing -> True update :: Depth -> [NodeId] -> DepthGroup' -> NodeId -> DepthGroup' update d' nids1 dg' nid0 =@@ -342,6 +357,10 @@ -- >>> dg = getDepthGroup edges -- >>> addBypassNode edges dg -- fromList [(0,([3],[])),(1,([2],[0])),(2,([1],[0])),(3,([0],[]))]+-- >>> edges = mkEdges [(0,[1,2]),(1,[4]),(2,[3]),(3,[4])]+-- >>> dg = getDepthGroup edges+-- >>> addBypassNode edges dg+-- fromList [(0,([4],[])),(1,([3,1],[])),(2,([2],[0])),(3,([0],[]))] addBypassNode :: Edges -> DepthGroup -> DepthGroup' addBypassNode edges dg = addBypassNode' edges $ M.fromList $ map (\(k,v)-> (k,(v,[]))) $ M.toList dg
stacked-dag.cabal view
@@ -2,10 +2,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 57c444b244471ba568f185b245e319dac1300ef668335859a1516b8b2a0bbe7d+-- hash: 2188812bea0c0424ece99cd546a16fcd01cedc61c8eacdac83b90c3447583c5d name: stacked-dag-version: 0.1.0.0+version: 0.1.0.1 synopsis: Ascii DAG(Directed acyclic graph) for visualization of dataflow description: Please see the README on GitHub at <https://github.com/junji.hashimoto/stacked-dag#readme> category: Graphs, Graphics