public static KernighanLin processWithVertices(Graph g, Set<Vertex> vertexSet) {
    Graph newG = new Graph();
    
    for (Vertex v : vertexSet) 
      newG.addVertex(v);
    
    for (Edge e : g.getEdges()) {
      Pair<Vertex> endpoints = g.getEndpoints(e);
      
      if (vertexSet.contains(endpoints.first) && 
          vertexSet.contains(endpoints.second))
        newG.addEdge(e, endpoints.first, endpoints.second);
    }
    return process(newG);
  }