def test_del_edge(): graph = DirectedGraph({1: [2]}) assert graph.is_edge(1, 2) graph.del_edge(1, 2) assert not graph.is_edge(1, 2) graph = DirectedGraph({1: [2, 2]}) assert graph.is_edge(1, 2) graph.del_edge(1, 2) assert graph.is_edge(1, 2) graph.del_edge(1, 2) assert not graph.is_edge(1, 2)
def test_add_edge(self): d = DirectedGraph() self.assertFalse(d.is_edge(1, 2)) self.assertEqual(d.get_outdegree(1), 0) d.add_edge(1, 2) self.assertEqual(d.get_outdegree(1), 1) self.assertEqual(d.get_indegree(2), 1) self.assertTrue(d.is_edge(1, 2)) d.add_edge(1, 2) self.assertTrue(1, 2) self.assertEqual(d.get_indegree(2), 1)
def test_add_edge(): graph = DirectedGraph() assert not graph.is_edge(1, 2) assert graph.get_outdegree(1) == 0 graph.add_edge(1, 2) assert graph.get_outdegree(1) == 1 assert graph.get_indegree(2) == 1 assert graph.is_edge(1, 2) graph.add_edge(1, 2) assert graph.get_indegree(1) == 0 assert graph.get_outdegree(1) == 2 assert graph.get_indegree(2) == 2
def test_del_edge(self): d = DirectedGraph({1: [2]}) self.assertTrue(d.is_edge(1, 2)) d.del_edge(1, 2) self.assertFalse(d.is_edge(1, 2))
def test_is_edge(self): d = DirectedGraph({1: [2]}) self.assertTrue(d.is_edge(1, 2)) self.assertFalse(d.is_edge(2, 1))
def test_is_edge(): graph = DirectedGraph({1: [2]}) assert graph.is_edge(1, 2) assert not graph.is_edge(2, 1)