def voronoi_cells(G, center_nodes, weight='weight'):
 paths = nx.multi_source_dijkstra_path(G, center_nodes, weight=weight)
 nearest = {v: p[0] for (v, p) in paths.items()}
 cells = groups(nearest)
 unreachable = (set(G) - set(nearest))
 if unreachable:
  cells['unreachable'] = unreachable
 return cells

def voronoi_cells ( G , center_nodes , weight = 'weight' ) : paths = nx . multi_source_dijkstra_path ( G , center_nodes , weight = weight ) nearest = { v : p [ 0 ] for ( v , p ) in paths . items ( ) } cells = groups ( nearest ) unreachable = ( set ( G ) - set ( nearest ) ) if unreachable : cells [ 'unreachable' ] = unreachable return cells
returns the voronoi cells centered at center_nodes with respect to the shortest-path distance metric .