def compute_distance_from_node(elements, node_points, ground_nodes): #incoming_supporters, _ = neighbors_from_orders(get_supported_orders( # element_from_id.values(), node_points)) nodes = nodes_from_elements(elements) neighbors = adjacent_from_edges(elements) edge_costs = {edge: get_distance(node_points[edge[0]], node_points[edge[1]]) for edge in elements} #edge_costs = {edge: np.abs(node_points[edge[1]] - node_points[edge[0]])[2] # for edge in elements} edge_costs.update({edge[::-1]: distance for edge, distance in edge_costs.items()}) successor_fn = lambda v: neighbors[v] cost_fn = lambda v1, v2: edge_costs[v1, v2] # TODO: z on cost function return dijkstra(ground_nodes & nodes, successor_fn, cost_fn)
def current_failed_cluster(binding): assert 1 <= binding.visits failed_result = binding.skeleton.stream_plan[binding.index] successful_results = [ result for i, result in enumerate(binding.skeleton.stream_plan) if i not in binding.stream_indices ] stream_plan = successful_results + [failed_result] partial_orders = get_partial_orders(stream_plan) # All connected components #return get_connected_components(stream_plan, partial_orders) # Only the failed connected component return [ grow_component([failed_result], adjacent_from_edges(partial_orders)) ]