summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlimi Qudirah <qudrohbidemi@gmail.com>2023-05-02 16:26:02 +0100
committerGitHub <noreply@github.com>2023-05-02 11:26:02 -0400
commit927c8799a5255bd03baee0390e6b46fb751e50ee (patch)
tree2d3767adefaab8098bf554163e1dd7c3815443a4
parentb467fdd82b9039b84b183e966749bd5a9a7a4770 (diff)
downloadnetworkx-927c8799a5255bd03baee0390e6b46fb751e50ee.tar.gz
Added tests to test_correlation.py (#6590)
* added tests to test_correlation.py * bugfix-for-6588
-rw-r--r--networkx/algorithms/assortativity/tests/test_correlation.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/networkx/algorithms/assortativity/tests/test_correlation.py b/networkx/algorithms/assortativity/tests/test_correlation.py
index dbaa432e..5203f944 100644
--- a/networkx/algorithms/assortativity/tests/test_correlation.py
+++ b/networkx/algorithms/assortativity/tests/test_correlation.py
@@ -15,6 +15,13 @@ class TestDegreeMixingCorrelation(BaseTestDegreeMixing):
r = nx.degree_assortativity_coefficient(self.P4)
np.testing.assert_almost_equal(r, -1.0 / 2, decimal=4)
+ def test_degree_assortativity_node_kwargs(self):
+ G = nx.Graph()
+ edges = [(0, 1), (0, 3), (1, 2), (1, 3), (1, 4), (5, 9), (9, 0)]
+ G.add_edges_from(edges)
+ r = nx.degree_assortativity_coefficient(G, nodes=[1, 2, 4])
+ np.testing.assert_almost_equal(r, -1.0, decimal=4)
+
def test_degree_assortativity_directed(self):
r = nx.degree_assortativity_coefficient(self.D)
np.testing.assert_almost_equal(r, -0.57735, decimal=4)
@@ -99,6 +106,14 @@ class TestAttributeMixingCorrelation(BaseTestAttributeMixing):
r = nx.numeric_assortativity_coefficient(self.N, "margin")
np.testing.assert_almost_equal(r, -0.2903, decimal=4)
+ def test_assortativity_node_kwargs(self):
+ G = nx.Graph()
+ G.add_nodes_from([0, 1], size=2)
+ G.add_nodes_from([2, 3], size=3)
+ G.add_edges_from([(0, 1), (2, 3)])
+ r = nx.numeric_assortativity_coefficient(G, "size", nodes=[0, 3])
+ np.testing.assert_almost_equal(r, 1.0, decimal=4)
+
def test_attribute_assortativity_float(self):
r = nx.numeric_assortativity_coefficient(self.F, "margin")
np.testing.assert_almost_equal(r, -0.1429, decimal=4)