def test_in_degree_unknown_key(self): g = Graph() g.add_node("new") g.add_node("node") g.add_node("test") g.add_edge("new", "node") g.add_edge("node", "test", 45) with self.assertRaises(IndexError) as context: g.in_degree("blip") self.assertTrue(context.exception)
def test_in_degree(self): g = Graph() g.add_node("new") g.add_node("node") g.add_node("test") g.add_edge("new", "node") g.add_edge("node", "test", 45) deg = g.in_degree("node") self.assertEqual(deg, 1)