code: public SparseDirectedEdgeSet copy(IntSet vertices) {        
          SparseDirectedEdgeSet copy = new SparseDirectedEdgeSet(rootVertex);
          if (vertices.size() < inEdges.size()
                  && vertices.size() < outEdges.size()) {
  
              IntIterator iter = vertices.iterator();
              while (iter.hasNext()) {
                  int v = iter.nextInt();
                  if (inEdges.contains(v)) 
                      copy.inEdges.add(v);
                  if (outEdges.contains(v)) 
                      copy.inEdges.add(v);
              }            
          }
          else {
              IntIterator iter = inEdges.iterator();
              while (iter.hasNext()) {
                  int v = iter.nextInt();
                  if (vertices.contains(v))
                      copy.inEdges.add(v);
              }
              iter = outEdges.iterator();
              while (iter.hasNext()) {
                  int v = iter.nextInt();
                  if (vertices.contains(v))
                      copy.outEdges.add(v);
              }
          }
          return copy;
      }
docs: {@inheritDoc}