def small_world_bd(W): ''' An implementation of small worldness. Returned is the coefficient cc/lambda, the ratio of the clustering coefficient to the characteristic path length. This ratio is >>1 for small world networks. inputs: W weighted undirected connectivity matrix output: s small world coefficient ''' cc = clustering_coef_bd(W) _, dists = breadthdist(W) _lambda, _, _, _, _ = charpath(dists) return np.mean(cc) / _lambda
def test_cluscoef_bd(): x = load_binary_directed_low_modularity_sample(thres=.41) cc = bct.clustering_coef_bd(x) assert np.allclose(np.sum(cc), 113.31145155)