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),
            )
    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),
            )
    def test_union_acycle(self, a: DiGraph, b: DiGraph, vertices, exception):
        a = AcyclicDiGraph(a)
        b = AcyclicDiGraph(b)

        if exception:
            with self.assertRaises(exception):
                a.union(b)
        else:
            a.union(b)

            self.assertEquals(set(vertices.keys()), a.vertexes())
            for edge, vertices in vertices.items():
                self.assertEquals(a.vertexes_to(edge), vertices)
    def test_union(self, a: DiGraph, b: DiGraph, vertices, exception):
        a.union(b)

        self.assertEquals(set(vertices.keys()), a.vertexes())
        for edge, vertices in vertices.items():
            self.assertEquals(a.vertexes_to(edge), vertices)