Ejemplo n.º 1
0
 def test_get_in_neighbors_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.get_in_neighbors("blip")
         self.assertTrue(context.exception)
Ejemplo n.º 2
0
 def test_get_in_neighbors(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)
     neighbors = g.get_in_neighbors("node")
     self.assertEqual(neighbors, ["new"])
Ejemplo n.º 3
0
 def test_get_in_neighbors_empty_graph(self):
     g = Graph()
     with self.assertRaises(IndexError) as context:
         g.get_in_neighbors("test")
         self.assertTrue(context.exception)