(graph, mode, length)
Calculates cul-de-sac length in a graph.
Calculates cul-de-sac length in a graph.
Calculates cul - de - sac length in a graph .
def _cds_length(graph, mode, length):
    """
    Calculates cul-de-sac length in a graph.
    """
    lens = []
    for u, v, k, cds in graph.edges.data("cdsbool", keys=True):
        if cds:
            lens.append(graph[u][v][k][length])
    if mode == "sum":
        return sum(lens)
    if mode == "mean":
        return np.mean(lens)
    raise ValueError("Mode {} is not supported. Use 'sum' or 'mean'.".format(mode))
def _cds_length ( graph , mode , length ) : lens = [ ] for u , v , k , cds in graph . edges . data ( "cdsbool" , keys = True ) : if cds : lens . append ( graph [ u ] [ v ] [ k ] [ length ] ) if mode == "sum" : return sum ( lens ) if mode == "mean" : return np . mean ( lens ) raise ValueError ( "Mode {} is not supported. Use 'sum' or 'mean'." . format ( mode ) )