for (int i = 0; i < a.size(); i++) {
for (int j = 0; j < b.size(); j++) {
distances[i][j] = distance(a.get(i), b.get(j));
}
}
HungarianAlgorithm ha = new HungarianAlgorithm();
int[][] assignments = ha.computeAssignments(distances);
Map<Integer, Integer> result = new HashMap<Integer, Integer>();
for (int i = 0; i < assignments.length; i++) {
result.put(assignments[i][0], assignments[i][1]);
}
return result;