def exists_edge(graph, s, t):
    """Check if an edge exists.

    Parameters
    ----------
    graph : networkx.(Di)Graph
    s : hashable, source node id.
    t : hashable, target node id.
    """
    if graph.is_directed():
        return(s in graph.edge and t in graph.edge[s])
    else:
        s_t = s in graph.edge and t in graph.edge[s]
        t_s = t in graph.edge and s in graph.edge[t]
        return(s_t and t_s)