ATLAS Offline Software
munkres.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 
6 #ifndef MUNKRES_H
7 #define MUNKRES_H
8 
9 #include <iostream>
10 #include <vector>
11 #include <iomanip>
12 #include <map>
13 
14 // adapted for C++ from http://csclab.murraystate.edu/bob.pilgrim/445/munkres.html
15 // standalone code at: https://github.com/lukasheinrich/munkres-cpp
16 
17 class munkres{
18 public:
19  typedef std::vector<double> vec_type;
20  typedef std::vector<vec_type > matrix_type;
21  typedef std::pair<int,int> coords;
22  typedef std::vector<int> result_type;
23 
24  enum markertype {kStar = 1, kPrime = 2};
25 
26  munkres(matrix_type costs);
28  result_type run(vec_type& costvector, bool debug = false);
29 
30 private:
31  void step_one();
32  void step_two();
33  void step_three();
34  void step_four();
35  void step_five();
36  void step_six();
37 
39  void printmatrix(const matrix_type&);
40 
41  void find_a_zero(int& row,int& col);
42  int find_in_row(const int row, markertype what);
43  int find_in_col(const int col, markertype what);
44  double find_min_uncov();
45 
46  void augment_path(const std::vector<coords>& path);
48 
52  int m_step;
53 
54  std::vector<bool> m_rowIsCovered;
55  std::vector<bool> m_colIsCovered;
56  const int m_dim;
57 };
58 #endif
query_example.row
row
Definition: query_example.py:24
munkres::step_three
void step_three()
Definition: munkres.cxx:109
athena.path
path
python interpreter configuration --------------------------------------—
Definition: athena.py:126
munkres::erase_primes_and_covers
void erase_primes_and_covers()
Definition: munkres.cxx:196
munkres::find_min_uncov
double find_min_uncov()
Definition: munkres.cxx:247
munkres
Definition: munkres.h:17
munkres::find_in_row
int find_in_row(const int row, markertype what)
Definition: munkres.cxx:137
munkres::m_costs_orig
matrix_type m_costs_orig
Definition: munkres.h:50
munkres::m_rowIsCovered
std::vector< bool > m_rowIsCovered
Definition: munkres.h:54
munkres::matrix_type
std::vector< vec_type > matrix_type
Definition: munkres.h:20
munkres::printmask
void printmask()
Definition: munkres.h:38
munkres::step_six
void step_six()
Definition: munkres.cxx:259
munkres::augment_path
void augment_path(const std::vector< coords > &path)
Definition: munkres.cxx:183
munkres::m_step
int m_step
Definition: munkres.h:52
munkres::printcosts
void printcosts()
Definition: munkres.h:27
munkres::step_two
void step_two()
Definition: munkres.cxx:86
munkres::run
result_type run(vec_type &costvector, bool debug=false)
Definition: munkres.cxx:20
munkres::step_four
void step_four()
Definition: munkres.cxx:149
munkres::kStar
@ kStar
Definition: munkres.h:24
munkres::munkres
munkres(matrix_type costs)
Definition: munkres.cxx:8
python.ExitCodes.what
def what(code)
Definition: ExitCodes.py:73
munkres::coords
std::pair< int, int > coords
Definition: munkres.h:21
munkres::vec_type
std::vector< double > vec_type
Definition: munkres.h:19
munkres::m_costmatrix
matrix_type m_costmatrix
Definition: munkres.h:49
debug
const bool debug
Definition: MakeUncertaintyPlots.cxx:53
munkres::step_one
void step_one()
Definition: munkres.cxx:71
munkres::m_maskmatrix
matrix_type m_maskmatrix
Definition: munkres.h:51
query_example.col
col
Definition: query_example.py:7
munkres::find_in_col
int find_in_col(const int col, markertype what)
Definition: munkres.cxx:143
munkres::printmatrix
void printmatrix(const matrix_type &)
Definition: munkres.cxx:275
munkres::markertype
markertype
Definition: munkres.h:24
munkres::result_type
std::vector< int > result_type
Definition: munkres.h:22
munkres::m_colIsCovered
std::vector< bool > m_colIsCovered
Definition: munkres.h:55
munkres::find_a_zero
void find_a_zero(int &row, int &col)
Definition: munkres.cxx:126
munkres::m_dim
const int m_dim
Definition: munkres.h:56
munkres::kPrime
@ kPrime
Definition: munkres.h:24
munkres::step_five
void step_five()
Definition: munkres.cxx:206