Esempio n. 1
0
 def test_poss1(self):
     poss, maps = poss_mappings(graph_from_edges((1, 2), (2, 3)))
     self.assertTrue(poss)
     self.assertEqual(maps[frozenset({1, 3})], {1, 2, 3})
     self.assertEqual(maps[frozenset({1})], {1, 2, 3, 0})
     self.assertEqual(maps[frozenset({2})], {2, 0})
     self.assertEqual(maps[frozenset({3})], {1, 2, 3, 0})
Esempio n. 2
0
 def test_impossible(self):
     poss, maps = poss_mappings(graph_from_edges((1, 2), (3, 4)))
     self.assertFalse(poss)
     self.assertEqual(maps[frozenset({1, 3})], set())
     self.assertEqual(maps[frozenset({2, 4})], set())
     self.assertEqual(maps[frozenset({1, 4})], set())
     self.assertEqual(maps[frozenset({2, 3})], set())
Esempio n. 3
0
 def test_squareGraph(self):
     graph = graph_from_edges({(1, 2), (2, 3), (3, 4), (4, 1)})
     sufficient, pm = possible_mappings(graph)
     self.assertTrue(sufficient)
     self.assertEqual(pm[frozenset({1, 3})], {1, 3})
     self.assertEqual(pm[frozenset({2, 4})], {2, 4})
     self.assertEqual(pm[frozenset({1})], {1, 3})
     self.assertEqual(pm[frozenset({3})], {1, 3})
     self.assertEqual(pm[frozenset({2})], {2, 4})
     self.assertEqual(pm[frozenset({4})], {2, 4})
     self.assertEqual(len(pm), 6)
Esempio n. 4
0
 def __init__(self, *edges):
     self.graph = graph_from_edges(*edges)
Esempio n. 5
0
 def test_neighborhood(self):
     G = graph_from_edges((1, 2))
     self.assertEqual(G[1], {2})
     self.assertEqual(G[2], {1})
Esempio n. 6
0
 def test_neighborhood3(self):
     G = graph_from_edges((1, 2), (1, 3), (1, 4))
     self.assertEqual(G[1], {2, 3, 4})
     self.assertEqual(G[2], {1})
     self.assertEqual(G[3], {1})
     self.assertEqual(G[4], {1})
Esempio n. 7
0
 def test_neighborhood2(self):
     G = graph_from_edges((1, 2), (2, 3), (3, 4), (4, 1))
     self.assertEqual(G[1], {2, 4})
     self.assertEqual(G[2], {1, 3})
     self.assertEqual(G[3], {2, 4})
     self.assertEqual(G[4], {1, 3})
Esempio n. 8
0
 def test_neighborhood1(self):
     G = graph_from_edges((1, 2), (2, 3))
     self.assertEqual(G[1], {2})
     self.assertEqual(G[2], {1, 3})
     self.assertEqual(G[3], {2})