def has_edges(edge, sets) -> bool:
    """Check whether the edge exists in the graph to avoid cycle.

       Args:
           edge(tuple): Represents an edge (input node, output node)
           sets(set): Stores inserted edges

       Return:
           Whether edge has already been inserted to the grpah
    """
    return edge in sets