def test_non_consecutive_adding(self): """Test adding vertices non-consecutively.""" # Create []. a_graph = DirectedGraph() # Add 1 to [], which becomes [set(), set()]. # Here 0 is added implicitly. a_graph.add(1) self.assertEqual(a_graph.n_vertices(), 2) self.assertEqual(a_graph.connected(0, 0), True) self.assertEqual(a_graph.connected(0, 1), False) self.assertEqual(a_graph.connected(1, 1), True)
def test_consecutive_adding(self): """Test adding vertices consecutively.""" # Create []. a_graph = DirectedGraph() # Add 0 to [], which becomes [set()]. a_graph.add(0) self.assertEqual(a_graph.n_vertices(), 1) self.assertEqual(a_graph.connected(0, 0), True) self.assertEqual(a_graph.connected(0, 1), False) self.assertEqual(a_graph.connected(1, 1), False) # Add 0 to [set()], nothing changes. a_graph.add(0) self.assertEqual(a_graph.n_vertices(), 1) self.assertEqual(a_graph.connected(0, 0), True) self.assertEqual(a_graph.connected(0, 1), False) self.assertEqual(a_graph.connected(1, 1), False) # Add 1 to [set()], which becomes [set(), set()]. a_graph.add(1) self.assertEqual(a_graph.n_vertices(), 2) self.assertEqual(a_graph.connected(0, 0), True) self.assertEqual(a_graph.connected(0, 1), False) self.assertEqual(a_graph.connected(1, 1), True)