Skip to content

InvalidOperationException in SdShortestPath #392

@ATrefzer

Description

@ATrefzer

Hello,

In rare cases, I get an InvalidOperationException in SdShortestPath.RouteEdgeWithGroups.
I reduced my failing graph to the following minimum example that reproduces the problem.

// Add code for example to WpfApplicationSample.

var graph = new Graph();
var ds = new Subgraph("DataStructure");
var dds = new Subgraph("DeviceDataStructure");
graph.RootSubgraph.AddSubgraph(ds);
ds.AddSubgraph(dds);
var n = graph.AddNode("CatalogSetToDefaults");
dds.AddNode(n);

graph.AddNode("Contracts");
graph.AddEdge("DeviceDataStructure", "Contracts");
graph.AddEdge("Contracts", "DeviceDataStructure");

graphViewer.Graph = graph;

Callstack where the InvalidOperationException is thrown.


>	Microsoft.Msagl.dll!Microsoft.Msagl.Routing.Spline.Bundling.SdShortestPath.RouteEdgeWithGroups() Line 183	C#
 	Microsoft.Msagl.dll!Microsoft.Msagl.Routing.Spline.Bundling.SdShortestPath.RouteEdge(Microsoft.Msagl.Core.Layout.EdgeGeometry edgeGeometry = {Microsoft.Msagl.Core.Layout.EdgeGeometry}) Line 155	C#
 	Microsoft.Msagl.dll!Microsoft.Msagl.Routing.Spline.Bundling.SdShortestPath.RouteEdges() Line 77	C#
 	Microsoft.Msagl.dll!Microsoft.Msagl.Routing.Spline.Bundling.BundleRouter.RoutePathsWithSteinerDijkstra() Line 233	C#
 	Microsoft.Msagl.dll!Microsoft.Msagl.Routing.Spline.Bundling.BundleRouter.RunInternal() Line 101	C#
 	Microsoft.Msagl.dll!Microsoft.Msagl.Core.AlgorithmBase.Run() Line 17	C#
 	Microsoft.Msagl.dll!Microsoft.Msagl.Routing.MultiEdgeRouter.Run() Line 37	C#
 	Microsoft.Msagl.dll!Microsoft.Msagl.Routing.SplineRouter.RouteMultiEdges(System.Collections.Generic.List<Microsoft.Msagl.Core.Layout.Edge[]> multiEdges = Count = 1, Microsoft.Msagl.Routing.InteractiveEdgeRouter interactiveEdgeRouter = {Microsoft.Msagl.Routing.InteractiveEdgeRouter}, Microsoft.Msagl.Core.DataStructures.Set<Microsoft.Msagl.Routing.Shape> parents = {Microsoft.Msagl.Core.DataStructures.Set<Microsoft.Msagl.Routing.Shape>}) Line 367	C#
 	Microsoft.Msagl.dll!Microsoft.Msagl.Routing.SplineRouter.RouteEdgesWithTheSamePassport(System.Linq.IGrouping<Microsoft.Msagl.Core.DataStructures.Set<Microsoft.Msagl.Routing.Shape>, Microsoft.Msagl.Core.Layout.Edge> edgeGeometryGroup = Key = {Microsoft.Msagl.Core.DataStructures.Set<Microsoft.Msagl.Routing.Shape>}, Microsoft.Msagl.Routing.InteractiveEdgeRouter interactiveEdgeRouter = {Microsoft.Msagl.Routing.InteractiveEdgeRouter}, Microsoft.Msagl.Core.DataStructures.Set<Microsoft.Msagl.Routing.Shape> obstacleShapes = {Microsoft.Msagl.Core.DataStructures.Set<Microsoft.Msagl.Routing.Shape>}) Line 325	C#
 	Microsoft.Msagl.dll!Microsoft.Msagl.Routing.SplineRouter.RouteOnVisGraph() Line 307	C#
 	Microsoft.Msagl.dll!Microsoft.Msagl.Routing.SplineRouter.RouteOnRoot() Line 188	C#
 	Microsoft.Msagl.dll!Microsoft.Msagl.Routing.SplineRouter.RunInternal() Line 171	C#
 	Microsoft.Msagl.dll!Microsoft.Msagl.Core.AlgorithmBase.Run(Microsoft.Msagl.Core.CancelToken cancelToken = {Microsoft.Msagl.Core.CancelToken}) Line 49	C#
 	Microsoft.Msagl.dll!Microsoft.Msagl.Miscellaneous.LayoutHelpers.RouteAndLabelEdges(Microsoft.Msagl.Core.Layout.GeometryGraph geometryGraph = {Microsoft.Msagl.Core.Layout.GeometryGraph}, Microsoft.Msagl.Core.Layout.LayoutAlgorithmSettings layoutSettings = {Microsoft.Msagl.Layout.Layered.SugiyamaLayoutSettings}, System.Collections.Generic.IEnumerable<Microsoft.Msagl.Core.Layout.Edge> edgesToRoute = {Microsoft.Msagl.Core.Layout.Edge[2]}, int straighLineRoutingThreshold = 0, Microsoft.Msagl.Core.CancelToken cancelToken = {Microsoft.Msagl.Core.CancelToken}) Line 222	C#
 	Microsoft.Msagl.dll!Microsoft.Msagl.Miscellaneous.LayoutHelpers.ProcessSugiyamaLayout(Microsoft.Msagl.Core.Layout.GeometryGraph geometryGraph = {Microsoft.Msagl.Core.Layout.GeometryGraph}, Microsoft.Msagl.Layout.Layered.SugiyamaLayoutSettings sugiyamaLayoutSettings = {Microsoft.Msagl.Layout.Layered.SugiyamaLayoutSettings}, Microsoft.Msagl.Core.CancelToken cancelToken = {Microsoft.Msagl.Core.CancelToken}) Line 102	C#
 	Microsoft.Msagl.dll!Microsoft.Msagl.Miscellaneous.LayoutHelpers.CalculateLayout(Microsoft.Msagl.Core.Layout.GeometryGraph geometryGraph = {Microsoft.Msagl.Core.Layout.GeometryGraph}, Microsoft.Msagl.Core.Layout.LayoutAlgorithmSettings settings = {Microsoft.Msagl.Layout.Layered.SugiyamaLayoutSettings}, Microsoft.Msagl.Core.CancelToken cancelToken = {Microsoft.Msagl.Core.CancelToken}, string tileDirectory = null) Line 58	C#
 	Microsoft.Msagl.WpfGraphControl.dll!Microsoft.Msagl.WpfGraphControl.GraphViewer.LayoutGraph() Line 820	C#

As a workaround I can use following setting:
graph.LayoutAlgorithmSettings.EdgeRoutingSettings.EdgeRoutingMode = EdgeRoutingMode.StraightLine;
With this setting the graph is rendered. So I assume it is not a problem with the graph.
Here is the graph rendered with this workaround.

Image

Note there is an older issue from 2016 that seems to be the same problem.
#92

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions