ATLAS Offline Software
Loading...
Searching...
No Matches
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
17class munkres{
18public:
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
30private:
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
const bool debug
munkres(matrix_type costs)
Definition munkres.cxx:8
int m_step
Definition munkres.h:52
int find_in_col(const int col, markertype what)
Definition munkres.cxx:143
markertype
Definition munkres.h:24
@ kStar
Definition munkres.h:24
@ kPrime
Definition munkres.h:24
const int m_dim
Definition munkres.h:56
void augment_path(const std::vector< coords > &path)
Definition munkres.cxx:183
std::vector< vec_type > matrix_type
Definition munkres.h:20
void erase_primes_and_covers()
Definition munkres.cxx:196
void step_one()
Definition munkres.cxx:71
void printmatrix(const matrix_type &)
Definition munkres.cxx:275
double find_min_uncov()
Definition munkres.cxx:247
void step_three()
Definition munkres.cxx:109
void find_a_zero(int &row, int &col)
Definition munkres.cxx:126
void printmask()
Definition munkres.h:38
matrix_type m_maskmatrix
Definition munkres.h:51
std::vector< int > result_type
Definition munkres.h:22
std::vector< bool > m_colIsCovered
Definition munkres.h:55
void step_six()
Definition munkres.cxx:259
void printcosts()
Definition munkres.h:27
std::vector< double > vec_type
Definition munkres.h:19
void step_four()
Definition munkres.cxx:149
int find_in_row(const int row, markertype what)
Definition munkres.cxx:137
matrix_type m_costs_orig
Definition munkres.h:50
std::pair< int, int > coords
Definition munkres.h:21
matrix_type m_costmatrix
Definition munkres.h:49
std::vector< bool > m_rowIsCovered
Definition munkres.h:54
void step_two()
Definition munkres.cxx:86
void step_five()
Definition munkres.cxx:206
Definition run.py:1