15 using namespace gtsam;
28 std::vector<size_t>
keys{0, 1, 2, 3, 4};
31 std::optional<MetisResult> actual = separatorPartitionByMetis<GenericGraph2D>(
graph,
keys,
34 CHECK(actual.has_value());
35 vector<size_t> A_expected{0, 3};
36 vector<size_t> B_expected{2, 4};
37 vector<size_t> C_expected{1};
38 CHECK(A_expected == actual->A);
39 CHECK(B_expected == actual->B);
40 CHECK(C_expected == actual->C);
46 TEST ( Partition, separatorPartitionByMetis2 )
53 std::vector<size_t>
keys{1, 2, 3, 5, 6};
56 std::optional<MetisResult> actual = separatorPartitionByMetis<GenericGraph2D>(
graph,
keys,
59 CHECK(actual.has_value());
60 vector<size_t> A_expected{1, 5};
61 vector<size_t> B_expected{3, 6};
62 vector<size_t> C_expected{2};
63 CHECK(A_expected == actual->A);
64 CHECK(B_expected == actual->B);
65 CHECK(C_expected == actual->C);
76 std::vector<size_t>
keys{0, 1, 2, 3};
79 std::optional<MetisResult> actual = edgePartitionByMetis<GenericGraph3D>(
graph,
keys,
82 CHECK(actual.has_value());
83 vector<size_t> A_expected{0, 1};
84 vector<size_t> B_expected{2, 3};
85 vector<size_t> C_expected;
93 CHECK(A_expected == actual->A || A_expected == actual->B);
94 CHECK(B_expected == actual->B || B_expected == actual->A);
95 CHECK(C_expected == actual->C);
100 TEST ( Partition, edgePartitionByMetis2 )
107 std::vector<size_t>
keys{0, 1, 2, 3, 4};
110 std::optional<MetisResult> actual = edgePartitionByMetis<GenericGraph3D>(
graph,
keys,
112 CHECK(actual.has_value());
113 vector<size_t> A_expected{0, 1};
114 vector<size_t> B_expected{2, 3, 4};
115 vector<size_t> C_expected;
116 CHECK(A_expected == actual->A);
117 CHECK(B_expected == actual->B);
118 CHECK(C_expected == actual->C);
131 std::vector<size_t>
keys{0, 1, 2, 3, 4};
134 int minNodesPerMap = -1;
135 bool reduceGraph =
false;
136 int numSubmaps = findSeparator<GenericGraph2D>(
graph,
keys, minNodesPerMap, workspace,
137 false, {}, reduceGraph, 0, 0);
150 TEST ( Partition, findSeparator2 )
157 std::vector<size_t>
keys{1, 2, 3, 5, 6};
160 int minNodesPerMap = -1;
161 bool reduceGraph =
false;
162 int numSubmaps = findSeparator<GenericGraph2D>(
graph,
keys, minNodesPerMap, workspace,
163 false, {}, reduceGraph, 0, 0);
182 TEST ( Partition, findSeparator3_with_reduced_camera )
185 for (
int j=1;
j<=8;
j++)
186 graph.
push_back(std::make_shared<GenericFactor3D>(25,
j));
187 for (
int j=1;
j<=16;
j++)
188 graph.push_back(std::make_shared<GenericFactor3D>(26,
j));
189 for (
int j=9;
j<=24;
j++)
190 graph.push_back(std::make_shared<GenericFactor3D>(27,
j));
191 for (
int j=17;
j<=24;
j++)
192 graph.push_back(std::make_shared<GenericFactor3D>(28,
j));
194 std::vector<size_t>
keys;
195 for(
int i=1;
i<=28;
i++)
198 vector<Symbol> int2symbol;
199 int2symbol.push_back(
Symbol(
'x',0));
200 for(
int i=1;
i<=24;
i++)
201 int2symbol.push_back(
Symbol(
'l',
i));
202 int2symbol.push_back(
Symbol(
'x',25));
203 int2symbol.push_back(
Symbol(
'x',26));
204 int2symbol.push_back(
Symbol(
'x',27));
205 int2symbol.push_back(
Symbol(
'x',28));
208 bool reduceGraph =
true;
209 int numIsland =
findSeparator(graph, keys, 3, workspace,
false, int2symbol, reduceGraph, 0, 0);
213 for (
int j=1;
j<=8;
j++)
215 for (
int j=9; j<=16; j++)
217 for (
int j=17; j<=24; j++)
std::optional< MetisResult > separatorPartitionByMetis(const GenericGraph &graph, const std::vector< size_t > &keys, WorkSpace &workspace, bool verbose)
static int runAllTests(TestResult &result)
TEST(Partition, separatorPartitionByMetis)
IsDerived< DERIVEDFACTOR > push_back(std::shared_ptr< DERIVEDFACTOR > factor)
Add a factor directly using a shared_ptr.
NonlinearFactorGraph graph
PartitionTable partitionTable
std::optional< MetisResult > edgePartitionByMetis(const GenericGraph &graph, const std::vector< size_t > &keys, WorkSpace &workspace, bool verbose)
std::vector< sharedGenericFactor2D > GenericGraph2D
int findSeparator(const GenericGraph &graph, const std::vector< size_t > &keys, const int minNodesPerMap, WorkSpace &workspace, bool verbose, const std::optional< std::vector< Symbol > > &int2symbol, const bool reduceGraph, const int minNrConstraintsPerCamera, const int minNrConstraintsPerLandmark)
std::vector< sharedGenericFactor3D > GenericGraph3D
#define LONGS_EQUAL(expected, actual)
std::vector< int > PartitionTable