def test_canonical_form(self): T = nx.Graph() T.add_edges_from([(0, 1), (0, 2), (0, 3)]) T.add_edges_from([(1, 4), (1, 5)]) T.add_edges_from([(3, 6), (3, 7)]) root = 0 actual = nx.to_nested_tuple(T, root, canonical_form=True) expected = ((), ((), ()), ((), ())) assert actual == expected
def test_canonical_form(self): T = nx.Graph() T.add_edges_from([(0, 1), (0, 2), (0, 3)]) T.add_edges_from([(1, 4), (1, 5)]) T.add_edges_from([(3, 6), (3, 7)]) root = 0 actual = nx.to_nested_tuple(T, root, canonical_form=True) expected = ((), ((), ()), ((), ())) assert_equal(actual, expected)
def test_encoding(self): T = nx.full_rary_tree(2, 2**3 - 1) expected = (((), ()), ((), ())) actual = nx.to_nested_tuple(T, 0) assert_nodes_equal(expected, actual)
def test_unknown_root(self): with pytest.raises(nx.NodeNotFound): G = nx.path_graph(2) nx.to_nested_tuple(G, "bogus")
def test_nontree(self): with pytest.raises(nx.NotATree): G = nx.cycle_graph(3) nx.to_nested_tuple(G, 0)
def test_unknown_root(self): G = nx.path_graph(2) nx.to_nested_tuple(G, 'bogus')
def test_nontree(self): G = nx.cycle_graph(3) nx.to_nested_tuple(G, 0)
def test_encoding(self): T = nx.full_rary_tree(2, 2 ** 3 - 1) expected = (((), ()), ((), ())) actual = nx.to_nested_tuple(T, 0) assert_equal(expected, actual)
def test_unknown_root(self): G = nx.path_graph(2) nx.to_nested_tuple(G, 'bogus')
def test_nontree(self): G = nx.cycle_graph(3) nx.to_nested_tuple(G, 0)