def pi(dest, E):
    """Return ``s`` in ``(s, d, w)`` with ``d`` == `dest` and `w` minimized.

    :param dest:    destination vertex
    :type dest:     int
    :param E:       a set of edges
    :type E:        [(int, int, float), ...]
    :return:        vertex with cheapest edge connected to `dest`
    :rtype:         int or None
    """
    src, weight = None, 0
    for (s, d, w) in E:
        if d == dest:
            if src is None or w < weight:
                src = s
                weight = w
    return src