microsoft / automatic-graph-layout

A set of tools for graph layout and viewing
Other
1.34k stars 301 forks source link

NullReferenceException when calling RemoveNode on graph without GeometryGraph #335

Open HannesFranke-smartoptics opened 1 year ago

HannesFranke-smartoptics commented 1 year ago

The following code will throw a NullReferenceException:

var graph = new Microsoft.Msagl.Drawing.Graph("graph");
var node = new Microsoft.Msagl.Drawing.Node("node");
graph.AddNode(node);
graph.RemoveNode(node);

Because without having displayed the graph https://github.com/microsoft/automatic-graph-layout/blob/ee9232bc292252fe897acb53d85b8ededadae768/GraphLayout/Drawing/Graph.cs#L300

            GeometryGraph.Nodes.Remove(node.GeometryObject as Core.Layout.Node);

GeometryGraph is null.