def _verts_within_dist(graph, sources, max_dist):
 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):
     dist_map[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)

def _verts_within_dist ( graph , sources , max_dist ) : 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 ) : dist_map [ 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 )
find all vertices wihin a maximum geodesic distance from source .