You need to keep InteractiveEdgeRouter
in sync with your graph:
edgeRouter_ = new InteractiveEdgeRouter(Graph.Nodes.Select(n => n.BoundaryCurve), 3, 0.65 * 3, 0);
Every recalc of graph layout should also call edgeRouter_.Run()
to keep it in sync with obstacle changes (you should add new nodes as well).
After you added new edge, instead of calculating layout again, set the edge curve manually using the router:
private void RouteMissingEdges()
{
foreach (var edge in Graph.Edges)
{
if (edge.Curve == null)
{
SmoothedPolyline ignore;
edge.Curve = edgeRouter_.RouteSplineFromPortToPortWhenTheWholeGraphIsReady(
new FloatingPort(edge.Source.BoundaryCurve, edge.Source.Center),
new FloatingPort(edge.Target.BoundaryCurve, edge.Target.Center),
true, out ignore);
Arrowheads.TrimSplineAndCalculateArrowheads(edge.EdgeGeometry,
edge.Source.BoundaryCurve,
edge.Target.BoundaryCurve,
edge.Curve, true,
false);
}
}
}