def _longest_paths(G):
    """Return a dict of nodes with values corresponding to longest paths from node"""
    lp = {}
    lp_old = lp.copy()
    for node in G.nodes():
        lp[node] = 0
    while lp != lp_old:
        lp_old = lp.copy()
        for edge in G.edges():
            lp[edge[1]] = max(lp[edge[1]], lp[edge[0]] + 1)
    return lp
