summaryrefslogtreecommitdiff
path: root/networkx/algorithms/cuts.py
diff options
context:
space:
mode:
authorJim Kitchen <jim22k@gmail.com>2022-10-11 15:24:14 -0500
committerMridul Seth <git@mriduls.com>2022-10-12 12:05:14 +0400
commitc2111a36841d5e43b6beae1fd667996d35646e30 (patch)
tree38fa5e1316ca45a9906169ceb7ac21bfc52a612e /networkx/algorithms/cuts.py
parent71434d674cf8ec6c3007dd41b78ee6f407e9b4eb (diff)
downloadnetworkx-nx-sparse.tar.gz
Allow dispatcher decorator without a namenx-sparse
- Name is taken from the decorated function - Raise error if backend doesn't implement a decorated function which is called - Check for duplicate names for dispatching algorithms
Diffstat (limited to 'networkx/algorithms/cuts.py')
-rw-r--r--networkx/algorithms/cuts.py16
1 files changed, 8 insertions, 8 deletions
diff --git a/networkx/algorithms/cuts.py b/networkx/algorithms/cuts.py
index 271ff309..2b4794ef 100644
--- a/networkx/algorithms/cuts.py
+++ b/networkx/algorithms/cuts.py
@@ -21,7 +21,7 @@ __all__ = [
# TODO STILL NEED TO UPDATE ALL THE DOCUMENTATION!
-@nx.dispatch("cut_size")
+@nx.dispatch
def cut_size(G, S, T=None, weight=None):
"""Returns the size of the cut between two sets of nodes.
@@ -84,7 +84,7 @@ def cut_size(G, S, T=None, weight=None):
return sum(weight for u, v, weight in edges)
-@nx.dispatch("volume")
+@nx.dispatch
def volume(G, S, weight=None):
"""Returns the volume of a set of nodes.
@@ -127,7 +127,7 @@ def volume(G, S, weight=None):
return sum(d for v, d in degree(S, weight=weight))
-@nx.dispatch("normalized_cut_size")
+@nx.dispatch
def normalized_cut_size(G, S, T=None, weight=None):
"""Returns the normalized size of the cut between two sets of nodes.
@@ -180,7 +180,7 @@ def normalized_cut_size(G, S, T=None, weight=None):
return num_cut_edges * ((1 / volume_S) + (1 / volume_T))
-@nx.dispatch("conductance")
+@nx.dispatch
def conductance(G, S, T=None, weight=None):
"""Returns the conductance of two sets of nodes.
@@ -228,7 +228,7 @@ def conductance(G, S, T=None, weight=None):
return num_cut_edges / min(volume_S, volume_T)
-@nx.dispatch("edge_expansion")
+@nx.dispatch
def edge_expansion(G, S, T=None, weight=None):
"""Returns the edge expansion between two node sets.
@@ -275,7 +275,7 @@ def edge_expansion(G, S, T=None, weight=None):
return num_cut_edges / min(len(S), len(T))
-@nx.dispatch("mixing_expansion")
+@nx.dispatch
def mixing_expansion(G, S, T=None, weight=None):
"""Returns the mixing expansion between two node sets.
@@ -323,7 +323,7 @@ def mixing_expansion(G, S, T=None, weight=None):
# TODO What is the generalization to two arguments, S and T? Does the
# denominator become `min(len(S), len(T))`?
-@nx.dispatch("node_expansion")
+@nx.dispatch
def node_expansion(G, S):
"""Returns the node expansion of the set `S`.
@@ -363,7 +363,7 @@ def node_expansion(G, S):
# TODO What is the generalization to two arguments, S and T? Does the
# denominator become `min(len(S), len(T))`?
-@nx.dispatch("boundary_expansion")
+@nx.dispatch
def boundary_expansion(G, S):
"""Returns the boundary expansion of the set `S`.