code: private static int[] insert(int v, int[] vs) {
  
          final int n = vs.length;
          final int[] ws = Arrays.copyOf(vs, n + 1);
          ws[n] = v;
  
          // insert 'u' in to sorted position
          for (int i = n; i > 0 && ws[i] < ws[i - 1]; i--) {
              int tmp = ws[i];
              ws[i] = ws[i - 1];
              ws[i - 1] = tmp;
          }
  
          return ws;
      }
docs: Insert the vertex 'v' into sorted position in the array 'vs'.
  
  @param v  a vertex (int id)
  @param vs array of vertices (int ids)
  @return array with 'u' inserted in sorted order