parameters: (self, graph, unbridged_graph)
docstring: This function will change a bridge's graph path based on what's currently available. This
          is to handle the case where a bridge has multiple possible graph paths, but its first
          choice isn't available anymore (because other bridges used up those segments).
          It has to balance the path quality with the path availability to make a choice.
docstring_summary: This function will change a bridge's graph path based on what's currently available. This
          is to handle the case where a bridge has multiple possible graph paths, but its first
          choice isn't available anymore (because other bridges used up those segments).
          It has to balance the path quality with the path availability to make a choice.
docstring_tokens: This function will change a bridge s graph path based on what s currently available . This is to handle the case where a bridge has multiple possible graph paths but its first choice isn t available anymore ( because other bridges used up those segments ) . It has to balance the path quality with the path availability to make a choice .
function: def set_path_based_on_availability(self, graph, unbridged_graph):
          """
          This function will change a bridge's graph path based on what's currently available. This
          is to handle the case where a bridge has multiple possible graph paths, but its first
          choice isn't available anymore (because other bridges used up those segments).
          It has to balance the path quality with the path availability to make a choice.
          """
          best_path = self.all_paths[0][0]
          best_sequence = unbridged_graph.get_path_sequence(best_path)
          best_scaled_score = self.all_paths[0][3]
          best_availability = graph.get_path_availability(best_path)
          for i in range(1, len(self.all_paths)):
              potential_path = self.all_paths[i][0]
              potential_scaled_score = self.all_paths[i][3]
              potential_availability = graph.get_path_availability(potential_path)
  
              # relative_score measures how much worse this path aligned than the current best.
              # Differences matter more close to scores of 100. E.g. 99 to 97 is a big drop in
              # score, but 79 to 77 is not as large of a drop.
              if potential_scaled_score == 100.0:
                  relative_score = 1.0
              else:
                  relative_score = (100.0 - best_scaled_score) / (100.0 - potential_scaled_score)
                  relative_score = min(1.0, relative_score)
  
              # relative_availability measures how much more available this path is than the current
              # best. We use 1.1 (instead of 1.0) in the equation to attenuate the affect of
              # availability a bit (because score is more important).
              relative_availability = (1.1 - best_availability) / (1.1 - potential_availability)
              relative_availability = min(2.0, relative_availability)
  
              # If this path looks better than our current best (considering both score and
              # availability), then it becomes the new best.
              if relative_score * relative_availability > 1.0:
                  best_path = potential_path
                  best_sequence = unbridged_graph.get_path_sequence(potential_path)
                  best_scaled_score = potential_scaled_score
                  best_availability = potential_availability
  
          self.graph_path = best_path
          self.bridge_sequence = best_sequence
function_tokens: def set_path_based_on_availability ( self , graph , unbridged_graph ) : best_path = self . all_paths [ 0 ] [ 0 ] best_sequence = unbridged_graph . get_path_sequence ( best_path ) best_scaled_score = self . all_paths [ 0 ] [ 3 ] best_availability = graph . get_path_availability ( best_path ) for i in range ( 1 , len ( self . all_paths ) ) : potential_path = self . all_paths [ i ] [ 0 ] potential_scaled_score = self . all_paths [ i ] [ 3 ] potential_availability = graph . get_path_availability ( potential_path ) # relative_score measures how much worse this path aligned than the current best. # Differences matter more close to scores of 100. E.g. 99 to 97 is a big drop in # score, but 79 to 77 is not as large of a drop. if potential_scaled_score == 100.0 : relative_score = 1.0 else : relative_score = ( 100.0 - best_scaled_score ) / ( 100.0 - potential_scaled_score ) relative_score = min ( 1.0 , relative_score ) # relative_availability measures how much more available this path is than the current # best. We use 1.1 (instead of 1.0) in the equation to attenuate the affect of # availability a bit (because score is more important). relative_availability = ( 1.1 - best_availability ) / ( 1.1 - potential_availability ) relative_availability = min ( 2.0 , relative_availability ) # If this path looks better than our current best (considering both score and # availability), then it becomes the new best. if relative_score * relative_availability > 1.0 : best_path = potential_path best_sequence = unbridged_graph . get_path_sequence ( potential_path ) best_scaled_score = potential_scaled_score best_availability = potential_availability self . graph_path = best_path self . bridge_sequence = best_sequence