Is there a way to specify the position of a node in the graph? For example:
Graph graph = graphViewer.Graph;
graph.AddNode("2");
Microsoft.Msagl.Core.Geometry.Point position = (199,991);
graph.FindNode("2").GeometryNode.Center = position;
graphViewer.Graph = graph;
I'm using the WpfApplicationSample from the msagl.
The code doesn't change the position of the point. Up to the "graphViewer.Graph = graph;" graph still has the changed node("2") position, but after the last command, both graph and graphViewer.Graph change the node's position to the original. Any tips how to solve this?
By running Graph graph = graphViewer.Graph;
the layout algorithm is called and therefore, the node positions and edges are calculated again by the selected layout algorithm. One can take over the pre-calculation of the layout by graphViewer.NeedToCalculateLayout = false;
before the Graph graph = graphViewer.Graph;
. Which then ensures that the previously modified geometry will remain after the assignment.
The MSAGL Author has helped me with this answer.