def _hungarian(cost_matrix):
 state = _HungarianState(cost_matrix)
 step = (None if (0 in cost_matrix.shape) else _step1)
 while (step is not None):
  step = step(state)
 results = np.array(np.where((state.marked == 1))).T
 if state.transposed:
  results = results[:, ::(-1)]
 return results

def _hungarian ( cost_matrix ) : state = _HungarianState ( cost_matrix ) step = ( None if ( 0 in cost_matrix . shape ) else _step1 ) while ( step is not None ) : step = step ( state ) results = np . array ( np . where ( ( state . marked == 1 ) ) ) . T if state . transposed : results = results [ : , : : ( - 1 ) ] return results
the hungarian algorithm .