SHOGUN  3.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
munkres.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2007 John Weaver
3  *
4  * 2012: Ported to shogun by Chiyuan Zhang
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19  */
20 
21 #if !defined(_MUNKRES_H_)
22 #define _MUNKRES_H_
23 
24 #include <shogun/lib/config.h>
25 
26 #include <shogun/lib/DataType.h>
27 #include <shogun/lib/SGMatrix.h>
28 
29 #include <list>
30 #include <utility>
31 
32 namespace shogun
33 {
34 
36 class Munkres
37 {
38 public:
41  :mask_matrix(m.num_rows, m.num_cols, true), matrix(m.num_rows, m.num_cols, true), ref_m(m)
42  {
43  }
44 
46  void solve()
47  {
48  solve(ref_m);
49  }
50 
53  {
54  }
55 
56 private:
57  static const int NORMAL=0;
58  static const int STAR=1;
59  static const int PRIME=2;
60 
61  void solve(SGMatrix<double> &m);
62 
63  inline bool find_uncovered_in_matrix(double,int&,int&);
64  inline bool pair_in_list(const std::pair<int,int> &, const std::list<std::pair<int,int> > &);
65  int step1(void);
66  int step2(void);
67  int step3(void);
68  int step4(void);
69  int step5(void);
70  int step6(void);
71  SGMatrix<int> mask_matrix;
72  SGMatrix<double> matrix;
73  bool *row_mask;
74  bool *col_mask;
75  int saverow, savecol;
76 
77  SGMatrix<double> &ref_m;
78 };
79 
80 } // namespace shogun
81 
82 #endif /* !defined(_MUNKRES_H_) */

SHOGUN Machine Learning Toolbox - Documentation