def reverse(graph):
    """Reverse the direction of edges in a graph."""
    reverse_graph = [[] for _ in range(len(graph))]

    for node, children in enumerate(graph):
        for child in children:
            reverse_graph[child].append(node)

    return reverse_graph