// at this point edgeId is not in use and both src and dst are not null
edge = edgeFactory.newInstance(edgeId, src, dst, directed);
// see if the endpoints accept the edge
if (!src.addEdgeCallback(edge)) {
if (strictChecking)
throw new EdgeRejectedException("Edge " + edge
+ " was rejected by node " + src);
return null;
}
// note that for loop edges the callback is called only once
if (src != dst && !dst.addEdgeCallback(edge)) {
// the edge is accepted by src but rejected by dst
// so we have to remove it from src
src.removeEdgeCallback(edge);
if (strictChecking)
throw new EdgeRejectedException("Edge " + edge
+ " was rejected by node " + dst);
return null;
}
// now we can finally add it