private void paintEdge(int edgeID, int replaceID) {
    final Batch <Coord> toPaint = new Batch <Coord> () ;
    for (Coord c : Visit.grid(0, 0, mapSize, mapSize, 1)) {
      final int h = typeIndex[c.x][c.y] ;
      if (h != edgeID) continue ;
      boolean inside = true ;
      for (int i : N_INDEX) {
        try {
          final int n = typeIndex[c.x + N_X[i]][c.y + N_Y[i]] ;
          if (n != edgeID && n != replaceID) { inside = false ; break ; }
        }
        catch (Exception e) { continue ; }
      }
      if (! inside) toPaint.add(new Coord(c)) ;
    }
    for (Coord c : toPaint) {
      typeIndex[c.x][c.y] = (byte) replaceID ;
    }
  }