Ejemplo n.º 1
0
    def test_init_acycle(
        self,
        graph: DiGraph,
        vertices,
        edges,
        has_edges,
        has_vertices,
        exception,
        inverse_graph,
    ):
        if exception:
            with self.assertRaises(exception):
                graph = AcyclicDiGraph(graph)

        for f, t in vertices:
            graph.insert(f, t)

        self.assertEquals(edges, graph.vertexes())

        for edge, has_edge in has_edges:
            self.assertEquals(has_edge, graph.has_vertex(edge))

        for vertice, has_vertice in has_vertices:
            self.assertEquals(has_vertice, graph.has_edge(*vertice))

        inv_graph = graph.reverse()
        for edge in inv_graph.vertexes():
            self.assertEqual(
                inverse_graph[edge],
                inv_graph.vertexes_to(edge),
            )
Ejemplo n.º 2
0
    def test_init(
        self,
        graph: DiGraph,
        vertices,
        edges,
        has_edges,
        has_vertices,
        exception,
        inverse_graph,
    ):
        for f, t in vertices:
            graph.insert(f, t)

        self.assertEquals(edges, graph.vertexes())

        for edge, has_edge in has_edges:
            self.assertEquals(has_edge, graph.has_vertex(edge))

        for vertice, has_vertice in has_vertices:
            self.assertEquals(has_vertice, graph.has_edge(*vertice))

        inv_graph = graph.reverse()
        for edge in inv_graph.vertexes():
            self.assertEqual(
                inverse_graph[edge],
                inv_graph.vertexes_to(edge),
            )