def irregular_edge_count(edges):
    """
    Computes ratio of multiedges and loops and simple edges

    :param edges: A list of tuples representing the set of edges of a graph.
    :return: The ratio described above.
    """
    unique_edges = set()
    loop_counter, multi_edge_cnt = 0, 0
    for e in edges:
        u, v = e
        # check if it is a loop
        if u == v: loop_counter += 1

        # check if it is multiedge
        if (u, v) in unique_edges or (v, u) in unique_edges: multi_edge_cnt += 1
        else: unique_edges.add(e)

    return float(loop_counter + multi_edge_cnt) / float(len(edges))