Mercurial > repos > shellac > sam_consensus_v3
comparison env/lib/python3.9/site-packages/networkx/algorithms/tree/tests/test_operations.py @ 0:4f3585e2f14b draft default tip
"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
author | shellac |
---|---|
date | Mon, 22 Mar 2021 18:12:50 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4f3585e2f14b |
---|---|
1 """Unit tests for the :mod:`networkx.algorithms.tree.operations` module. | |
2 | |
3 """ | |
4 | |
5 import networkx as nx | |
6 from networkx.testing import assert_nodes_equal | |
7 from networkx.testing import assert_edges_equal | |
8 | |
9 | |
10 class TestJoin: | |
11 """Unit tests for the :func:`networkx.tree.join` function.""" | |
12 | |
13 def test_empty_sequence(self): | |
14 """Tests that joining the empty sequence results in the tree | |
15 with one node. | |
16 | |
17 """ | |
18 T = nx.join([]) | |
19 assert len(T) == 1 | |
20 assert T.number_of_edges() == 0 | |
21 | |
22 def test_single(self): | |
23 """Tests that joining just one tree yields a tree with one more | |
24 node. | |
25 | |
26 """ | |
27 T = nx.empty_graph(1) | |
28 actual = nx.join([(T, 0)]) | |
29 expected = nx.path_graph(2) | |
30 assert_nodes_equal(list(expected), list(actual)) | |
31 assert_edges_equal(list(expected.edges()), list(actual.edges())) | |
32 | |
33 def test_basic(self): | |
34 """Tests for joining multiple subtrees at a root node.""" | |
35 trees = [(nx.full_rary_tree(2, 2 ** 2 - 1), 0) for i in range(2)] | |
36 actual = nx.join(trees) | |
37 expected = nx.full_rary_tree(2, 2 ** 3 - 1) | |
38 assert nx.is_isomorphic(actual, expected) |