def connected_components(edges):
    """
    Computes the connected components.

    @param      edges       edges
    @return                 dictionary { vertex : id of connected components }
    """
    res = {}
    for k in edges:
        for _ in k[:2]:
            if _ not in res:
                res[_] = _
    modif = 1
    while modif > 0:
        modif = 0
        for k in edges:
            a, b = k[:2]
            r, s = res[a], res[b]
            if r != s:
                m = min(res[a], res[b])
                res[a] = res[b] = m
                modif += 1
    return res
