Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fun odwiedz (i,odw,v, l) =
- let fun g [] = [] | g (h::t) = (odwiedz (h,odw,v,l); g t) in
- if (Array.sub (odw,i)) = 0 then
- (
- Array.update (odw,i,1);
- l := i::(!l);
- g (Vector.sub (v,i));
- []
- )
- else []
- end
- fun dfs x =
- let val v = Vector.fromList x and i = ref 0 and n = length x and l = ref [] and odw = Array.array (length x, 0)
- in
- while !i <> n do
- (
- odwiedz (!i,odw,v, l);
- i := !i + 1
- );
- rev (!l)
- end
Add Comment
Please, Sign In to add comment