gtsam/cpp/testFactorgraph.cpp

53 lines
1.4 KiB
C++
Raw Normal View History

2009-08-22 06:23:24 +08:00
/**
* @file testFactorgraph.cpp
* @brief Unit tests for Factor Graphs
* @author Christian Potthast
**/
/*STL/C++*/
#include <list>
#include <iostream>
2010-02-26 21:31:38 +08:00
#include <boost/shared_ptr.hpp>
#include <boost/tuple/tuple.hpp>
#include <CppUnitLite/TestHarness.h>
#define GTSAM_MAGIC_KEY
#include "SymbolicFactorGraph.h"
2009-08-22 06:23:24 +08:00
using namespace std;
2010-02-26 21:31:38 +08:00
using namespace gtsam;
2009-08-22 06:23:24 +08:00
2010-02-26 21:31:38 +08:00
typedef boost::shared_ptr<SymbolicFactorGraph> shared;
/* ************************************************************************* */
TEST( FactorGraph, splitMinimumSpanningTree )
{
SymbolicFactorGraph G;
G.push_factor("x1", "x2");
G.push_factor("x1", "x3");
G.push_factor("x1", "x4");
G.push_factor("x2", "x3");
G.push_factor("x2", "x4");
G.push_factor("x3", "x4");
SymbolicFactorGraph T, C;
boost::tie(T, C) = G.splitMinimumSpanningTree();
2010-02-26 21:31:38 +08:00
SymbolicFactorGraph expectedT, expectedC;
expectedT.push_factor("x1", "x2");
expectedT.push_factor("x1", "x3");
expectedT.push_factor("x1", "x4");
expectedC.push_factor("x2", "x3");
expectedC.push_factor("x2", "x4");
expectedC.push_factor("x3", "x4");
CHECK(assert_equal(expectedT,T));
CHECK(assert_equal(expectedC,C));
2010-02-26 21:31:38 +08:00
}
2009-08-22 06:23:24 +08:00
/* ************************************************************************* */
2010-02-26 21:31:38 +08:00
int main() {
TestResult tr;
return TestRegistry::runAllTests(tr);
}
2009-08-22 06:23:24 +08:00
/* ************************************************************************* */