Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let bfs mat start finish=
- let n = Array.length mat in
- let q = Queue.create () in
- let visited = Array.make n 0 in
- Queue.add start q;
- let flague = ref false in
- while (Queue.is_empty q <> true && !flague <> true)
- do
- let cur = Queue.take q in
- for i = 0 to n-1
- do
- if ((mat.(cur).(i) = 1)&&visited.(i)=0)
- then
- (if i = finish then (flague:=true;)
- else
- begin
- Queue.add i q;
- visited.(i)<-1;
- end;)
- done;
- done;
- !flague
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement