




def        lowerCAmelCase_			(  snake_case_  ):
      _A							:  str    =		set()
      # edges = list of graph's edges
      _A							:  Optional[Any]    =		get_edges(snake_case_  )

      # While there are still elements in edges list, take an arbitrary edge
      # (from_node, to_node) and add his extremity to chosen_vertices and then
      # remove all arcs adjacent to the from_node and to_node
      while edges:
            _A    ,     _A							:  Optional[int]    =		edges.pop()
            chosen_vertices.add(snake_case_  )
            chosen_vertices.add(snake_case_  )
            for edge in edges.copy():
                  if from_node in edge or to_node in edge:
                        edges.discard(snake_case_  )
      return chosen_vertices







def        lowerCAmelCase_			(  snake_case_  ):
      _A							:  Optional[int]    =		set()
      for from_node, to_nodes in graph.items():
            for to_node in to_nodes:
                  edges.add((from_node, to_node)  )
      return edges


if __name__ == "__main__":
  import doctest

  doctest.testmod()

  # graph = {0: [1, 3], 1: [0, 3], 2: [0, 3, 4], 3: [0, 1, 2], 4: [2, 3]}
  # print(f"Matching vertex cover:\n{matching_min_vertex_cover(graph)}")







import operator







def        lowerCAmelCase_			(  snake_case_,snake_case_ = False,snake_case_ = None  ):
      _A							:  str    =		operator.lt if reverse else operator.gt
      _A							:  Optional[Any]    =		solution or []

      if not arr:
            return solution

      _A							:  Dict    =		[arr.pop(0  )]
      for i, item in enumerate(snake_case_  ):
            if _operator(snake_case_,sublist[-1]  ):
                  sublist.append(snake_case_  )
                  arr.pop(snake_case_  )

    #  merging sublist into solution list
      if not solution:
            solution.extend(snake_case_  )
      else:
            while sublist:
                  _A							:  Union[str, Any]    =		sublist.pop(0  )
                  for i, xx in enumerate(snake_case_  ):
                        if not _operator(snake_case_,snake_case_  ):
                              solution.insert(snake_case_,snake_case_  )
                              break
                  else:
                        solution.append(snake_case_  )

      strand_sort(snake_case_,snake_case_,snake_case_  )
      return solution


if __name__ == "__main__":
  assert strand_sort([4, 3, 5, 1, 2]) == [1, 2, 3, 4, 5]
  assert strand_sort([4, 3, 5, 1, 2], reverse=True) == [5, 4, 3, 2, 1]

