API Questions / Ideas

Mar 11, 2009 at 12:55 AM
Hello, I'm a new to this forum.  I'm working on using nodexl algorithms for a project that I'm working on.  One request that I have is that it would be great if the stuff in Microsoft.NodeXL.Algorithms didn't require a backgroundworker as a parameter.  Perhaps an overload that doesn't require this?  In my setup this data is calculated via background threads by the time it gets to my code, so in a sense i can use nodexl's algorithms in a single threaded fashion.  I looked at the code, it appeared that i could pass NULL in for the background worker but for some of the algorithms it threw an assertion.  Its not a huge deal for me to create a Backgroundworker and pass it in, but if its not really needed I would love to have an overload that didn't require it.  Anything that can simplify the api makes it more discoverable :) and easier to use.

Another thought, If i send in a graph with duplicate edges and calculate clustering coefficient, i can get values back in excess of 1.0 (saw some as high as 7.0).  Its absolutely true i shouldn't do this; but in this case I had an expert I could bounce things off of to discuss the values I should get.  I would expect that nodexl's algorithms would throw an exception of some sort explaining that edges cannot be duplicated.

Awesome product! thank you!

Scott Sargent

Mar 11, 2009 at 3:54 AM

Thanks for the post.  The graph metric calculators are indeed designed to handle a NULL backgroundWorker argument.  If any of them are throwing an assertion in this case, please post the assertion details so I can fix them.  (You can press Ctrl-C to copy the assertion text to the clipboard.)  I tend to concentrate my testing on the cases used by the Excel Template, which are all asynchronous, and it sounds like I missed a bug here.

Each graph calculator has a synchronous CalculateGraphMetrics() method that does not take a BackgroundWorker.  In fact, it's defined in the IGraphMetricCalculator interface that each calculator implements.  The only disadvantage to this method is that it returns an Object instead of a specified type.  That's by necessity, because it's part of a common interface.  The class topic for each calculator documents the actual type.

In the Excel Template we don't want to stop a user in her tracks when she attempts to calculate graph metrics that are invalid because of duplicate edges.  Instead, we issue a warning and then paint the resulting numbers red.  You can use Algorithms.DuplicateEdgeDetector to check for this in your own application and handle the situation in an appropriate manner.  I do warn about this in the documentation for ClusteringCoefficientCalculator: "The calculations are rendered invalid if the graph has duplicate edges..."