public Edge addEdge(final Object id, final Vertex outVertex, final Vertex inVertex, final String label) { if (label == null) throw ExceptionFactory.edgeLabelCanNotBeNull(); String idString = null; Edge edge; if (null != id) { idString = id.toString(); edge = this.edges.get(idString); if (null != edge) { throw ExceptionFactory.edgeWithIdAlreadyExist(id); } } else { boolean done = false; while (!done) { idString = this.getNextId(); edge = this.edges.get(idString); if (null == edge) done = true; } } edge = new TinkerEdge(idString, outVertex, inVertex, label, this); this.edges.put(edge.getId().toString(), edge); final TinkerVertex out = (TinkerVertex) outVertex; final TinkerVertex in = (TinkerVertex) inVertex; out.addOutEdge(label, edge); in.addInEdge(label, edge); return edge; }