

def _verts_within_dist(graph, sources, max_dist):
    'Find all vertices wihin a maximum geodesic distance from source\n\n    Parameters\n    ----------\n    graph : scipy.sparse.csr_matrix\n        Sparse matrix with distances between adjacent vertices.\n    sources : list of int\n        Source vertices.\n    max_dist : float\n        Maximum geodesic distance.\n\n    Returns\n    -------\n    verts : array\n        Vertices within max_dist.\n    dist : array\n        Distances from source vertex.\n    '
    dist_map = {
        
    }
    verts_added_last = []
    for source in sources:
        dist_map[source] = 0
        verts_added_last.append(source)
    while (len(verts_added_last) > 0):
        verts_added = []
        for i in verts_added_last:
            v_dist = dist_map[i]
            row = graph[i, :]
            neighbor_vert = row.indices
            neighbor_dist = row.data
            for (j, d) in zip(neighbor_vert, neighbor_dist):
                n_dist = (v_dist + d)
                if (j in dist_map):
                    if (n_dist < dist_map[j]):
                        dist_map[j] = n_dist
                elif (n_dist <= max_dist):
                    neighbor_dist[j] = n_dist
                    verts_added.append(j)
        verts_added_last = verts_added
    verts = np.sort(np.array(list(dist_map.keys()), dtype=np.int))
    dist = np.array([dist_map[v] for v in verts])
    return (verts, dist)

dataset/ETHPy150Open mne-tools/mne-python/mne/label.py _verts_within_dist/VarMisuse@165/401 `dist_map`->`neighbor_dist`