22#include <gtsam/dllexport.h>
24#if GTSAM_ENABLE_BOOST_SERIALIZATION
25#include <boost/serialization/version.hpp>
26#include <boost/serialization/nvp.hpp>
33namespace serialization {
45class GTSAM_EXPORT Subgraph {
50 inline bool isUnitWeight()
const {
return (weight == 1.0); }
51 friend std::ostream &operator<<(std::ostream &os,
const Edge &edge);
54#if GTSAM_ENABLE_BOOST_SERIALIZATION
55 friend class boost::serialization::access;
56 template <
class Archive>
57 void serialize(Archive &ar,
const unsigned int ) {
58 ar &BOOST_SERIALIZATION_NVP(index);
59 ar &BOOST_SERIALIZATION_NVP(weight);
64 typedef std::vector<Edge> Edges;
65 typedef std::vector<size_t> EdgeIndices;
66 typedef Edges::iterator iterator;
67 typedef Edges::const_iterator const_iterator;
75 Subgraph(
const Edges &edges) : edges_(edges) {}
76 Subgraph(
const std::vector<size_t> &indices);
78 inline const Edges &edges()
const {
return edges_; }
79 inline size_t size()
const {
return edges_.size(); }
80 EdgeIndices edgeIndices()
const;
82 iterator begin() {
return edges_.begin(); }
83 const_iterator begin()
const {
return edges_.begin(); }
84 iterator end() {
return edges_.end(); }
85 const_iterator end()
const {
return edges_.end(); }
87 friend std::ostream &operator<<(std::ostream &os,
const Subgraph &subgraph);
90#if GTSAM_ENABLE_BOOST_SERIALIZATION
91 friend class boost::serialization::access;
92 template <
class Archive>
93 void serialize(Archive &ar,
const unsigned int ) {
94 ar &BOOST_SERIALIZATION_NVP(edges_);
96 void save(
const std::string &fn)
const;
97 static Subgraph load(
const std::string &fn);
102struct GTSAM_EXPORT SubgraphBuilderParameters {
103 typedef std::shared_ptr<SubgraphBuilderParameters> shared_ptr;
112 enum SkeletonWeight {
119 enum AugmentationWeight {
126 } augmentationWeight;
131 SubgraphBuilderParameters()
132 : skeletonType(KRUSKAL),
133 skeletonWeight(RANDOM),
134 augmentationWeight(SKELETON),
140 virtual void print(std::ostream &os)
const;
141 friend std::ostream &operator<<(std::ostream &os,
142 const PreconditionerParameters &p);
144 static Skeleton skeletonTranslator(
const std::string &s);
145 static std::string skeletonTranslator(Skeleton s);
146 static SkeletonWeight skeletonWeightTranslator(
const std::string &s);
147 static std::string skeletonWeightTranslator(SkeletonWeight w);
148 static AugmentationWeight augmentationWeightTranslator(
const std::string &s);
149 static std::string augmentationWeightTranslator(AugmentationWeight w);
153class GTSAM_EXPORT SubgraphBuilder {
155 typedef SubgraphBuilder Base;
156 typedef std::vector<double> Weights;
161 virtual ~SubgraphBuilder() {}
166 const std::vector<double> &weights)
const;
171 const std::vector<double> &weights)
const;
172 std::vector<size_t> sample(
const std::vector<double> &weights,
173 const size_t t)
const;
185std::pair<GaussianFactorGraph, GaussianFactorGraph> GTSAM_EXPORT
splitFactorGraph(
Typedefs for easier changing of types.
A thin wrapper around std::map that uses boost's fast_pool_allocator.
Global functions in a separate testing namespace.
Definition chartTesting.h:28
GaussianFactorGraph buildFactorSubgraph(const GaussianFactorGraph &gfg, const Subgraph &subgraph, const bool clone)
Select the factors in a factor graph according to the subgraph.
Definition SubgraphBuilder.cpp:406
void save(const Matrix &A, const string &s, const string &filename)
save a matrix to file, which can be loaded by matlab
Definition Matrix.cpp:154
std::pair< GaussianFactorGraph, GaussianFactorGraph > splitFactorGraph(const GaussianFactorGraph &factorGraph, const Subgraph &subgraph)
Split the graph into a subgraph and the remaining edges.
Definition SubgraphBuilder.cpp:419
A Linear Factor Graph is a factor graph where all factors are Gaussian, i.e.
Definition GaussianFactorGraph.h:77
Definition Preconditioner.h:27
Definition SubgraphBuilder.h:45
Definition SubgraphBuilder.h:47
Definition SubgraphBuilder.h:102
double augmentationFactor
factor multiplied with n, yields number of extra edges.
Definition SubgraphBuilder.h:129