def test_add_node(self): g1 = AdjMat() g1.add_node(1) assert g1.get_num_node() == 1 assert g1.contains_node(1) g1.add_node(2) assert g1.get_num_node() == 2 assert g1.contains_node(2) try: g1.add_node(2) raise Exception("Test should panic.") except GraphException: pass
def test_add_edge(self): g1 = AdjMat() g1.add_edge(1, 2, 3) assert g1.get_num_edge() == 1 assert g1.get_num_node() == 2 g1.add_edge(2, 1, 4) assert g1.get_num_edge() == 2 assert g1.get_num_node() == 2 try: g1.add_edge(1, 2, 1) raise Exception("Test should panic.") except GraphException: pass