Exemplo n.º 1
0
def test_create_random_graph():
    base_dir = str(Path(__file__).parent/"examples")
    in_mat = np.load(base_dir + '/997/997_Default_est_cov_0.1_4.npy')
    G = nx.from_numpy_array(in_mat)
    n = 10
    p = 0.5

    start_time = time.time()
    rG = netstats.create_random_graph(G, n, p)
    print("%s%s%s" % ('thresh_and_fit (Functional, proportional thresholding) --> finished: ', str(np.round(time.time() - start_time, 1)), 's'))
    assert rG is not None
Exemplo n.º 2
0
def smallworldness(G, rep = 1000):
    n = nx.number_of_nodes(G)
    m = nx.number_of_edges(G)
    p = float(m) * 2 /(n*(n-1))
    ss = []
    for bb in range(rep):
        rG = create_random_graph(G, n, p)
        swm = smallworldness_measure(G, rG)
        ss.append(swm)
    mean_s = np.mean(ss)
    return mean_s