From 27ff6f5809cbfcced0234e6fe6e6f59b46d59479 Mon Sep 17 00:00:00 2001 From: Schefflera-Arboricola <1509aditi@gmail.com> Date: Tue, 12 Mar 2024 18:40:46 +0530 Subject: [PATCH] updated test for get_chunk --- .../centrality/tests/test_betweenness_centrality.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/nx_parallel/algorithms/centrality/tests/test_betweenness_centrality.py b/nx_parallel/algorithms/centrality/tests/test_betweenness_centrality.py index 76d6c0a..d336e5c 100644 --- a/nx_parallel/algorithms/centrality/tests/test_betweenness_centrality.py +++ b/nx_parallel/algorithms/centrality/tests/test_betweenness_centrality.py @@ -23,17 +23,17 @@ def get_chunk(nodes, num_chunks): return chunks - G = nx.fast_gnp_random_graph(200, 0.8, seed=5, directed=False) + G = nx.bipartite.random_graph(400, 700, 0.8, seed=5, directed=False) + H = nxp.ParallelGraph(G) ebc = nx.edge_betweenness_centrality(G) t1 = time.time() - par_bc_chunk = nxp.betweenness_centrality(G, get_chunks=get_chunk) # smoke test + par_bc_chunk = nxp.betweenness_centrality(H, get_chunks=get_chunk) # smoke test t2 = time.time() - par_bc = nxp.betweenness_centrality(G) + par_bc = nxp.betweenness_centrality(H) t3 = time.time() - for i in range(200): + for i in range(len(G.nodes)): assert math.isclose(par_bc[i], par_bc_chunk[i], abs_tol=1e-16) with_chunk = t2 - t1 without_chunk = t3 - t2 - # assert with_chunk < without_chunk + assert with_chunk < without_chunk # get_chunk is faster than default(for big graphs) - # eg - G = nx.bipartite.random_graph(400, 700, 0.8, seed=5, directed=False)