Module Expr Str Import alias identifier ImportFrom alias FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore Call AttributeLoad Call NameLoad NameLoad attr Expr Call AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr NameLoad keyword NameLoad Assign AttributeStore NameLoad attr TupleLoad Num Num Return NameLoad decorator_list ClassDef bases NameLoad body Expr Str FunctionDef arguments args NameParam NameParam defaults body Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assign NameStore CompareLt SubscriptLoad AttributeLoad NameLoad attr Index Num SubscriptLoad AttributeLoad NameLoad attr Index Num If NameLoad body Assign AttributeStore NameLoad attr Call AttributeLoad AttributeLoad NameLoad attr attr orelse Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr Assign AttributeStore NameLoad attr NameLoad Assign TupleStore NameStore NameStore AttributeLoad AttributeLoad NameLoad attr attr Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr NameLoad keyword AttributeLoad NameLoad attr Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr NameLoad keyword AttributeLoad NameLoad attr Assign AttributeStore NameLoad attr Num Assign AttributeStore NameLoad attr Num Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr TupleLoad BinOpAdd NameLoad NameLoad Num keyword NameLoad Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr TupleLoad NameLoad NameLoad keyword NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore Call AttributeLoad NameLoad attr CompareEq SubscriptLoad AttributeLoad NameLoad attr Index NameLoad Num If CompareNotEq SubscriptLoad AttributeLoad NameLoad attr Index TupleLoad NameLoad NameLoad Num body Assign NameStore Num Return NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Assign SubscriptStore AttributeLoad NameLoad attr Slice NameLoad Assign SubscriptStore AttributeLoad NameLoad attr Slice NameLoad decorator_list decorator_list FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore Call NameLoad NameLoad Assign NameStore IfExp CompareIn Num AttributeLoad NameLoad attr NameLoad NameLoad While CompareIsNot NameLoad NameLoad body Assign NameStore Call NameLoad NameLoad Assign NameStore AttributeLoad Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr CompareEq AttributeLoad NameLoad attr Num attr If AttributeLoad NameLoad attr body Assign NameStore SubscriptLoad NameLoad ExtSlice Slice Slice Num Return NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str AugAssignSub AttributeStore NameLoad attr SubscriptLoad Call AttributeLoad AttributeLoad NameLoad attr attr keyword Num ExtSlice Slice Index AttributeLoad NameLoad attr For TupleStore NameStore NameStore Call NameLoad Call AttributeLoad NameLoad attr CompareEq AttributeLoad NameLoad attr Num body If BoolOpAnd SubscriptLoad AttributeLoad NameLoad attr Index NameLoad SubscriptLoad AttributeLoad NameLoad attr Index NameLoad body Assign SubscriptStore AttributeLoad NameLoad attr Index TupleLoad NameLoad NameLoad Num Assign SubscriptStore AttributeLoad NameLoad attr Index NameLoad NameLoad Assign SubscriptStore AttributeLoad NameLoad attr Index NameLoad NameLoad Expr Call AttributeLoad NameLoad attr Return NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore CompareEq AttributeLoad NameLoad attr Num Assign SubscriptStore AttributeLoad NameLoad attr Index Call AttributeLoad NameLoad attr NameLoad keyword Num NameLoad If CompareLt Call AttributeLoad NameLoad attr SubscriptLoad AttributeLoad AttributeLoad NameLoad attr attr Index Num body Return NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore Call AttributeLoad CompareEq AttributeLoad NameLoad attr Num attr AttributeLoad NameLoad attr Assign NameStore BinOpMult NameLoad SubscriptLoad AttributeLoad NameLoad attr ExtSlice Slice Index AttributeLoad NameLoad attr AugAssignMult NameStore Call NameLoad AttributeLoad NameLoad attr keyword AttributeLoad NameLoad attr keyword NameLoad Assign NameStore SubscriptLoad AttributeLoad AttributeLoad NameLoad attr attr Index Num Assign NameStore SubscriptLoad AttributeLoad AttributeLoad NameLoad attr attr Index Num While NameLoad body Assign TupleStore NameStore NameStore Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr NameLoad TupleLoad NameLoad NameLoad If CompareEq SubscriptLoad NameLoad Index TupleLoad NameLoad NameLoad Num body Return NameLoad orelse Assign SubscriptStore AttributeLoad NameLoad attr Index TupleLoad NameLoad NameLoad Num Assign NameStore Call AttributeLoad NameLoad attr CompareEq SubscriptLoad AttributeLoad NameLoad attr Index NameLoad Num If UnaryOpNot CompareEq SubscriptLoad AttributeLoad NameLoad attr Index TupleLoad NameLoad NameLoad Num body Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad Return NameLoad orelse Assign NameStore NameLoad Assign SubscriptStore AttributeLoad NameLoad attr Index NameLoad NameLoad Assign SubscriptStore AttributeLoad NameLoad attr Index NameLoad NameLoad Assign SubscriptStore NameLoad ExtSlice Slice Index NameLoad BinOpMult SubscriptLoad NameLoad ExtSlice Slice Index NameLoad Call NameLoad AttributeLoad NameLoad attr keyword AttributeLoad NameLoad attr keyword NameLoad Assign SubscriptStore NameLoad Index NameLoad Num decorator_list FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore Num Assign NameStore AttributeLoad NameLoad attr Assign SubscriptStore NameLoad Index TupleLoad NameLoad Num AttributeLoad NameLoad attr Assign SubscriptStore NameLoad Index TupleLoad NameLoad Num AttributeLoad NameLoad attr While NameLoad body Assign NameStore Call AttributeLoad NameLoad attr CompareEq SubscriptLoad AttributeLoad NameLoad attr ExtSlice Slice Index SubscriptLoad NameLoad Index TupleLoad NameLoad Num Num If UnaryOpNot CompareEq SubscriptLoad AttributeLoad NameLoad attr Index TupleLoad NameLoad SubscriptLoad NameLoad Index TupleLoad NameLoad Num Num body Break orelse AugAssignAdd NameStore Num Assign SubscriptStore NameLoad Index TupleLoad NameLoad Num NameLoad Assign SubscriptStore NameLoad Index TupleLoad NameLoad Num SubscriptLoad NameLoad Index TupleLoad BinOpSub NameLoad Num Num Assign NameStore Call AttributeLoad NameLoad attr CompareEq SubscriptLoad AttributeLoad NameLoad attr Index SubscriptLoad NameLoad Index TupleLoad NameLoad Num Num If CompareNotEq SubscriptLoad AttributeLoad NameLoad attr Index TupleLoad NameLoad NameLoad Num body Assign NameStore Num AugAssignAdd NameStore Num Assign SubscriptStore NameLoad Index TupleLoad NameLoad Num SubscriptLoad NameLoad Index TupleLoad BinOpSub NameLoad Num Num Assign SubscriptStore NameLoad Index TupleLoad NameLoad Num NameLoad For NameStore Call NameLoad BinOpAdd NameLoad Num body If CompareEq SubscriptLoad AttributeLoad NameLoad attr Index TupleLoad SubscriptLoad NameLoad Index TupleLoad NameLoad Num SubscriptLoad NameLoad Index TupleLoad NameLoad Num Num body Assign SubscriptStore AttributeLoad NameLoad attr Index TupleLoad SubscriptLoad NameLoad Index TupleLoad NameLoad Num SubscriptLoad NameLoad Index TupleLoad NameLoad Num Num orelse Assign SubscriptStore AttributeLoad NameLoad attr Index TupleLoad SubscriptLoad NameLoad Index TupleLoad NameLoad Num SubscriptLoad NameLoad Index TupleLoad NameLoad Num Num Expr Call AttributeLoad NameLoad attr Assign SubscriptStore AttributeLoad NameLoad attr Index CompareEq AttributeLoad NameLoad attr Num Num Return NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str If BoolOpAnd Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr body Assign NameStore Call AttributeLoad NameLoad attr SubscriptLoad AttributeLoad NameLoad attr Index AttributeLoad NameLoad attr keyword Num Assign NameStore Call AttributeLoad NameLoad attr SubscriptLoad NameLoad Index AttributeLoad NameLoad attr AugAssignAdd SubscriptStore AttributeLoad NameLoad attr Index Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr NameLoad AugAssignSub SubscriptStore AttributeLoad NameLoad attr ExtSlice Slice Index AttributeLoad NameLoad attr NameLoad Return NameLoad decorator_list
N/A N/A 
Solve the unique lowest-cost assignment problem using the
Hungarian algorithm (also known as Munkres algorithm).

 N/A numpy np fixes astype linear_assignment N/A N/A X N/A N/A N/A Solve the linear assignment problem using the Hungarian algorithm.

    The problem is also known as maximum weight matching in bipartite graphs.
    The method is also known as the Munkres or Kuhn-Munkres algorithm.

    Parameters
    ----------
    X : array
        The cost matrix of the bipartite graph

    Returns
    -------
    indices : array,
        The pairs of (row, col) indices in the original array giving
        the original ordering.

    References
    ----------

    1. http://www.public.iastate.edu/~ddoty/HungarianAlgorithm.html

    2. Harold W. Kuhn. The Hungarian Method for the assignment problem.
       *Naval Research Logistics Quarterly*, 2:83-97, 1955.

    3. Harold W. Kuhn. Variants of the Hungarian method for assignment
       problems. *Naval Research Logistics Quarterly*, 3: 253-258, 1956.

    4. Munkres, J. Algorithms for the Assignment and Transportation Problems.
       *Journal of the Society of Industrial and Applied Mathematics*,
       5(1):32-38, March, 1957.

    5. https://en.wikipedia.org/wiki/Hungarian_algorithm
     N/A indices N/A N/A N/A _hungarian X tolist N/A N/A N/A indices sort N/A indices N/A N/A np array indices dtype int N/A N/A indices shape N/A -1 2 N/A indices N/A _HungarianState N/A object N/A N/A State of one execution of the Hungarian algorithm.

    Parameters
    ----------
    cost_matrix : 2D matrix
        The cost matrix. Does not have to be square.
     __init__ N/A N/A self cost_matrix N/A N/A N/A cost_matrix N/A N/A np atleast_2d cost_matrix N/A transposed N/A N/A N/A cost_matrix shape N/A 1 N/A N/A cost_matrix shape N/A 0 N/A transposed N/A N/A N/A self C N/A N/A N/A cost_matrix T copy N/A N/A N/A self C N/A N/A cost_matrix copy N/A N/A self transposed transposed N/A N/A n m N/A N/A self C shape N/A N/A self row_uncovered N/A N/A np ones n dtype N/A np bool N/A N/A self col_uncovered N/A N/A np ones m dtype N/A np bool N/A N/A self Z0_r 0 N/A N/A self Z0_c 0 N/A N/A self path N/A N/A np zeros N/A N/A n m 2 dtype int N/A N/A self marked N/A N/A np zeros N/A n m dtype int N/A _find_prime_in_row N/A N/A self row N/A N/A N/A 
        Find the first prime element in the specified row. Returns
        the column index, or -1 if no starred element was found.
         N/A col N/A N/A np argmax N/A N/A N/A self marked N/A row 2 N/A N/A N/A N/A self marked N/A N/A row col 2 N/A N/A col -1 N/A col N/A _clear_covers N/A N/A self N/A N/A N/A Clear all covered matrix cells N/A N/A N/A self row_uncovered N/A True N/A N/A N/A self col_uncovered N/A True N/A N/A _hungarian N/A N/A cost_matrix N/A N/A N/A The Hungarian algorithm.

    Calculate the Munkres solution to the classical assignment problem and
    return the indices for the lowest-cost pairings.

    Parameters
    ----------
    cost_matrix : 2D matrix
        The cost matrix. Does not have to be square.

    Returns
    -------
    indices : 2D array of indices
        The pairs of (row, col) indices in the original array giving
        the original ordering.
     N/A state N/A _HungarianState cost_matrix N/A step N/A N/A 0 N/A cost_matrix shape None _step1 N/A N/A step None N/A N/A step N/A step state N/A results N/A N/A N/A np array N/A N/A np where N/A N/A state marked 1 T N/A N/A state transposed N/A N/A results N/A results N/A N/A N/A -1 N/A results N/A _step1 N/A N/A state N/A N/A N/A Steps 1 and 2 in the Wikipedia page. N/A N/A state C N/A N/A N/A N/A state C min axis 1 N/A N/A N/A N/A np newaxis N/A N/A i j N/A zip N/A N/A np where N/A N/A state C 0 N/A N/A N/A N/A N/A state col_uncovered N/A j N/A N/A state row_uncovered N/A i N/A N/A N/A N/A state marked N/A N/A i j 1 N/A N/A N/A state col_uncovered N/A j False N/A N/A N/A state row_uncovered N/A i False N/A N/A N/A state _clear_covers N/A _step3 N/A _step3 N/A N/A state N/A N/A N/A 
    Cover each column containing a starred zero. If n columns are covered,
    the starred zeros describe a complete set of unique assignments.
    In this case, Go to DONE, otherwise, Go to Step 4.
     N/A marked N/A N/A state marked 1 N/A N/A N/A state col_uncovered N/A N/A N/A np any marked axis 0 False N/A N/A N/A N/A marked sum N/A N/A N/A state C shape N/A 0 N/A N/A _step4 N/A _step4 N/A N/A state N/A N/A N/A 
    Find a noncovered zero and prime it. If there is no starred zero
    in the row containing this primed zero, Go to Step 5. Otherwise,
    cover this row and uncover the column containing the starred
    zero. Continue in this manner until there are no uncovered zeros
    left. Save the smallest uncovered value and Go to Step 6.
     N/A C N/A N/A N/A N/A state C 0 astype N/A np int N/A covered_C N/A C N/A N/A state row_uncovered N/A N/A N/A N/A np newaxis N/A covered_C N/A astype N/A state col_uncovered dtype N/A np int copy False N/A n N/A N/A N/A state C shape N/A 0 N/A m N/A N/A N/A state C shape N/A 1 N/A True N/A N/A N/A row col N/A N/A np unravel_index N/A N/A np argmax covered_C N/A n m N/A N/A N/A covered_C N/A N/A row col 0 N/A N/A _step6 N/A N/A N/A N/A state marked N/A N/A row col 2 N/A star_col N/A N/A np argmax N/A N/A N/A state marked N/A row 1 N/A N/A N/A N/A N/A state marked N/A N/A row star_col 1 N/A N/A N/A state Z0_r row N/A N/A state Z0_c col N/A _step5 N/A N/A col star_col N/A N/A N/A state row_uncovered N/A row False N/A N/A N/A state col_uncovered N/A col True N/A N/A covered_C N/A N/A N/A col N/A N/A C N/A N/A N/A col N/A astype N/A state row_uncovered dtype N/A np int copy False N/A N/A covered_C N/A row 0 N/A _step5 N/A N/A state N/A N/A N/A 
    Construct a series of alternating primed and starred zeros as follows.
    Let Z0 represent the uncovered primed zero found in Step 4.
    Let Z1 denote the starred zero in the column of Z0 (if any).
    Let Z2 denote the primed zero in the row of Z1 (there will always be one).
    Continue until the series terminates at a primed zero that has no starred
    zero in its column. Unstar each starred zero of the series, star each
    primed zero of the series, erase all primes and uncover every line in the
    matrix. Return to Step 3
     N/A count 0 N/A path N/A state path N/A N/A path N/A N/A count 0 N/A state Z0_r N/A N/A path N/A N/A count 1 N/A state Z0_c N/A True N/A N/A row N/A N/A np argmax N/A N/A N/A state marked N/A N/A N/A N/A path N/A N/A count 1 1 N/A N/A N/A N/A N/A state marked N/A N/A row N/A path N/A N/A count 1 1 N/A N/A N/A N/A count 1 N/A N/A path N/A N/A count 0 row N/A N/A path N/A N/A count 1 N/A path N/A N/A N/A count 1 1 N/A col N/A N/A np argmax N/A N/A N/A state marked N/A N/A path N/A N/A count 0 2 N/A N/A N/A N/A state marked N/A N/A row col 2 N/A N/A col -1 N/A count 1 N/A N/A path N/A N/A count 0 N/A path N/A N/A N/A count 1 0 N/A N/A path N/A N/A count 1 col N/A i N/A range N/A count 1 N/A N/A N/A N/A N/A state marked N/A N/A N/A path N/A N/A i 0 N/A path N/A N/A i 1 1 N/A N/A N/A N/A state marked N/A N/A N/A path N/A N/A i 0 N/A path N/A N/A i 1 0 N/A N/A N/A N/A state marked N/A N/A N/A path N/A N/A i 0 N/A path N/A N/A i 1 1 N/A N/A N/A state _clear_covers N/A N/A N/A state marked N/A N/A N/A state marked 2 0 N/A _step3 N/A _step6 N/A N/A state N/A N/A N/A 
    Add the value found in Step 4 to every element of each covered row,
    and subtract it from every element of each uncovered column.
    Return to Step 4 without altering any stars, primes, or covered lines.
     N/A N/A N/A N/A np any N/A state row_uncovered N/A N/A np any N/A state col_uncovered N/A N/A minval N/A N/A np min N/A N/A state C N/A N/A state row_uncovered axis 0 N/A minval N/A N/A np min N/A minval N/A N/A state col_uncovered N/A N/A N/A state C N/A N/A N/A np logical_not N/A state row_uncovered minval N/A N/A N/A state C N/A N/A N/A N/A state col_uncovered minval N/A _step4 N/A