| 213 | } |
| 214 | |
| 215 | unsigned long get_neighbor ( |
| 216 | long node_id, |
| 217 | long idx |
| 218 | ) const |
| 219 | { |
| 220 | ++count; |
| 221 | const point& p = get_loc(node_id); |
| 222 | if (rect.contains(p + point(1,0))) |
| 223 | { |
| 224 | if (idx == 0) |
| 225 | return node_id+1; |
| 226 | --idx; |
| 227 | } |
| 228 | |
| 229 | if (rect.contains(p - point(1,0))) |
| 230 | { |
| 231 | if (idx == 0) |
| 232 | return node_id-1; |
| 233 | --idx; |
| 234 | } |
| 235 | |
| 236 | if (rect.contains(p + point(0,1))) |
| 237 | { |
| 238 | if (idx == 0) |
| 239 | return node_id+nc; |
| 240 | --idx; |
| 241 | } |
| 242 | |
| 243 | return node_id-nc; |
| 244 | } |
| 245 | |
| 246 | void set_label ( |
| 247 | const unsigned long& idx, |