Large Graph With Around 75k Nodes And Edges Not Drawing The Graph

Jan 10, 2013 at 12:57 PM
Edited Jan 11, 2013 at 5:11 AM


I have been using NodeXLControl library in window application (c#).

We have very large dataset to be handle for drawing graph.

Following is the code we are using for drawing the graph


  foreach (string Contact in Unique_Contacts)
                    IVertex verMainGraph = Overtices.Add();
                    verMainGraph.Name = Contact;
                    verMainGraph.SetValue(ReservedMetadataKeys.PerVertexLabel, Contact);
                    verMainGraph.SetValue(ReservedMetadataKeys.PerVertexToolTip, Contact);
                    verMainGraph.SetValue(ReservedMetadataKeys.Visibility, VisibilityKeyValue.Visible);

foreach (var Counts in CallCount)
                    IVertex EdgeVer1;
                    IVertex EdgeVer2;
                    nodeXLControl1.Graph.Vertices.Find(Counts.caller1.ToString(), out EdgeVer1);
                    nodeXLControl1.Graph.Vertices.Find(Counts.caller2.ToString(), out EdgeVer2);                     
                    IEdge edgeMainGraph = OEdges.Add(EdgeVer1, EdgeVer2);
                    edgeMainGraph.Name = Counts.count.ToString();
                    edgeMainGraph.SetValue(ReservedMetadataKeys.PerEdgeLabel, Counts.count.ToString());
                    edgeMainGraph.SetValue(ReservedMetadataKeys.PerEdgeLabelFontSize, 12F);                    
                    edgeMainGraph.SetValue(ReservedMetadataKeys.Visibility, VisibilityKeyValue.Visible);                    
                    edgeMainGraph.SetValue("MinDate", Counts.min);
                    edgeMainGraph.SetValue("MaxDate", Counts.max);
                    edgeMainGraph.SetValue("MinTime",Convert.ToDateTime("2012-01-01 " + Counts.minTime));
                    edgeMainGraph.SetValue("MaxTime", "2012-01-01 " + Counts.maxTime);
                    edgeMainGraph.SetValue("HideByDegree", "False");                  


Here we have following parameters

Total Vertices to be add = 87000 approx

Total Edges to be add = 75000 approx.

Now we are not drawing the graph at this level.

We are calling another function GetSubgraph which gives the subgraph vertices and edges to be drawn finally like this


public void GetSubGraph(string Vertex, string Level)
                IVertex SubGraphVertex = null;
                nodeXLControl1.Graph.Vertices.Find(Vertex, out SubGraphVertex);
                SubGraphVertex.SetValue(ReservedMetadataKeys.PerVertexShape, VertexShape.SolidTaperedDiamond);
                SubGraphVertex.SetValue(ReservedMetadataKeys.PerVertexRadius, 15F);
                Dictionary<IVertex, int> SubGraphVertices = new Dictionary<IVertex, int>();
                HashSet<IEdge> SubGraphEdges = new HashSet<IEdge>();
                SubgraphCalculator.GetSubgraph(SubGraphVertex, Convert.ToDecimal(Level), true, out SubGraphVertices, out SubGraphEdges);
                IVertexCollection SubGraphvercol = nodeXLControl1.Graph.Vertices;
                IEdgeCollection SubGraphedcol = nodeXLControl1.Graph.Edges;
                foreach (KeyValuePair<IVertex, int> pair in SubGraphVertices)
                foreach (IEdge edge in SubGraphEdges)
            catch(Exception ex)




 Here the parameters are

Total vertices that added are - 12000  approx

Total edges that added are - 15000 approx


After execution of NodeXLControl1.DrawGraph(true);

The process goes for endless execution.



My System configuration is 

Intel Pentium Dual CPU

E2140 @ 1.60GHZ



What could be the issue.

Does NodeXLControl does not handle such a large dataset ??

Jan 11, 2013 at 5:42 AM
Edited Jan 11, 2013 at 5:43 AM


First, I assume that you tested your code with a smaller dataset and that it worked, so you know there are no fundamental bugs in your code.

Second, I note that you are calling VertexCollection.Find() twice for each edge.  Find() is an O(n) operation, so those calls are going to take forever.  (Our own ExcelTemplate application uses a Dictionary while populating the graph to avoid such repeated linear searches.)

Third, I see that you are using a CPU that is almost six years old, and you probably have an ancient graphics card, too.  You deserve better, and NodeXL needs more.  Have you tried running your program on a recently purchased computer?  See if that makes enough of a difference in performance.  (Note that NodeXL uses Windows Presentation Foundation, which falls back on the CPU for graphics operations if a modern GPU isn't present.  And if your CPU is slow, that's a double-whammy of a performance hit.)

Finally, even with a modern CPU and GPU, 12,000 vertices with 15,000 edges is pushing things for NodeXL, which was designed for graphs with a few thousand vertices and edges.  I don't know if you're going to be satisfied with its performance even on a fast computer, but it's at least worth trying.

-- Tony

Jan 11, 2013 at 6:42 AM
Edited Jan 11, 2013 at 6:43 AM

Thanks Tony For your suggestions.

I have tried removing 

  nodeXLControl1.Graph.Vertices.Find(Counts.caller1.ToString(), out EdgeVer1);
  nodeXLControl1.Graph.Vertices.Find(Counts.caller2.ToString(), out EdgeVer2); 

This two lines from code and manage a dictionory instead to get vertex from graph.
It significantly improve the performance of that particular loop that adding edges 
to graph approx 2 minutes to 3 seconds as of now.

But it still takes around 9-10 Minutes to DrawGraph.

Jan 11, 2013 at 8:43 AM


Does NodeXLControl.DrawGraph(true) gives any progess information ?

So that we can put in progressbar to let the user  know that something is loaded in application.

Jan 11, 2013 at 4:52 PM


No, it doesn't.  It's theoretically possible to monitor the progress of the layout phase, which is performed by one of NodeXL's layout classes, but then NodeXL passes the laid-out graph to Windows Presentation Foundation, which performs the actual drawing on a background worker thread.  WPF provides no feedback at all.

-- Tony