0

Is there a way to route only edges in existing layout with MSAGL?

I have a GeometryGraph object with layout generated using LayeredLayout and I want to remove/add edges without running the layout algorithm again (this operation makes drastic changes to node positions and is confusing to end user).

Can I somehow simply run layout again with all node positions fixed?

4

2 回答 2

0

您需要InteractiveEdgeRouter与图表保持同步:

edgeRouter_ = new InteractiveEdgeRouter(Graph.Nodes.Select(n => n.BoundaryCurve), 3, 0.65 * 3, 0);

图形布局的每次重新计算也应该调用edgeRouter_.Run()以使其与障碍物变化保持同步(您也应该添加新节点)。

添加新边缘后,无需再次计算布局,而是使用路由器手动设置边缘曲线:

 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);

         }
     }
}
于 2015-11-02T08:52:29.570 回答
0

使用可以使用LayoutHelpers.RouteAndLabelEdges

LayoutAlgorithmSettings settings = new MdsLayoutSettings();
RouteAndLabelEdges(geometryGraph, settings, geometryGraph.Edges);

它比 ghord 的解决方案更短,但需要更多的计算。

于 2017-05-29T12:47:26.493 回答