how to dynamically update a map?

Dec 19, 2012 at 4:52 AM

  I'm drawing a diagram by using NodeXL, there are thousands of vertex in this diagram, I find it will experience a very long time until the picture appears. I use C# windows form, so, if I use WPF, can it's speed be faster? Another problem, I want to add a vertex or an edge in this diagram with thousands, in Form_Load event I wrote:

vertexCollection = nodexl.Graph.Vertices;
edgeCollection = nodexl.Graph.Edges;

  In buttonAddVertex_click event I wrote:

vertex = vertexCollection.Add();
vertex.SetValue(ReservedMetadataKeys.PerColor, Color.Red);

  I find Nodexl begin to redraw, I still have to wait for a long time, how should I godynamically update the diagram, only update this vertex ,not the whole diagram?

  Thanks a lot!

Dec 19, 2012 at 7:24 AM


Adding a vertex to a graph that has thousands of vertices is always going to be slow, because the graph has to be laid out again before it can be drawn, and the force-based layout algorithms take a long time with that many objects.  And the drawing phase is slow, too, as you've discovered.  WPF is, unfortunately, much slower than the old GDI+ when there are many objects to be drawn.  I've tried to speed up the drawing code as much as possible, mainly by freezing everything that can be frozen in WPF, but it's still slow.

If you are wondering whether making your application WPF-based instead of Windows-Forms-base will help, I'm afraid it won't.  It's probably not your application code that's slow; it's the layout algorithm and the WPF drawing code in the NodeXLControl that's slowing you down.

-- Tony

Dec 20, 2012 at 4:31 AM

when the layout is complete, NodeXl shows the entire diagram, coule I add a vertex on the basis of the current completed diagram without redrawing the whole diagram?

Dec 20, 2012 at 7:46 AM


To skip the layout phase, you can add the vertex and then call NodeXLControl.DrawGraph(false). That prevents NodeXL from laying out the graph before drawing it.  However, you will have to set the vertex's coordinates yourself, using the Vertex.Location property, before adding the vertex to the graph.  That's what the layout phase normally does for you.  Also, the entire graph is still going to be redrawn again, so you still might not get the performance you want.

-- Tony

Dec 20, 2012 at 10:54 AM

Thank you dear tcap479 :)