children p [] = []
children p (h:t)
| head h == p = tail h
| otherwise = children p t
extend w g = map ( \q -> q:w ) (children (head w) g)
extend1 w g = foldr (++) []( map (\q->extend q g) w)
sg g = map ( \q-> [ head q ] ) g
extendall 1 g = sg g
extendall k g = rex (k-1) (extend1 (sg g ) g) g
rex 0 w g = w
rex k w g = rex (k-1) (extend1 w g) g
child n [] = []
child n (node:t)
|head(node)==n = tail(node)
|otherwise = child n t
ext w g = map (\p -> p:w) (child (head w) g)
extall wl g = foldr (++) [] (map (\p-> ext p g) wl)
find 1 g p = p
find k g p = find (k-1) g (extall p g)
findall k g = find k g (map (\p->p:[]) (map (\p-> head p) g))
g=[[1,2,3],[2,3],[3,4,5],[4],[5,1,4]]
sq x = x * x
pwr10 = (^) 10
children (h:t) a
|a==head(h) =tail(h)
|otherwise =children t a
extend w g = ext w (children g (head w))
ext w c = map (\l-> l:w) c
extendlist l g= map (\x-> extend x g) l
extendall l g = foldr (++) [] (extendlist l g)
pathk k g = zad3 k (heads g) g
zad3 k p g
|k==1 = p
|otherwise = zad3 (k-1) (extendall p g) g
heads []=[]
heads g = map (\l-> [head l]) g
g=[[1,2,3],[2,3],[3,4,5],[4],[5,1,4]]
children v g = tail (head (filter (\n->head n ==v) g))
extend w g =map (\v->v:w) (children (head w) g)
extendall w g = concat (map (\v->extend v g) w)
allways k g
|k==1 =map (\c->[head c]) g
|otherwise =extendall (allways (k-1) g) g