blob: 9bf42d8115cd408229c18383c94d8fea47241687 (
plain) (
tree)
|
|
import Data.List (partition)
paths :: Eq a => a -> a -> [(a, a)] -> [[a]]
paths s t edges = map reverse $ paths' s edges [s]
where
paths' u edges path
| u == t = [path]
| otherwise =
do let (vs, edges') = partition ((== u) . fst) edges
(_, v) <- vs
paths' v edges' (v:path)
|