def self_loop_proportion(Gu: nx.MultiGraph) -> float:
    """
    Calculate percent of edges that are self-loops in a graph.

    A self-loop is defined as an edge from node `u` to node `v` where `u==v`.

    Parameters
    ----------
    Gu
        Undirected input graph.

    Returns
    -------
    proportion
        Proportion of graph edges that are self-loops.
    """
    if nx.is_directed(Gu):  # pragma: no cover
        msg = "`Gu` must be undirected."
        raise ValueError(msg)
    return float(sum(u == v for u, v, k in Gu.edges) / len(Gu.edges))

    Calculate percent of edges that are self-loops in a graph.

    A self-loop is defined as an edge from node `u` to node `v` where `u==v`.

    Parameters
    ----------
    Gu
        Undirected input graph.

    Returns
    -------
    proportion
        Proportion of graph edges that are self-loops.
    
osmnx/stats.py