diff options
author | Alimi Qudirah <qudrohbidemi@gmail.com> | 2022-10-17 16:52:51 +0100 |
---|---|---|
committer | Jarrod Millman <jarrod.millman@gmail.com> | 2022-11-01 10:27:34 -0700 |
commit | 984421bfd44328f1cd51735e3700b78a583476c4 (patch) | |
tree | 7abe5586ebab20eeaf3f80ac363283584e769978 | |
parent | ac13ea00737048ed14ae9fdbc5e16cd6bc762009 (diff) | |
download | networkx-984421bfd44328f1cd51735e3700b78a583476c4.tar.gz |
fixes #6036 (#6080)
* fixes #6036
* test load centrality
-rw-r--r-- | networkx/algorithms/centrality/tests/test_load_centrality.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/networkx/algorithms/centrality/tests/test_load_centrality.py b/networkx/algorithms/centrality/tests/test_load_centrality.py index 065b4fda..d994394f 100644 --- a/networkx/algorithms/centrality/tests/test_load_centrality.py +++ b/networkx/algorithms/centrality/tests/test_load_centrality.py @@ -24,6 +24,7 @@ class TestLoadCentrality: cls.P3 = nx.path_graph(3) cls.P4 = nx.path_graph(4) cls.K5 = nx.complete_graph(5) + cls.P2 = nx.path_graph(2) cls.C4 = nx.cycle_graph(4) cls.T = nx.balanced_tree(r=2, h=2) @@ -41,6 +42,13 @@ class TestLoadCentrality: assert result[n] == pytest.approx(b[n], abs=1e-3) assert result[n] == pytest.approx(nx.load_centrality(self.D, n), abs=1e-3) + def test_P2_normalized_load(self): + G = self.P2 + c = nx.load_centrality(G, normalized=True) + d = {0: 0.000, 1: 0.000} + for n in sorted(G): + assert c[n] == pytest.approx(d[n], abs=1e-3) + def test_weighted_load(self): b = nx.load_centrality(self.G, weight="weight", normalized=False) for n in sorted(self.G): |