if (source == null || target == null) {
throw new NullPointerException();
}
AbstractNode nodeSource = (AbstractNode) source;
AbstractNode nodeTarget = (AbstractNode) target;
AbstractEdge edge;
if (source == target) {
edge = new SelfLoopImpl(idGen.newEdgeId(), nodeSource);
} else {
edge = new MixedEdgeImpl(idGen.newEdgeId(), nodeSource, nodeTarget, directed);
}
edge.setAttributes(newEdgeAttributes(edge.getEdgeData()));
edge.setWeight(weight);
edge.getEdgeData().setTextData(newTextData());
if (id != null) {
edge.getEdgeData().setId(id);
} else {
edge.getEdgeData().setId("" + edge.getId());
}
return edge;
}