cyclesFor :: (DynGraph g) => GDecomp g a b -> [NGroup]
cyclesFor = map init .
            filter isCycle .
            pathTree .
            first Just
    where
      isCycle p = not (single p) && (head p == last p)

-- -----------------------------------------------------------------------------

{- $chains
   A chain is a path in a graph where for each interior node, there is
   exactly one predecessor and one successor node, i.e. that part of
   the graph forms a \"straight line\".  Furthermore, the initial node
   should have only one successor, and the final node should have only
   one predecessor.  Chains are found by recursively finding the next
   successor in the chain, until either a leaf node is reached or no
   more nodes match the criteria.
-}

-- | Find all chains in the given graph.
cyclesFor :: (DynGraph g) => GDecomp g a b -> [NGroup]
cyclesFor = map init .
            filter isCycle .
            pathTree .
            first Just
    where
      isCycle p = not (single p) && (head p == last p)

-- -----------------------------------------------------------------------------

{- $chains
   A chain is a path in a graph where for each interior node, there is
   exactly one predecessor and one successor node, i.e. that part of
   the graph forms a \"straight line\".  Furthermore, the initial node
   should have only one successor, and the final node should have only
   one predecessor.  Chains are found by recursively finding the next
   successor in the chain, until either a leaf node is reached or no
   more nodes match the criteria.
-}

-- | Find all chains in the given graph.
cyclesFor = map init .
            filter isCycle .
            pathTree .
            first Just
    where
      isCycle p = not (single p) && (head p == last p)

-- -----------------------------------------------------------------------------

{- $chains
   A chain is a path in a graph where for each interior node, there is
   exactly one predecessor and one successor node, i.e. that part of
   the graph forms a \"straight line\".  Furthermore, the initial node
   should have only one successor, and the final node should have only
   one predecessor.  Chains are found by recursively finding the next
   successor in the chain, until either a leaf node is reached or no
   more nodes match the criteria.
-}

-- | Find all chains in the given graph.