C++ vector to dump to graph

Aug 10, 2010 at 6:41 AM
Edited Aug 10, 2010 at 6:42 AM

Hi i'm using visual studio 2008 on a windows 7 x64 machine to create a C++ application that basically brings in 2 main values and a descriptor of their relationship. I have the C++ code dropping the data into a class object node and the relation being saved into a vector. What i am trying to do is take that information from the node and  vector and push it out to the  vertex1, vertex2, label format. I have downloaded the class library and imported the wpf controls to the toolbox, I am not seeing them display nor do I have any options to use them in visual studio. Additionally the help file is not displaying any text when i try to use it. Looking for help mostly just to display the graph either through the template by importing the data or preferably through a UI tool. Your assistance in any way is greatly appreciated!!

Aug 10, 2010 at 7:12 AM
Edited Aug 10, 2010 at 5:01 PM

First, the help file problem is easily fixed.  Here is the note regarding that issue from the class library download page:

"Important Note: You may see nothing but empty topics when you attempt to view the NodeXLApi.chm file. To fix this problem, which is due to a security restriction in Internet Explorer, right-click the chm file in Windows Explorer, select Properties, and click the Unblock button on the General tab."

But if your goal is simply to get your data into an application in which it can be visualized, perhaps you don't even need the help file or the class library it documents.  The NodeXL Excel Template can import data in a variety of formats, and if modify your C++ application to output your edge list to a file in one of those formats, then you can just import that file into a NodeXL workbook, click Show Graph, and see your data in the Template's graph pane.

Are you interested in that sort of approach?  If so, I'll make some suggestions about the format.  Otherwise, tell me what else you need.

-- Tony

Aug 10, 2010 at 7:52 AM

Thank you that fixxed the help file!!

Honestly i would prefer having the graph accessible in the application instead of importing the data to the template BUT at this point that may be the fastest option. If you could help me get it to be reconized in VS2008 for C++ and the data output option both it would be helpful. But the output is the one i need the most since I'm trying to display data and funtionality of the code i already have instead of adding to it.

 

--Paul 

Aug 10, 2010 at 6:00 PM

Paul:

Going from easier to harder, the easiest thing for you to do is to export a tab-delimited text file from your C++ application:

1-a. In your C++ application, create a tab-delimited text file in the format "Vertex1Name\tVertex2Name\tEdgeName".  The EdgeName field is optional.

1-b. Open your tab-delimited file in Excel, which knows how to open such files.

1-c. Create a NodeXL workbook in Excel (Round Office Button, New, My templates, NodeXLGraph.xltx).

1-d. In the NodeXL workbook, select NodeXL, Data, Import, From Open Edge Workbook in the Excel ribbon.  This will let you copy your edge list from the other Excel workbook into the NodeXL workbook.

1-e. In the NodeXL workbook, click Show Graph at the top of the graph pane, which is on the right side of the workbook.

The advantage here is that exporting a tab-delimited text file is trivial, and you don't need the NodeXL class libraries at all.  The disadvantage is the multiple steps required in Excel to show your graph.  But if you have just a few graphs to show, this is the way to go.

Alternatively, to eliminate those multiple steps, you can have your C++ application export a GraphML file, which can be directly imported into a NodeXL workbook.  GraphML is an industry-standard XML format for storing network graph data.  Here is an introduction:

http://graphml.graphdrawing.org/primer/graphml-primer.html

You don't need the NodeXL class libraries to export a GraphML file.  If your C++ application is .NET-based, however, you can use the GraphMLGraphAdapter class in the libraries to do this.  It's documented in the help file.

The steps here are:

2-a. In your C++ application, create a GraphML file containing your edge data.

2-b. Create a NodeXL workbook in Excel (Round Office Button, New, My templates, NodeXLGraph.xltx).

2-c. In the NodeXL workbook, select NodeXL, Data, Import, from GraphML file.

2-d. In the NodeXL workbook, click Show Graph.

Finally, you could skip the NodeXL Excel Template altogether and show a NodeXL graph directly in your application using the NodeXLControl.  However, Visual Studio doesn't make it easy to do this in the designer for C++ applications.  First, NodeXLControl is WPF-based, and there is no project template for a C++ WPF application.  Second, NodeXLControl can be used in a Windows Forms application by hosting it in an ElementHost control (which is documented in the NodeXLControl Class topic in the help file), but Visual Studio won't show the ElementHost in its Toolbox in C++ applications.  There is nothing in the NodeXLControl that would prevent it from being used in a C++ application, but I don't know how to do it from the designer.

It's easy in C# applications, however.  Any chance of your using C# instead of C++?

-- Tony

Aug 24, 2011 at 1:57 PM

I have created a Graf using NodeXL in C#, and I want to display it in Excel, but I don't now how, can someone tell me how?

Thanks you in advance for the reply, and sorry for the inconvenient. 

Aug 24, 2011 at 5:46 PM
Edited Aug 24, 2011 at 5:46 PM

I assume that you've used the NodeXL class libraries or source code to write your own application that creates IGraph objects. and that you now want to export one of those graphs to the NodeXL Excel template.  If that is the case, the best solution is to export the graph from your application to a GraphML file, and then import the GraphML into the NodeXL Excel template.  The steps are as follows:

1. Create a Microsoft.NodeXL.Adapters.GraphMLGraphAdapter object in your application.

2. Call its SaveGraph(IGraph graph, String filename) method to export the graph to a GraphML file.

3. In the NodeXL Excel template, use NodeXL, Data, Import, From GraphML file in the Ribbon to import the GraphML file into the workbook.

-- Tony

Aug 25, 2011 at 10:58 AM

Thanks for the fast replay.

I have encountered upon a nother problem , an error thrown by the NodeXL code, can you pls give me some tips.

Microsoft.NodeXL.Core.Graph.GetRequiredValue: A value with the key "~AllEdgeMetadataKeys" does not exist.
Parameter name: key  

In public void ThrowArgumentException from ArgumentChecker.cs

I didn't now how to Get and Set the "key" of an Vertex or an Edge and I modified the code, when I am using "nod_aux.SetValue(V[i].getKey(), V[i].getValue()); "  SetValue I am setting the Key.

Thanks you in advance for the reply, and sorry for the inconvenient.

Aug 25, 2011 at 5:42 PM

You haven't said much about what you are doing.  Is the following assumption correct?

"I assume that you've used the NodeXL class libraries or source code to write your own application that creates IGraph objects. and that you now want to export one of those graphs to the NodeXL Excel template."

If this is correct, then in which application is the error occurring -- in your own application or in Excel?

If my assumption is not correct, please tell me how you are using NodeXL.  NodeXL is several things -- a precompiled class library, an Excel template, and the source code for everything -- and I can't tell which parts you're using.

-- Tony