A Question about Centrality Calculations

Jun 3, 2013 at 4:13 AM
Hi, I'm currently working on a C# program with NodeXL API and I want to calculate the centrality metrics within the code. I'm new to the API, and I think the class that can calculate the centrality is the "BrandesFastCentralityCalculator Class" under the Smrf.NodeXL.Algorithms namespace, is that the right one?
And in NodeXLApi Help file it says "Starting with version of NodeXL, the centralities are calculated using the SNAP graph library...", so does it mean that the built-in algorithm of this class is from SNAP or I have to use another class called "SNAP library"?
Hope you can help, and sorry for my bad English.;-)

Best wishes. Larry.
Jun 3, 2013 at 5:25 AM

Yes, that is the correct class. For synchronous calculations, your code would look something like the following. (I haven't compiled this, so I can't guarantee there are no typos here.)
BrandesFastCentralityCalculator calculator = new BrandesFastCentralityCalculator();
Dictionary<Int32, BrandesVertexCentralities> centralities = calculator.CalculateGraphMetrics(graph);
The dictionary key is a Vertex.ID and the value is a BrandesVertexCentralities object for the vertex. The BrandesVertexCentralities class is documented in the NodeXLApi.chm help file.

Internally, the CalculateGraphMetrics() object makes a call to an executable called SnapGraphMetricCalculator.exe. This executable is included in the NodeXL Class Libraries download. If you place the executable in the same folder as the Smrf.NodeXL.Algorithms.dll assembly, then NodeXL will automatically find and use the executable. You don't need to do anything else, and you don't need to know anything about SNAP.

-- Tony
Jun 3, 2013 at 6:15 AM
Thank you for your quick and highly effective reply. I followed your instructions and now it's working properly. Thanks a lot Tony, and have a nice day!