forked from networkx/nx-parallel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbench_bipartite.py
More file actions
25 lines (18 loc) · 772 Bytes
/
bench_bipartite.py
File metadata and controls
25 lines (18 loc) · 772 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import networkx as nx
from .common import (
Benchmark,
backends,
edge_prob,
)
# for an unbalanced bipartite random graph
n = [50, 100, 200, 400, 800]
m = [25, 50, 100, 200, 400]
class Redundancy(Benchmark):
params = [(backends), (n), (m), (edge_prob)]
param_names = ["backend", "n", "m", "edge_prob"]
def time_node_redundancy(self, backend, n, m, edge_prob):
G = get_random_bipartite_graph(n, m, edge_prob)
_ = nx.node_redundancy(G, backend=backend)
def get_random_bipartite_graph(n, m, p, seed=42, directed=False):
"""Ref. https://networkx.org/documentation/stable/reference/algorithms/generated/networkx.algorithms.bipartite.generators.random_graph.html"""
return nx.bipartite.random_graph(n, m, p, seed, directed)