def test_num_nodes_empty(self):
     """Test ID: G8."""
     g = Graph()
     num_nodes = g.num_nodes()
     self.assertEqual(0, num_nodes)
 def test_del_node_empty_graph(self):
     """Test ID: G32."""
     g = Graph()
     result = g.del_node('a')
     self.assertFalse(result)
 def setUp(self):
     self.graph = Graph({'a': ['b', 'c'], 'b': ['a'], 'c': ['a'], 'd': []})
 def test_unlink_nodes_empty_graph(self):
     """Test ID: G28."""
     g = Graph()
     with self.assertRaises(TypeError):
         g.unlink_nodes('a', 'b')
class TestGraph(unittest.TestCase):

    def setUp(self):
        self.graph = Graph({'a': ['b', 'c'], 'b': ['a'], 'c': ['a'], 'd': []})

    def test_get_adj_list_node_exists(self):
        """Test ID: G1."""
        a_adj_nodes = self.graph.get_adj_list('a')
        self.assertEqual(a_adj_nodes, ['b', 'c'])

    def test_get_adj_list_unknown_node(self):
        """Test ID: G2."""
        e_adj_nodes = self.graph.get_adj_list('e')
        self.assertIsNone(e_adj_nodes)

    def test_get_adj_list_no_input(self):
        """Test ID: G3."""
        with self.assertRaises(TypeError):
            self.graph.get_adj_list()

    def test_is_adjacent_known_edge(self):
        """Test ID: G4."""
        result = self.graph.is_adjacent('a', 'b')
        self.assertTrue(result)

    def test_is_adjacent_unknown_node(self):
        """Test ID: G5."""
        result = self.graph.is_adjacent('a', 'e')
        self.assertFalse(result)

    def test_is_adjacent_unknown_node1(self):
        """Test ID: G6."""
        result = self.graph.is_adjacent('ff', 'b')
        self.assertFalse(result)

    def test_is_adjacent_not_adjacent(self):
        """Test ID: G7."""
        result = self.graph.is_adjacent('b', 'c')
        self.assertFalse(result)

    def test_num_nodes_empty(self):
        """Test ID: G8."""
        g = Graph()
        num_nodes = g.num_nodes()
        self.assertEqual(0, num_nodes)

    def test_num_nodes_contains_data(self):
        """Test ID: G9."""
        num_nodes = self.graph.num_nodes()
        self.assertEqual(4, num_nodes)

    def test_len_empty(self):
        """Test ID: G10."""
        g = Graph()
        length = len(g)
        self.assertEqual(0, length)

    def test_len_contains_data(self):
        """Test ID: G11."""
        length = len(self.graph)
        self.assertEqual(4, length)

    def test_contains_node_exists(self):
        """Test ID: G12."""
        result = self.graph.__contains__('a')
        self.assertTrue(result)

    def test_contains_node_dne(self):
        """Test ID: G13."""
        result = self.graph.__contains__('e')
        self.assertFalse(result)

    def test_add_node_new_node(self):
        """Test ID: G14."""
        result = self.graph.add_node('f')
        self.assertTrue(result)

    def test_add_node_existing_node(self):
        """Test ID: G15."""
        result = self.graph.add_node('a')
        self.assertFalse(result)

    def test_add_node_check_adj_list(self):
        """Test ID: G16."""
        self.graph.add_node('zz')
        zz_adj_nodes = self.graph.get_adj_list('zz')
        self.assertEqual(zz_adj_nodes, [])

    def test_link_nodes_unlinked_nodes(self):
        """Test ID: G17."""
        result = self.graph.link_nodes('b', 'c')
        self.assertTrue(result)

    def test_link_nodes_unlinked_nodes_check(self):
        """Test ID: G18."""
        self.graph.link_nodes('b', 'c')
        result = self.graph.is_adjacent('b', 'c')
        self.assertTrue(result)

    def test_link_nodes_linked_nodes(self):
        """Test ID: G19."""
        result = self.graph.link_nodes('a', 'b')
        self.assertFalse(result)

    def test_link_nodes_single_input(self):
        """Test ID: G20."""
        with self.assertRaises(TypeError):
            self.graph.link_nodes('a')

    def test_link_nodes_same_node(self):
        """Test ID: G21."""
        result = self.graph.link_nodes('b', 'b')
        self.assertFalse(result)

    def test_link_nodes_empty_graph(self):
        """Test ID: G22."""
        g = Graph()
        result = g.link_nodes('b', 'c')
        self.assertFalse(result)

    def test_unlink_nodes_linked_nodes(self):
        """Test ID: G23."""
        result = self.graph.unlink_nodes('a', 'b')
        self.assertTrue(result)

    def test_unlink_nodes_linked_nodes_check(self):
        """Test ID: G24."""
        self.graph.unlink_nodes('a', 'b')
        result = self.graph.is_adjacent('a', 'b')
        self.assertFalse(result)

    def test_unlink_nodes_unlinked_nodes(self):
        """Test ID: G25."""
        result = self.graph.unlink_nodes('b', 'c')
        self.assertFalse(result)

    def test_unlink_nodes_single_input(self):
        """Test ID: G26."""
        with self.assertRaises(TypeError):
            self.graph.unlink_nodes('b')

    def test_unlink_nodes_same_node(self):
        """Test ID: G27."""
        result = self.graph.unlink_nodes('b', 'b')
        self.assertFalse(result)

    def test_unlink_nodes_empty_graph(self):
        """Test ID: G28."""
        g = Graph()
        with self.assertRaises(TypeError):
            g.unlink_nodes('a', 'b')

    def test_del_node_node_exists(self):
        """Test ID: G29."""
        result = self.graph.del_node('b')
        self.assertTrue(result)

    def test_del_node_node_exists_check(self):
        """Test ID: G30."""
        self.graph.del_node('b')
        result = self.graph.__contains__('b')
        self.assertFalse(result)

    def test_del_node_node_dne(self):
        """Test ID: G31."""
        result = self.graph.del_node('ff')
        self.assertFalse(result)

    def test_del_node_empty_graph(self):
        """Test ID: G32."""
        g = Graph()
        result = g.del_node('a')
        self.assertFalse(result)

    def test_iter(self):
        i = iter(self.graph)
        self.assertEqual(i.next(), ('a', ['b', 'c']))

    def test_str(self):
        ex = """{'a': ['b', 'c'], 'c': ['a'], 'b': ['a'], 'd': []}"""
        self.assertEqual(str(self.graph), ex)
 def test_link_nodes_empty_graph(self):
     """Test ID: G22."""
     g = Graph()
     result = g.link_nodes('b', 'c')
     self.assertFalse(result)