def test_prim(self):
        graph = prim(self.graph)

        assert not contains_cycle(graph)

        assert {Edge(2, 1, 2), Edge(1, 3, 4), Edge(3, 2, 3), Edge(4, 3, 5)} == set(graph.get_all_edges())

        assert len(graph.get_all_edges()) == len(graph.get_vertices()) - 1
Exemplo n.º 2
0
    def test_prim(self):
        graph = prim(self.graph)

        assert not contains_cycle(graph)

        assert {Edge(2, 1, 2),
                Edge(1, 3, 4),
                Edge(3, 2, 3),
                Edge(4, 3, 5)} == set(graph.get_all_edges())

        assert len(graph.get_all_edges()) == len(graph.get_vertices()) - 1
Exemplo n.º 3
0
 def test_topological_sort(self):
     assert not contains_cycle(self.undirected)
     self.undirected.add_edge(4, 5, 6)
     assert contains_cycle(self.undirected)