def _CopyExcluding(er, s, t):
    """Return a copy of er, excluding all those involving triangles s and t.

    Args:
      er: list of (weight, e, tl, tr) - see _ERGraph
      s: 3-tuple of int - a triangle
      t: 3-tuple of int - a triangle
    Returns:
      Copy of er excluding those with tl or tr == s or t
    """
    ans = []
    for e in er:
        _, _, tl, tr = e
        if tl == s or tr == s or tl == t or tr == t:
            continue
        ans.append(e)
    return ans
