summaryrefslogtreecommitdiff
path: root/networkx/algorithms/assortativity/tests/base_test.py
diff options
context:
space:
mode:
authorVitaliy Pozdnyakov <pozdnyakov.vitaliy@yandex.ru>2021-06-22 23:11:53 +0300
committerGitHub <noreply@github.com>2021-06-22 23:11:53 +0300
commit61688295e63cec163e0c17cfa29383822f00cf19 (patch)
tree4279a0fa1c5cc964459183781a6accab28c293a5 /networkx/algorithms/assortativity/tests/base_test.py
parent9315381d3fa39fed4de166457eaf50e5996b8d87 (diff)
downloadnetworkx-61688295e63cec163e0c17cfa29383822f00cf19.tar.gz
Fix assortativity coefficent calculation (#4851)
Update calculation of assortativity coefficients and update tests to reflect new behavior. Introduces mapping kwarg to degree_mixing_matrix and remove 0-padded rows/cols from degree_mixing_matrix. Co-authored-by: Dan Schult <dschult@colgate.edu>
Diffstat (limited to 'networkx/algorithms/assortativity/tests/base_test.py')
-rw-r--r--networkx/algorithms/assortativity/tests/base_test.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/networkx/algorithms/assortativity/tests/base_test.py b/networkx/algorithms/assortativity/tests/base_test.py
index 9a8a1e72..5b371231 100644
--- a/networkx/algorithms/assortativity/tests/base_test.py
+++ b/networkx/algorithms/assortativity/tests/base_test.py
@@ -49,3 +49,24 @@ class BaseTestDegreeMixing:
cls.M.add_edge(0, 1)
cls.S = nx.Graph()
cls.S.add_edges_from([(0, 0), (1, 1)])
+ cls.W = nx.Graph()
+ cls.W.add_edges_from([(0, 3), (1, 3), (2, 3)], weight=0.5)
+ cls.W.add_edge(0, 2, weight=1)
+
+
+class BaseTestNumericMixing:
+ @classmethod
+ def setup_class(cls):
+ N = nx.Graph()
+ N.add_nodes_from([0, 1], margin=-2)
+ N.add_nodes_from([2, 3], margin=-2)
+ N.add_nodes_from([4], margin=-3)
+ N.add_nodes_from([5], margin=-4)
+ N.add_edges_from([(0, 1), (2, 3), (0, 4), (2, 5)])
+ cls.N = N
+
+ F = nx.Graph()
+ F.add_edges_from([(0, 3), (1, 3), (2, 3)], weight=0.5)
+ F.add_edge(0, 2, weight=1)
+ nx.set_node_attributes(F, dict(F.degree(weight="weight")), "margin")
+ cls.F = F