Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let dfs mat start finish =
- let n = Array.length mat in
- let visited = Array.make n 0 in
- let lista = ref [start] in
- let flague = ref false in
- while (!lista <> [] && !flague <> true)
- do
- let cur= List.hd !lista in
- lista:= List.tl !lista;
- for i = 0 to n-1 do
- if(mat.(cur).(i)=1 && visited.(i)=0) then
- if i=finish then (flague:=true;)
- else
- (visited.(i)<-1;
- lista:=i::!lista;)
- done;
- done;
- !flague
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement