Example #1
0
 def test_get_out_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_out_neighbors("blip")
         self.assertTrue(context.exception)
Example #2
0
 def test_get_out_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_out_neighbors("new")
     self.assertEqual(neighbors, ["node"])
Example #3
0
 def test_get_out_neighbors_empty_graph(self):
     g = Graph()
     with self.assertRaises(IndexError) as context:
         g.get_out_neighbors("test")
         self.assertTrue(context.exception)