diff env/lib/python3.9/site-packages/networkx/generators/tests/test_duplication.py @ 0:4f3585e2f14b draft default tip

"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
author shellac
date Mon, 22 Mar 2021 18:12:50 +0000
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/env/lib/python3.9/site-packages/networkx/generators/tests/test_duplication.py	Mon Mar 22 18:12:50 2021 +0000
@@ -0,0 +1,71 @@
+"""Unit tests for the :mod:`networkx.generators.duplication` module.
+
+"""
+import pytest
+
+from networkx.exception import NetworkXError
+from networkx.generators.duplication import duplication_divergence_graph
+from networkx.generators.duplication import partial_duplication_graph
+
+
+class TestDuplicationDivergenceGraph:
+    """Unit tests for the
+    :func:`networkx.generators.duplication.duplication_divergence_graph`
+    function.
+
+    """
+
+    def test_final_size(self):
+        G = duplication_divergence_graph(3, 1)
+        assert len(G) == 3
+        G = duplication_divergence_graph(3, 1, seed=42)
+        assert len(G) == 3
+
+    def test_probability_too_large(self):
+        with pytest.raises(NetworkXError):
+            duplication_divergence_graph(3, 2)
+
+    def test_probability_too_small(self):
+        with pytest.raises(NetworkXError):
+            duplication_divergence_graph(3, -1)
+
+
+class TestPartialDuplicationGraph:
+    """Unit tests for the
+    :func:`networkx.generators.duplication.partial_duplication_graph`
+    function.
+
+    """
+
+    def test_final_size(self):
+        N = 10
+        n = 5
+        p = 0.5
+        q = 0.5
+        G = partial_duplication_graph(N, n, p, q)
+        assert len(G) == N
+        G = partial_duplication_graph(N, n, p, q, seed=42)
+        assert len(G) == N
+
+    def test_initial_clique_size(self):
+        N = 10
+        n = 10
+        p = 0.5
+        q = 0.5
+        G = partial_duplication_graph(N, n, p, q)
+        assert len(G) == n
+
+    def test_invalid_initial_size(self):
+        with pytest.raises(NetworkXError):
+            N = 5
+            n = 10
+            p = 0.5
+            q = 0.5
+            G = partial_duplication_graph(N, n, p, q)
+
+    def test_invalid_probabilities(self):
+        N = 1
+        n = 1
+        for p, q in [(0.5, 2), (0.5, -1), (2, 0.5), (-1, 0.5)]:
+            args = (N, n, p, q)
+            pytest.raises(NetworkXError, partial_duplication_graph, *args)