IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
Public Member Functions | Protected Attributes | List of all members
ipsdk::math::Munkres Class Reference

Implementation of munkres algorithm. More...

#include <Munkres.h>

Inheritance diagram for ipsdk::math::Munkres:

Public Member Functions

bool isInit () const
 check for object initialization
 
void init (const ipUInt32 nbRows, const ipUInt32 nbColumns)
 initialization of munkres algorithm More...
 
ipUInt32 getNbRows () const
 retrieve number of rows for matrix associated to algorithm More...
 
ipUInt32 getNbColumns () const
 retrieve number of columns for matrix associated to algorithm More...
 
ipReal64getWeights (const ipUInt32 rowIdx)
 method allowing to write matrix row weights associated to a given row index More...
 
const ipReal64getWeights (const ipUInt32 rowIdx) const
 retrieve matrix row weights associated to a given row index More...
 
ipReal64 getWeight (const ipUInt32 rowIdx, const ipUInt32 columnIdx) const
 retrieve weight associated to a given row and column index More...
 
bool isSolved () const
 check whether hungarian problem has been solved More...
 
void solve ()
 resolution of hungarian problem More...
 
const UInt32VectorgetAssignments () const
 retrieve assignments made by hungarian method More...
 
ipReal64 getTotalWeigth ()
 retrieve total weight for assignment solution More...
 
void clear ()
 method allowing to clear object data
 
Constructors and destructor
 Munkres ()
 
 ~Munkres ()
 

Protected Attributes

ipUInt32 _nbRows
 number of rows for matrix associated to algorithm
 
ipUInt32 _nbColumns
 number of columns for matrix associated to algorithm
 
Real64Vector _inputWeights
 input matrix data associated to algorithm
 
UInt32Vector _assignments
 assignment vector associated to problem solution
 

Detailed Description

Implementation of munkres algorithm.

Author
E.Noirfalise
Date
2016/10/13

This algorithm, also known has Hungarian method or Kuhn-Munkres algorithm, allows to solve a weighted bipartite graph assignment problem.

After algorithm initialization, user should fill rows of matrix data. Once all data filled, user can trigger processing

Note
implementation of algorithm supose a column major matrix (number of columns greater or equal to number of rows)
See also
https://en.wikipedia.org/wiki/Hungarian_algorithm
https://www.topcoder.com/community/data-science/data-science-tutorials/assignment-problem-and-hungarian-algorithm/

Member Function Documentation

◆ init()

void ipsdk::math::Munkres::init ( const ipUInt32  nbRows,
const ipUInt32  nbColumns 
)

initialization of munkres algorithm

Exceptions
ipsdk::math::IPSDKMathExceptionif nbColumns == 0
ipsdk::math::IPSDKMathExceptionif nbRows > nbColumns

◆ getNbRows()

ipUInt32 ipsdk::math::Munkres::getNbRows ( ) const

retrieve number of rows for matrix associated to algorithm

Exceptions
ipsdk::math::IPSDKMathExceptionif isInit() == false

◆ getNbColumns()

ipUInt32 ipsdk::math::Munkres::getNbColumns ( ) const

retrieve number of columns for matrix associated to algorithm

Exceptions
ipsdk::math::IPSDKMathExceptionif isInit() == false

◆ getWeights() [1/2]

ipReal64* ipsdk::math::Munkres::getWeights ( const ipUInt32  rowIdx)

method allowing to write matrix row weights associated to a given row index

Exceptions
ipsdk::math::IPSDKMathExceptionif rowIdx >= getNbRows()

◆ getWeights() [2/2]

const ipReal64* ipsdk::math::Munkres::getWeights ( const ipUInt32  rowIdx) const

retrieve matrix row weights associated to a given row index

Exceptions
ipsdk::math::IPSDKMathExceptionif rowIdx >= getNbRows()

◆ getWeight()

ipReal64 ipsdk::math::Munkres::getWeight ( const ipUInt32  rowIdx,
const ipUInt32  columnIdx 
) const

retrieve weight associated to a given row and column index

Exceptions
ipsdk::math::IPSDKMathExceptionif rowIdx >= getNbRows()
ipsdk::math::IPSDKMathExceptionif columnIdx >= getNbColumns()

◆ isSolved()

bool ipsdk::math::Munkres::isSolved ( ) const

check whether hungarian problem has been solved

Exceptions
ipsdk::math::IPSDKMathExceptionif isInit() == false

◆ solve()

void ipsdk::math::Munkres::solve ( )

resolution of hungarian problem

Exceptions
ipsdk::math::IPSDKMathExceptionif isInit() == false

◆ getAssignments()

const UInt32Vector& ipsdk::math::Munkres::getAssignments ( ) const

retrieve assignments made by hungarian method

Returns
On output getAssignments()[i] = j means that row i is associated to column j
Exceptions
ipsdk::math::IPSDKMathExceptionif isSolved() == false

◆ getTotalWeigth()

ipReal64 ipsdk::math::Munkres::getTotalWeigth ( )

retrieve total weight for assignment solution

Exceptions
ipsdk::math::IPSDKMathExceptionif isSolved() == false

The documentation for this class was generated from the following file: