def can_add_relation(s, d, relations, new_relations):
    """
    returns true if (s, d) is a valid new relation
    """
    if s == d:
        return False
    for r in relations:
        if r.entry1.id == s and r.entry2.id == d:
            return False
        if r.entry2.id == s and r.entry1.id == d:
            return False
    for ns, nd in new_relations:
        if ns == s and nd == d:
            return False
        if nd == s and ns == d:
            return False
    return True