(graph, name="meanlen", length="mm_len", verbose=True)
return netx
Calculates mean distance to neighbouring nodes.

    Mean of values in ``length`` attribute.

    Parameters
    ----------
    graph : networkx.Graph
        Graph representing street network.
        Ideally generated from GeoDataFrame using :func:`momepy.gdf_to_nx`
    name : str, optional
        calculated attribute name
    length : str, optional
        name of attribute of segment length (geographical)
    verbose : bool (default True)
        if True, shows progress bars in loops and indication of steps

    Returns
    -------
    Graph
        networkx.Graph

    Examples
    --------
    >>> network_graph = mm.mean_node_dist(network_graph)
Calculates mean distance to neighbouring nodes.
Calculates mean distance to neighbouring nodes .
def mean_node_dist(graph, name="meanlen", length="mm_len", verbose=True):
    """
    Calculates mean distance to neighbouring nodes.

    Mean of values in ``length`` attribute.

    Parameters
    ----------
    graph : networkx.Graph
        Graph representing street network.
        Ideally generated from GeoDataFrame using :func:`momepy.gdf_to_nx`
    name : str, optional
        calculated attribute name
    length : str, optional
        name of attribute of segment length (geographical)
    verbose : bool (default True)
        if True, shows progress bars in loops and indication of steps

    Returns
    -------
    Graph
        networkx.Graph

    Examples
    --------
    >>> network_graph = mm.mean_node_dist(network_graph)

    """
    netx = graph.copy()

    for n, nbrs in tqdm(netx.adj.items(), total=len(netx), disable=not verbose):
        lengths = []
        for nbr, keydict in nbrs.items():
            for key, eattr in keydict.items():
                lengths.append(eattr[length])
        netx.nodes[n][name] = np.mean(lengths)

    return netx
def mean_node_dist ( graph , name = "meanlen" , length = "mm_len" , verbose = True ) : netx = graph . copy ( ) for n , nbrs in tqdm ( netx . adj . items ( ) , total = len ( netx ) , disable = not verbose ) : lengths = [ ] for nbr , keydict in nbrs . items ( ) : for key , eattr in keydict . items ( ) : lengths . append ( eattr [ length ] ) netx . nodes [ n ] [ name ] = np . mean ( lengths ) return netx