@@ -4,6 +4,7 @@
4module Hakyll.Core.DirectedGraph
4module Hakyll.Core.DirectedGraph
5 ( DirectedGraph
5 ( DirectedGraph
7 , neighbours
8 , neighbours
@@ -26,6 +27,13 @@ fromList :: Ord a
26 -> DirectedGraph a -- ^ Resulting directed graph
27 -> DirectedGraph a -- ^ Resulting directed graph
27fromList = DirectedGraph . M.fromList . map (\(t, d) -> (t, Node t d))
28fromList = DirectedGraph . M.fromList . map (\(t, d) -> (t, Node t d))
30+-- | Get all nodes in the graph
33+ => DirectedGraph a -- ^ Graph to get the nodes from
34+ -> Set a -- ^ All nodes in the graph
35+nodes = M.keysSet . unDirectedGraph
29-- | Get a set of reachable neighbours from a directed graph
37-- | Get a set of reachable neighbours from a directed graph
31neighbours :: Ord a
39neighbours :: Ord a
@@ -66,22 +74,3 @@ reachableNodes x graph = reachable (neighbours x graph) (S.singleton x)
66 sanitize = S.filter (`S.notMember` visited)
74 sanitize = S.filter (`S.notMember` visited)
67 neighbours' = S.unions $ map (flip neighbours graph)
75 neighbours' = S.unions $ map (flip neighbours graph)
68 $ S.toList $ sanitize next
76 $ S.toList $ sanitize next
71−exampleGraph :: DirectedGraph Int
72−exampleGraph = fromList
73− [ makeNode 8 [2, 4, 6]
80− makeNode tag deps = (tag, S.fromList deps)
82−cyclic :: DirectedGraph Int
84− [ (1, S.fromList [2])
85− , (2, S.fromList [1, 3])