blob: 9bf42d8115cd408229c18383c94d8fea47241687 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
|
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)
|