Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void exploreNeighbours(int r, int c) {
- for(int i = 0; i < 4; i++){
- int rr = r + dr[i];
- int cc = c + dc[i];
- //Skip out of bounds locations
- if(rr < 0 || cc < 0)continue;
- if(rr >= R || cc >= C)continue;
- //Skip visited cells
- if(visited[rr][cc])continue;
- //Skip invalid cells
- if(m[rr][cc] == m[r][c])continue;
- //Add neighbour to queue
- rq.add(rr);
- cq.add(cc);
- //Set neighbour to visited = true and add to next layer
- visited[rr][cc] = true;
- nodes_in_next_layer++;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement