示例#1
0
 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
示例#2
0
 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)
示例#3
0
 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)
示例#4
0
 def test_unknown_root(self):
     with pytest.raises(nx.NodeNotFound):
         G = nx.path_graph(2)
         nx.to_nested_tuple(G, "bogus")
示例#5
0
 def test_nontree(self):
     with pytest.raises(nx.NotATree):
         G = nx.cycle_graph(3)
         nx.to_nested_tuple(G, 0)
示例#6
0
 def test_unknown_root(self):
     G = nx.path_graph(2)
     nx.to_nested_tuple(G, 'bogus')
示例#7
0
 def test_nontree(self):
     G = nx.cycle_graph(3)
     nx.to_nested_tuple(G, 0)
示例#8
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)
示例#9
0
 def test_unknown_root(self):
     G = nx.path_graph(2)
     nx.to_nested_tuple(G, 'bogus')
示例#10
0
 def test_nontree(self):
     G = nx.cycle_graph(3)
     nx.to_nested_tuple(G, 0)