def share_edge(label, uv1, uv2, h, w):
    """Determine if two uv share an edge."""
    if uv1[0] == uv2[0]:
        if uv1[0] == 0 or uv1[0] == w:
            return True
    elif uv1[1] == uv2[1]:
        if uv1[1] == 0 or uv1[1] == h:
            return True
    else:
        return False