def reverse_graph(y):
    """ Function to create a dictionary containing edges of y reversed.

    INPUTS
    ======
    y : ADnum

    OUTPUTS
    =======
    A dictionary
    """
    d = y.graph
    parents = {}
    for key in d:
        neighbors = d[key]
        for neighbor in neighbors:
            if neighbor[0] not in parents:
                parents[neighbor[0]] = []
            parents[neighbor[0]].append((key, neighbor[1]))
    return parents
