Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int sendFishes(int start) {
- LinkedQueue<Integer> pom = new LinkedQueue<Integer>();
- int count = 0;
- boolean checked[] = new boolean[num_nodes];
- for (int i = 0; i < checked.length; i++) {
- checked[i] = false;
- }
- pom.enqueue(start);
- checked[start] = true;
- while (!pom.isEmpty()) {
- int tmp = pom.dequeue();
- count++;
- for (int i = 0; i < num_nodes; i++) {
- if (adjMat[tmp][i] == 1) {
- if (!checked[i]) {
- pom.enqueue(i);
- checked[i] = true;
- }
- }
- }
- }
- return count-1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement