public E addEdge(V vertex, V targetVertex, Object... attributes) { final VertexInfo<V, E> info = vertexMap.get(vertex); if (info == null) { throw new IllegalArgumentException("no vertex " + vertex); } final VertexInfo<V, E> info2 = vertexMap.get(targetVertex); if (info2 == null) { throw new IllegalArgumentException("no vertex " + targetVertex); } @SuppressWarnings("unchecked") final AttributedEdgeFactory<V, E> f = (AttributedEdgeFactory) this.edgeFactory; final E edge = f.createEdge(vertex, targetVertex, attributes); if (edges.add(edge)) { info.outEdges.add(edge); return edge; } else { return null; } }