def remove_multiedges(E):
    """Returns ``(s, d, w)`` with unique ``(s, d)`` values and `w` minimized.

    :param E:       a set of edges
    :type E:        [(int, int, float)]
    :return:        a subset of edges `E`
    :rtype:         [(int, int, float), ...]
    """
    result = []
    exclusion = set()
    for i, (si, di, wi) in enumerate(E):
        if i in exclusion:
            continue
        minimum = 0
        for j in range(i + 1, len(E)):
            if j in exclusion:
                continue
            sj, dj, wj = E[j]
            if si == sj and di == dj:
                if wi > wj:
                    exclusion.add(i)
                elif wi < wj:
                    exclusion.add(j)
        if i in exclusion:
            continue
        result.append(E[i])
    return result