Help with NodeXL in c++ app

Jul 21, 2010 at 7:57 PM
I've read the documentation from the api.chm file in the libraries download, but I can't really get an understanding of how to use this in my c++ app. Is there any c++ sample code I can look at and pick apart? I've searched and searched and just can't find anything to help me. The documentation doesn't really explain it like I need it to.
Jul 21, 2010 at 8:16 PM
Edited Jul 21, 2010 at 8:17 PM

As I mentioned in a previous post, you have to provide more details about what it is you want to do.  I do not know what you mean by a "C++ app."  Is this a .NET C++/CLI application, or an MFC application, or an application that uses raw Win32 calls, or something else?  Does it have a graphical UI in which you want to display a graph, or is it a console application from which you want to generate graph image files?  Or something else?

Briefly, the NodeXLControl is WPF-based and is meant for use in WPF, Windows Forms, and other .NET applications, although there are ways to use it in non-.NET applications.  But I can't answer your question without having more information.

-- Tony

Jul 21, 2010 at 9:38 PM
I am creating an app that will use NodeXL for the graphing utility for the application described below: What is provided • A text file that contains rows of records. • In each row, a number of strings and numbers are separated with commas and semicolons. • A row consists of 4 components, and each pair of components is separated with a semicolon. • The first and second components are single or multi-term strings. A single term component is a name of one protein, e.g., erbb2. A multi-term component consists of more than one protein name, e.g., erbb2 gn3. • Comma is used to separate two protein names within one component. • An example record reads as follows: erbb2; gn3; 32; 26 • The number of rows in a file is unknown. What is expected • A graphical user interface, preferably web interface, is created to illustrate a sub-graph produced from the records. • User has to specify one keyword, i.e., one protein name. This keyword is the starting point of constructing the sub-graph. • The user can specify the range of the numbers and the records that have the numbers out of the range are not used in the sub-graph. • The two strings in one record are depicted with two nodes and a line segment connects them. The two numbers are displayed close to the line. For example: … Protein A; Protein B; 21; 0.8 Protein A; Protein C; 40; 0.6 Protein A; Protein E; 99; 0.3 Protein C; Protein F; 60; 0.7 Protein B; Protein E; 28; 0.3 Protein D; Protein F; 66; 0.6 Protein C; Protein E; 56; 0.8 … I just need to know how to use C++ with NodeXL to graph the relationships.
Jul 22, 2010 at 5:36 PM
Edited Jul 22, 2010 at 5:56 PM

Because NodeXL is .NET-based, the easiest way to use it with C++ is to write your application in C++/CLI, the Microsoft version of C++ that plays nicely in the .NET environment. You can create a C++/CLI ASP.NET Web application that uses our NodeXLVisual component, which renders a graph as a WPF Visual object that can be displayed on a Web page. The NodeXLVisual Class topic in the NodeXLApi.chm help file gives a complete example of just that: using the component to write a graph image to an ASP.NET Web page. The example is in C#, however, and I do not have any sample code for C++/CLI.  But if I did, it would look an awful lot like the C# code, with minor syntax changes.

As indicated in the example, you add an edge to a NodeXL graph by first adding its vertices to a vertex collection, and then adding an edge that uses the vertices to an edge collection:

IVertex oVertexA = oVertices.Add();
IVertex oVertexB = oVertices.Add();
IEdge oEdge1 = oEdges.Add(oVertexA, oVertexB, true);

Exactly which vertices and edges you add is entirely up to your application, which I imagine would have some sort of code to parse your text file, filter it according to a specified keyword and range, and generate vertices and edges from it.

-- Tony