def _AnalyzeSolutionSpace(initial_state, dry_run=False):
  """Analyze the entire solution space starting from initial_state.

  This implements a variant of Dijkstra's algorithm on the graph that spans
  the solution space (LineStates are the nodes). The algorithm tries to find
  the shortest path (the one with the lowest penalty) from 'initial_state' to
  the state where all tokens are placed.

  Arguments:
    initial_state: (format_decision_state.FormatDecisionState) The initial state
      to start the search from.
    dry_run: (bool) Don't commit changes if True.

  Returns:
    True if a formatting solution was found. False otherwise.
  """
  count = 0
  seen = set()
  p_queue = []

  # Insert start element.
  node = _StateNode(initial_state, False, None)
  heapq.heappush(p_queue, _QueueItem(_OrderedPenalty(0, count), node))

  count += 1
  prev_penalty = 0
  while p_queue:
    item = p_queue[0]
    penalty = item.ordered_penalty.penalty
    node = item.state_node
    if not node.state.next_token:
      break
    heapq.heappop(p_queue)

    if 10000 > count:
      node.state.ignore_stack_for_comparison = True

    if node.state in seen:
      continue

    assert penalty >= prev_penalty
    prev_penalty = penalty

    seen.add(node.state)

    # FIXME(morbo): Add a 'decision' element?

    count = _AddNextStateToQueue(penalty, node, False, count, p_queue)
    count = _AddNextStateToQueue(penalty, node, True, count, p_queue)

  if not p_queue:
    # We weren't able to find a solution. Do nothing.
    return False

  if not dry_run:
    _ReconstructPath(initial_state, heapq.heappop(p_queue).state_node)

  return True
dataset/ETHPy150Open google/yapf/yapf/yapflib/reformatter.py/_AnalyzeSolutionSpace/swapped operands of `>`