parameters: (graph, start, end, min_length, max_length)
return_statement: return final_paths
docstring: Returns a list of all paths which connect the starting segment to the ending segment and
      are within the length bounds. The start and end segments are not themselves included in the
      paths. Returns an empty list if no paths exist.
      Loops in the graph (especially loops of short segments which don't add much to the path
      length) can result in very large numbers of potential paths in complex areas. To somewhat
      manage this, we exclude paths which include too many copies of a segment. 'Too many copies'
      is defined as double the copy depth count or the double the depth over start/end depth.
docstring_summary: Returns a list of all paths which connect the starting segment to the ending segment and
      are within the length bounds. The start and end segments are not themselves included in the
      paths. Returns an empty list if no paths exist.
      Loops in the graph (especially loops of short segments which don't add much to the path
      length) can result in very large numbers of potential paths in complex areas. To somewhat
      manage this, we exclude paths which include too many copies of a segment. 'Too many copies'
      is defined as double the copy depth count or the double the depth over start/end depth.
docstring_tokens: Returns a list of all paths which connect the starting segment to the ending segment and are within the length bounds . The start and end segments are not themselves included in the paths . Returns an empty list if no paths exist . Loops in the graph ( especially loops of short segments which don t add much to the path length ) can result in very large numbers of potential paths in complex areas . To somewhat manage this we exclude paths which include too many copies of a segment . Too many copies is defined as double the copy depth count or the double the depth over start / end depth .
function: def all_paths(graph, start, end, min_length, max_length):
      """
      Returns a list of all paths which connect the starting segment to the ending segment and
      are within the length bounds. The start and end segments are not themselves included in the
      paths. Returns an empty list if no paths exist.
      Loops in the graph (especially loops of short segments which don't add much to the path
      length) can result in very large numbers of potential paths in complex areas. To somewhat
      manage this, we exclude paths which include too many copies of a segment. 'Too many copies'
      is defined as double the copy depth count or the double the depth over start/end depth.
      """
      if start not in graph.forward_links:
          return []
  
      start_seg = graph.segments[abs(start)]
      end_seg = graph.segments[abs(end)]
      start_end_depth = weighted_average(start_seg.depth, end_seg.depth,
                                         start_seg.get_length(), end_seg.get_length())
      working_paths = [[x] for x in graph.forward_links[start]]
      final_paths = []
      while working_paths:
          new_working_paths = []
          for working_path in working_paths:
              last_seg = working_path[-1]
              if last_seg == end:
                  potential_result = working_path[:-1]
                  if graph.get_path_length(potential_result) >= min_length:
                      final_paths.append(potential_result)
                      if len(final_paths) > settings.ALL_PATH_SEARCH_MAX_FINAL_PATHS:
                          raise TooManyPaths
              elif graph.get_path_length(working_path) <= max_length and \
                      last_seg in graph.forward_links:
                  for next_seg in graph.forward_links[last_seg]:
                      max_allowed_count = graph.max_path_segment_count(next_seg, start_end_depth)
                      count_so_far = working_path.count(next_seg) + working_path.count(-next_seg)
                      if count_so_far < max_allowed_count:
                          new_working_paths.append(working_path + [next_seg])
  
          # If the number of working paths is too high, we give up.
          if len(working_paths) > settings.ALL_PATH_SEARCH_MAX_WORKING_PATHS:
              raise TooManyPaths
          working_paths = new_working_paths
  
      return final_paths
function_tokens: def all_paths ( graph , start , end , min_length , max_length ) : if start not in graph . forward_links : return [ ] start_seg = graph . segments [ abs ( start ) ] end_seg = graph . segments [ abs ( end ) ] start_end_depth = weighted_average ( start_seg . depth , end_seg . depth , start_seg . get_length ( ) , end_seg . get_length ( ) ) working_paths = [ [ x ] for x in graph . forward_links [ start ] ] final_paths = [ ] while working_paths : new_working_paths = [ ] for working_path in working_paths : last_seg = working_path [ - 1 ] if last_seg == end : potential_result = working_path [ : - 1 ] if graph . get_path_length ( potential_result ) >= min_length : final_paths . append ( potential_result ) if len ( final_paths ) > settings . ALL_PATH_SEARCH_MAX_FINAL_PATHS : raise TooManyPaths elif graph . get_path_length ( working_path ) <= max_length and last_seg in graph . forward_links : for next_seg in graph . forward_links [ last_seg ] : max_allowed_count = graph . max_path_segment_count ( next_seg , start_end_depth ) count_so_far = working_path . count ( next_seg ) + working_path . count ( - next_seg ) if count_so_far < max_allowed_count : new_working_paths . append ( working_path + [ next_seg ] ) # If the number of working paths is too high, we give up. if len ( working_paths ) > settings . ALL_PATH_SEARCH_MAX_WORKING_PATHS : raise TooManyPaths working_paths = new_working_paths return final_paths