Skip to content

Commit

Permalink
updated docs and added benchmark for node_redundancy
Browse files Browse the repository at this point in the history
  • Loading branch information
Schefflera-Arboricola committed Feb 12, 2024
1 parent 8e44dee commit 2858910
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
24 changes: 24 additions & 0 deletions benchmarks/benchmarks/bench_bipartite.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from .common import (
backends,
edge_prob,
Benchmark,
)
import networkx as nx

# 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)
6 changes: 4 additions & 2 deletions nx_parallel/algorithms/bipartite/redundancy.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@


def node_redundancy(G, nodes=None):
"""Computes the node redundancy coefficients for the nodes in the bipartite
graph `G`."""
"""In the parallel implementation we compute the node redundancy coefficients
for all the nodes in the bipartite graph `G` concurrently.
networkx.bipartite.node_redundancy : https://networkx.org/documentation/stable/reference/algorithms/generated/networkx.algorithms.bipartite.redundancy.node_redundancy.html"""

if hasattr(G, "graph_object"):
G = G.graph_object
Expand Down

0 comments on commit 2858910

Please sign in to comment.