summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOkite chimaobi Samuel <okitesamuel@gmail.com>2022-10-21 09:45:28 +0100
committerJarrod Millman <jarrod.millman@gmail.com>2022-11-01 10:28:05 -0700
commit4d96ab94816b535a6fc5d4bf41ce1424889cbf95 (patch)
tree78918bdf4a7fcf1f2d853d5656aeb47f9068a43d
parentfee6347bdbb20d5efa1419a141eb38f39ec4a4fd (diff)
downloadnetworkx-4d96ab94816b535a6fc5d4bf41ce1424889cbf95.tar.gz
Improve test coverage for algorithms in dominating_set.py (PR for issue 6032) (#6068)
* updated test coverage for issue 6032 * updated test coverage for issue 6032 * updated test coverage for issue 6032 * updated test coverage for issue 6032 * updated test coverage for issue 6032 * improved test coverage of dominating_set.py to 100% * removed unneccessary files
-rw-r--r--networkx/algorithms/approximation/tests/test_dominating_set.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/networkx/algorithms/approximation/tests/test_dominating_set.py b/networkx/algorithms/approximation/tests/test_dominating_set.py
index 892ce34e..6b90d85e 100644
--- a/networkx/algorithms/approximation/tests/test_dominating_set.py
+++ b/networkx/algorithms/approximation/tests/test_dominating_set.py
@@ -1,3 +1,5 @@
+import pytest
+
import networkx as nx
from networkx.algorithms.approximation import (
min_edge_dominating_set,
@@ -37,6 +39,11 @@ class TestMinWeightDominatingSet:
G = nx.relabel_nodes(G, {0: 9, 9: 0})
assert min_weighted_dominating_set(G) == {9}
+ def test_null_graph(self):
+ """Tests that the unique dominating set for the null graph is an empty set"""
+ G = nx.Graph()
+ assert min_weighted_dominating_set(G) == set()
+
def test_min_edge_dominating_set(self):
graph = nx.path_graph(5)
dom_set = min_edge_dominating_set(graph)
@@ -65,3 +72,7 @@ class TestMinWeightDominatingSet:
for dom_edge in dom_set:
found |= u == dom_edge[0] or u == dom_edge[1]
assert found, "Non adjacent edge found!"
+
+ graph = nx.Graph() # empty Networkx graph
+ with pytest.raises(ValueError, match="Expected non-empty NetworkX graph!"):
+ min_edge_dominating_set(graph)