| 181 | } |
| 182 | |
| 183 | unsigned long get_neighbor_idx ( |
| 184 | long node_id1, |
| 185 | long node_id2 |
| 186 | ) const |
| 187 | { |
| 188 | ++count; |
| 189 | const point& p = get_loc(node_id1); |
| 190 | long ret = 0; |
| 191 | if (rect.contains(p + point(1,0))) |
| 192 | { |
| 193 | if (node_id2-node_id1 == 1) |
| 194 | return ret; |
| 195 | ++ret; |
| 196 | } |
| 197 | |
| 198 | if (rect.contains(p - point(1,0))) |
| 199 | { |
| 200 | if (node_id2-node_id1 == -1) |
| 201 | return ret; |
| 202 | ++ret; |
| 203 | } |
| 204 | |
| 205 | if (rect.contains(p + point(0,1))) |
| 206 | { |
| 207 | if (node_id2-node_id1 == nc) |
| 208 | return ret; |
| 209 | ++ret; |
| 210 | } |
| 211 | |
| 212 | return ret; |
| 213 | } |
| 214 | |
| 215 | unsigned long get_neighbor ( |
| 216 | long node_id, |