17 using namespace gtsam;
42 std::vector<size_t>
keys{1, 2, 3, 4, 5, 6, 7, 8, 9};
45 list<vector<size_t> > islands =
findIslands(graph,
keys, workspace, 7, 2);
47 vector<size_t> island1{1, 2, 3, 7, 8};
48 vector<size_t> island2{4, 5, 6, 9};
49 CHECK(island1 == islands.front());
50 CHECK(island2 == islands.back());
59 TEST( GenerciGraph, findIslands2 )
75 std::vector<size_t>
keys{1, 2, 3, 4, 5, 6, 7, 8};
78 list<vector<size_t> > islands =
findIslands(graph,
keys, workspace, 7, 2);
80 vector<size_t> island1{1, 2, 3, 4, 5, 6, 7, 8};
81 CHECK(island1 == islands.front());
89 TEST ( GenerciGraph, findIslands3 )
97 std::vector<size_t>
keys{1, 2, 3, 4, 5, 6};
100 list<vector<size_t> > islands =
findIslands(graph,
keys, workspace, 7, 2);
102 vector<size_t> island1{1, 5};
103 vector<size_t> island2{2, 3, 4, 6};
104 CHECK(island1 == islands.front());
105 CHECK(island2 == islands.back());
112 TEST ( GenerciGraph, findIslands4 )
117 std::vector<size_t>
keys{3, 4, 7};
120 list<vector<size_t> > islands =
findIslands(graph,
keys, workspace, 7, 2);
122 vector<size_t> island1{3, 4};
123 vector<size_t> island2{7};
124 CHECK(island1 == islands.front());
125 CHECK(island2 == islands.back());
134 TEST ( GenerciGraph, findIslands5 )
145 std::vector<size_t>
keys{1, 2, 3, 4, 5};
148 list<vector<size_t> > islands =
findIslands(graph,
keys, workspace, 7, 2);
150 vector<size_t> island1{1, 3, 5};
151 vector<size_t> island2{2, 4};
152 CHECK(island1 == islands.front());
153 CHECK(island2 == islands.back());
165 graph.
push_back(std::make_shared<GenericFactor3D>(1, 3));
166 graph.push_back(std::make_shared<GenericFactor3D>(1, 4));
167 graph.push_back(std::make_shared<GenericFactor3D>(1, 5));
168 graph.push_back(std::make_shared<GenericFactor3D>(2, 5));
169 graph.push_back(std::make_shared<GenericFactor3D>(2, 6));
171 std::vector<size_t> cameraKeys, landmarkKeys;
172 cameraKeys.push_back(1);
173 cameraKeys.push_back(2);
174 landmarkKeys.push_back(3);
175 landmarkKeys.push_back(4);
176 landmarkKeys.push_back(5);
177 landmarkKeys.push_back(6);
179 std::vector<int> dictionary;
180 dictionary.resize(7, -1);
185 std::map<size_t, vector<size_t> > cameraToLandmarks;
197 TEST ( GenericGraph, reduceGenericGraph2 )
207 std::vector<size_t> cameraKeys, landmarkKeys;
208 cameraKeys.push_back(1);
209 cameraKeys.push_back(2);
210 cameraKeys.push_back(7);
211 landmarkKeys.push_back(3);
212 landmarkKeys.push_back(4);
213 landmarkKeys.push_back(5);
214 landmarkKeys.push_back(6);
216 std::vector<int> dictionary;
217 dictionary.resize(8, -1);
223 std::map<size_t, vector<size_t> > cameraToLandmarks;
233 std::set<size_t> cameras1{1, 2, 3, 4, 5};
234 std::set<size_t> cameras2{8, 7, 6, 5};
240 TEST ( GenerciGraph, hasCommonCamera2 )
242 std::set<size_t> cameras1{1, 3, 5, 7};
243 std::set<size_t> cameras2{2, 4, 6, 8, 10};
list< vector< size_t > > findIslands(const GenericGraph2D &graph, const vector< size_t > &keys, WorkSpace &workspace, const int minNrConstraintsPerCamera, const int minNrConstraintsPerLandmark)
bool hasCommonCamera(const std::set< size_t > &cameras1, const std::set< size_t > &cameras2)
static int runAllTests(TestResult &result)
IsDerived< DERIVEDFACTOR > push_back(std::shared_ptr< DERIVEDFACTOR > factor)
Add a factor directly using a shared_ptr.
NonlinearFactorGraph graph
std::vector< sharedGenericFactor2D > GenericGraph2D
std::vector< sharedGenericFactor3D > GenericGraph3D
const Symbol key1('v', 1)
void reduceGenericGraph(const GenericGraph3D &graph, const std::vector< size_t > &cameraKeys, const std::vector< size_t > &landmarkKeys, const std::vector< int > &dictionary, GenericGraph3D &reducedGraph)
TEST(GenerciGraph, findIslands)
std::uint64_t index() const
#define LONGS_EQUAL(expected, actual)
const Symbol key2('v', 2)