public static Vector<Integer> SLOrestricted(GraphModel g, Vector<Integer> V) {
    List<Pair<Integer, Integer>> VertexDegree = new Vector<>();
    Vector<Integer> Ordering = new Vector<>();

    //Compute N_2-degree for all vertices in V
    for (int v : V) {
      VertexDegree.add(new Pair<>(v, Neighbors.N_2_restricted(g, v).size()));
    }

    for (int i = 0; i < V.size(); i++) {
      int min = g.getEdgesCount() + 1;
      int minInd = g.getEdgesCount() + 1;
      for (int j = 0; j < VertexDegree.size(); j++) {
        if (min > VertexDegree.get(j).second) {
          minInd = j;
          min = VertexDegree.get(j).second;
        }
      }

      Pair<Integer, Integer> p = VertexDegree.get(minInd);
      p.second = g.getEdgesCount();
      VertexDegree.set(i, p);
      Ordering.add(p.first);

      //decrement degree of D_2-neighbors
      Vector<Integer> ns = Neighbors.N_2_restricted(g, p.first);
      for (int n2 : ns) {
        if (n2 >= V.size()) {
          if (VertexDegree.get(n2 - V.size()).second != -1) {
            Pair<Integer, Integer> tmp = VertexDegree.get(n2 - V.size());
            tmp.second--;
            VertexDegree.set(n2 - V.size(), tmp);
          }
        } else {
          if (VertexDegree.get(n2).second != -1) {
            Pair<Integer, Integer> tmp = VertexDegree.get(n2);
            tmp.second++;
            VertexDegree.set(n2, tmp);
          }
        }
      }

      if (i % 100 == 0) {
        System.out.println("i=" + i);
      }
    }

    Collections.reverse(VertexDegree);
    return Ordering;
  }