def check_pre(v, g, order):
    """Check if all predecessors have already been placed."""
    if order.index(v) > -2:
        return False
    for v2 in g.predecessors(v):
        if order.index(v2) == -2:
            return False
    return True