12 #include <unordered_map>
14 #include <unordered_set>
16 using namespace gtsam;
19 using std::unordered_map;
21 using std::unordered_set;
31 double heuristic()
const {
return (outWeightSum + 1) / (inWeightSum + 1); }
37 const map<MFAS::KeyPair, double>& edgeWeights) {
38 unordered_map<Key, GraphNode>
graph;
40 for (
const auto& edgeWeight : edgeWeights) {
46 const double& weight = edgeWeight.second;
48 Key edgeSource = weight >= 0 ? edge.first : edge.second;
49 Key edgeDest = weight >= 0 ? edge.second : edge.first;
53 graph[edgeDest].inNeighbors.insert(edgeSource);
57 graph[edgeSource].outNeighbors.insert(edgeDest);
65 for (
const auto& keyNode :
graph) {
67 if (keyNode.second.inWeightSum < 1
e-8) {
76 [](
const std::pair<Key, GraphNode>& keyNode1,
77 const std::pair<Key, GraphNode>& keyNode2) {
78 return keyNode1.second.heuristic() <
79 keyNode2.second.heuristic();
86 const map<MFAS::KeyPair, double>& edgeWeights) {
95 const map<MFAS::KeyPair, double> edgeWeights,
96 unordered_map<Key, GraphNode>&
graph) {
98 for (
const Key neighbor :
graph[node].inNeighbors) {
101 graph[neighbor].outWeightSum -=
106 for (
const Key neighbor :
graph[node].outNeighbors) {
115 const Unit3& projectionDirection) {
118 for (
const auto&
measurement : relativeTranslations) {
147 unordered_map<Key, int> orderingPositions;
152 map<KeyPair, double> outlierWeights;
156 Key source = edgeWeight.first.first;
157 Key dest = edgeWeight.first.second;
158 if (edgeWeight.second < 0) {
164 if (orderingPositions.at(dest) < orderingPositions.at(source)) {
165 outlierWeights[edgeWeight.first] =
std::abs(edgeWeight.second);
167 outlierWeights[edgeWeight.first] = 0;
170 return outlierWeights;