/** * Returns a shallow copy of this graph instance. Neither edges nor vertices are cloned. * * @return a shallow copy of this set. * @throws RuntimeException * @see java.lang.Object#clone() */ public Object clone() { try { TypeUtil<AbstractBaseGraph<V, E>> typeDecl = null; AbstractBaseGraph<V, E> newGraph = TypeUtil.uncheckedCast(super.clone(), typeDecl); newGraph.edgeMap = new LinkedHashMap<E, IntrusiveEdge>(); newGraph.edgeFactory = this.edgeFactory; newGraph.unmodifiableEdgeSet = null; newGraph.unmodifiableVertexSet = null; // NOTE: it's important for this to happen in an object // method so that the new inner class instance gets associated with // the right outer class instance newGraph.specifics = newGraph.createSpecifics(); Graphs.addGraph(newGraph, this); return newGraph; } catch (CloneNotSupportedException e) { e.printStackTrace(); throw new RuntimeException(); } }
/** @see Graph#getEdgeTarget(Object) */ public V getEdgeTarget(E e) { return TypeUtil.uncheckedCast(getIntrusiveEdge(e).target, vertexTypeDecl); }
/** @see Graph#getEdgeSource(Object) */ public V getEdgeSource(E e) { return TypeUtil.uncheckedCast(getIntrusiveEdge(e).source, vertexTypeDecl); }