| 139 | |
| 140 | |
| 141 | void Counter::makeMatch(const vector<vector<double> > &similarity, vector<int> &match1, vector<int> &match2) { |
| 142 | int m = similarity.size(); |
| 143 | int n = similarity[0].size(); |
| 144 | pipartiteGraph gra; |
| 145 | bool have_exchange = false; |
| 146 | if (m > n) { |
| 147 | have_exchange = true; |
| 148 | swap(m, n); |
| 149 | } |
| 150 | gra.resize(m, n); |
| 151 | for (int i = 0; i < gra.leftNum; i++) { |
| 152 | for (int j = 0; j < gra.rightNum; j++) { |
| 153 | if(have_exchange) |
| 154 | gra.mat[i][j] = similarity[j][i]; |
| 155 | else |
| 156 | gra.mat[i][j] = similarity[i][j]; |
| 157 | } |
| 158 | } |
| 159 | gra.match(); |
| 160 | match1 = gra.leftMatch; |
| 161 | match2 = gra.rightMatch; |
| 162 | if (have_exchange) swap(match1, match2); |
| 163 | } |