def path_exists(g, start, end):
    """
    Given a networkx graph g,
    do a dfs and determine if there
    exists a path between start
    and end.

    :return: True if there is a
    path from start to end, False
    otherwise.

    """
    st = []

    visited = set()

    st.append(start)
    while st:
        current = st.pop()

        visited |= {current}

        if current == end:
            return True

        for c in g.neighbors(current):
            if c not in visited:
                st.append(c)

    return end in visited