Weighted Graph

Jun 30, 2010 at 6:49 PM
Edited Jun 30, 2010 at 7:41 PM
Hey, I was trying to find out if there is a way in NodeXL API which generates a weighted graph( giving weights to the edges). That is when file containing only (vertex1 Vertex2) info loaded into the NodeXL API , API generates a weighted undirected or weighted directed graph from it. Though I see from the standalone application that we ca get degree, in-degree , out- degree etc. Can we get weights for the edges as well. I mean some methods in API to be called to get the edge weights,in-degree, out-degree. Thanks for the help in advance.
Jun 30, 2010 at 9:03 PM
Edited Jun 30, 2010 at 9:04 PM

There is no low-level NodeXL API call to merge duplicate edges and assign weights to the edges.  (I assume that's what you're asking for; correct me if I'm wrong.)  There is code in the NodeXL Excel Template to do this, but because that code operates on a worksheet and not on a graph, it is not available to other applications.

There are low-level NodeXL API calls to get in-degree and out-degree.  Do you want to know how to use them?  I'm not sure if that's part of your question.

-- Tony

Jul 1, 2010 at 2:11 AM

ya Tony, that what I wanted to know. I mean how can I get in-degree,out-degree and weights. Like say there is node A and B and say there is edge whose weight is 3. Now by making some calls to some method in API which gives me weight, in-degree,out-degree. Also how can we apply filters on edge's weights etc in program. Thanks Tony for your help 

Jul 1, 2010 at 5:47 AM

"Edge weight" does not have a specific definition.  It is just a number that someone has assigned to each edge, and the meaning of the numbers varies from graph to graph.  When you say you have an edge whose weight is 3, then you already know the edge weight, and you don't need NodeXL to calculate it for you.  And in fact NodeXL can't calculate it for you, because the lower-level NodeXL layers know nothing about edge weights.  (As I mentioned earlier, the high-level Node Excel Template does assign edge weights when it merges duplicate edges, where the edge weight is the number of duplicate edges that were merged into one, but that definition of edge weight is specific to the Template, and other applications may define edge weight in a completely different manner.)

We can help you with degree, however.  To calculate the degrees of a graph's vertices, use the Microsoft.NodeXL.Algorithms.VertexDegreeCalculator class.  There are several ways to use the class, but the simplest is to call the CalculateGraphMetrics() method.  This takes an IGraph as an argument and returns a Dictionary<> of VertexDegrees objects, one for each of the graph's vertices.  Please see the VertexDegreeCalculator Class topic in the NodeXLApi.chm help file for more details.

-- Tony

Mar 17, 2015 at 4:20 AM
I have an excel sheet containing node 1 and 2 information (i.e their names) in columns 1 and 2 and column 3 has the edge weight. Is there a way to generate a network having edge weights? I would like to be able to import the resultant edge weighted network to Cytoscape to do calculations of network parameters.
Thanks for the help, in advance
Mar 17, 2015 at 3:53 PM

Thank you for the interest in NodeXL.

If you have an edge list (Vertex 1, Vertex 2, Edge Weight) then you can probably import directly into Cytoscape - NodeXL would not add much to the process.

However, you can calculate network metrics in NodeXL as well. So perhaps you can paste your data into the NodeXL edges worksheet and then calculate metrics and layout and visualize the network.

You can display edge weights in NodeXL by mapping an edge data attribute to the Edge Width display attribute via the NodeXL>Visual Properties>Autofill Columns>Edges>Edge Width>[Select the edge weight column you prefer].


Mar 17, 2015 at 3:55 PM
That is the issue. Cytoscape doesn't support weighted edge.

Mar 17, 2015 at 3:58 PM

In that case, you may find that NodeXL is able to perform the operations you require.

You might consider uploading your graph to NodeXL Graph Gallery if you would like others to access and possibly refine your network visualization.

Mar 17, 2015 at 4:00 PM
Okay shall do it