Skip to content

Commit

Permalink
updated test for get_chunk
Browse files Browse the repository at this point in the history
  • Loading branch information
Schefflera-Arboricola committed Mar 12, 2024
1 parent cf6a5bd commit 27ff6f5
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 27ff6f5

Please sign in to comment.