if(o instanceof Vertex) { g.add((Vertex) o); } else if(o instanceof Edge) { g.add((Vertex) ((Edge) o).getEnds().car()); g.add((Vertex) ((Edge) o).getEnds().cdr()); g.add((Edge) o);
String id = ((GraphElement) o).id(); if(_v.contains(o) || _e.contains(o)) { if(o instanceof Vertex) { vertices.put(id, ((Vertex) o).clone()); } else if(o instanceof Edge) { edges.put(id, o); }  assert(false); } else {  assert(false);
	public Graph subset(Set graphelements) {		// filter for those edges which contain only the vertices we want		DGraph g = new DGraph();		Iterator i = graphelements.iterator();		while(i.hasNext()) {			Object o = i.next();			if(o instanceof Vertex) {				g.add((Vertex) o);			} else if(o instanceof Edge) {				g.add((Vertex) ((Edge) o).getEnds().car());				g.add((Vertex) ((Edge) o).getEnds().cdr());				g.add((Edge) o);			}		}		// add any additional edges for the vertices which were not		// included		i = getEdges().iterator();		while(i.hasNext()) {			Edge e = (Edge) i.next();			if(graphelements.contains(e.getEnds().car()) && graphelements.contains(e.getEnds().cdr())) {				g.add(e);			}		}		return g;	}