ElementHelper.validateLabel(label);
ElementHelper.legalPropertyKeyValueArray(keyValues);
Object idValue = ElementHelper.getIdValue(keyValues).orElse(null);
final Edge edge;
if (null != idValue) {
if (graph.edges.containsKey(idValue))
throw Graph.Exceptions.edgeWithIdAlreadyExists(idValue);
} else {
idValue = TinkerHelper.getNextId(graph);
}
edge = new TinkerEdge(idValue, outVertex, label, inVertex, graph);
ElementHelper.attachProperties(edge, keyValues);
graph.edges.put(edge.id(), edge);
TinkerHelper.addOutEdge(outVertex, label, edge);
TinkerHelper.addInEdge(inVertex, label, edge);
return edge;
}