def proba_fail(origin, next_ids, graph):
    """ Return the probability that the origin should be predicted before all the next_ids (supposing independency)"""
    prod = 1
    for next_id in next_ids:
        if next_id in graph[origin]:
            prod *= graph[origin][next_id]
        else:
            prod *= 1-graph[next_id][origin]
    return prod