Home › Forums › Software Bugs (Braph 1.0) › NaN in small worldness › Reply To: NaN in small worldness
Thank you for using Braph.
The issue with small worldness (and characteristic path length) is that they cannot be calculated (especially for small densities) due to the disconnections of some nodes in the graph. This is due to their current implementation, in which first the nodal path lengths for each node are calculated and then they are averaged out in order to calculate the characteristic path length. Therefore, if any disconnected nodes exist in the graph, the nodal path length will return NaN and the characteristic path length cannot be calculated.
As an alternative, you might want to calculate them only within connected subgraphs, where there are no disconnected nodes. If you calculate the small worldness from the command line, you can specify a second argument (“wsg”) as a function input, which ,if set to true, will calculate the small worldness within the connected component of the network. You can find the codes for this on line 1427 in the file Graph.m (for calculating the small worldness) and on line 460 in GraphBU.m (within the method “measure”) for the differences of calculating the path length only within the connected components. Currently, the default value of this argument is set to false. If you would like to change this so that the small worldness is always calculated within the connected components you can do so by changing line 1439 of Graph.m file.
Another alternative method is to implement the harmonic mean as I explained above.
I realize that the calculation of the small-worldness takes a lot of time. This is due to the fact that in order to calculate the small-worldness the network needs to be randomized many times, and currently, the randomization algorithm implemented in Braph is very slow. We hope that we can implement faster alternative methods in Braph soon.
Hope this helps you. Please do not hesitate to ask if you would need any more help.