24 template <
class GRAPH>
52 return *(children[
i]);
56 template <
class CONTAINER>
63 template <
class CONTAINER>
65 orderedFrontalKeys.push_back(key);
66 factors.push_back(factorsToAdd);
67 problemSize_ += factors.size();
71 void addChild(
const boost::shared_ptr<Cluster>& cluster) {
72 children.push_back(cluster);
73 problemSize_ =
std::max(problemSize_, cluster->problemSize_);
77 return children.size();
81 return factors.size();
85 return orderedFrontalKeys.size();
93 virtual void print(
const std::string&
s =
"",
100 void merge(
const boost::shared_ptr<Cluster>& cluster);
138 void print(
const std::string&
s =
"",
146 void addRoot(
const boost::shared_ptr<Cluster>& cluster) {
147 roots_.push_back(cluster);
151 for (
auto child : cluster->children)
156 return roots_.size();
183 template <
class BAYESTREE,
class GRAPH>
192 typedef boost::shared_ptr<ConditionalType>
222 std::pair<boost::shared_ptr<BayesTreeType>, boost::shared_ptr<FactorGraphType> > eliminate(
223 const Eliminate&
function)
const;
232 return remainingFactors_;
EliminatableClusterTree(const This &other)
ClusterTree()
Default constructor.
GRAPH FactorGraphType
The factor graph type.
FactorGraphType factors
Factors associated with this node.
Concept check for values that can be used in unit tests.
virtual void print(const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const
print this node
FastVector< sharedNode > roots_
GTSAM_CONCEPT_TESTABLE_TYPE(FactorType)
BAYESTREE::ConditionalType ConditionalType
The type of conditionals.
boost::shared_ptr< This > shared_ptr
Shared pointer to this class.
GRAPH::FactorType FactorType
The type of factors.
void addChildrenAsRoots(const boost::shared_ptr< Cluster > &cluster)
EliminatableClusterTree< BAYESTREE, GRAPH > This
This class.
GRAPH::FactorType FactorType
The type of factors.
This & operator=(const This &other)
boost::shared_ptr< Cluster > sharedCluster
Shared pointer to Cluster.
const Cluster & operator[](size_t i) const
boost::shared_ptr< FactorType > sharedFactor
Shared pointer to a factor.
boost::shared_ptr< ConditionalType > sharedConditional
Shared pointer to a conditional.
static const KeyFormatter DefaultKeyFormatter
EliminatableClusterTree()
Default constructor to be used in derived classes.
FastVector< boost::shared_ptr< Cluster > > Children
std::vector< size_t > nrFrontalsOfChildren() const
Return a vector with nrFrontal keys for each child.
boost::shared_ptr< This > shared_ptr
Shared pointer to this class.
ClusterTree(const This &other)
std::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
BAYESTREE BayesTreeType
The BayesTree type produced by elimination.
size_t nrChildren() const
A thin wrapper around std::vector that uses a custom allocator.
Keys orderedFrontalKeys
Frontal keys of this node.
const FastVector< sharedFactor > & remainingFactors() const
size_t nrFrontals() const
A Cluster is just a collection of factors.
void addFactors(Key key, const CONTAINER &factorsToAdd)
Add factors associated with a single key.
Children children
sub-trees
const Cluster & operator[](size_t i) const
void addChild(const boost::shared_ptr< Cluster > &cluster)
Add a child cluster.
std::vector< T, typename internal::FastDefaultVectorAllocator< T >::type > FastVector
void merge(const boost::shared_ptr< Cluster > &cluster)
Merge in given cluster.
GRAPH::Eliminate Eliminate
Typedef for an eliminate subroutine.
FastVector< sharedFactor > remainingFactors_
boost::shared_ptr< FactorType > sharedFactor
Shared pointer to a factor.
ClusterTree< GRAPH > This
This class.
void mergeChildren(const std::vector< bool > &merge)
Merge all children for which bit is set into this node.
const FastVector< sharedNode > & roots() const
void addRoot(const boost::shared_ptr< Cluster > &cluster)
std::uint64_t Key
Integer nonlinear key type.
GRAPH FactorGraphType
The factor graph type.
Cluster(Key key, const CONTAINER &factorsToAdd)
Construct from factors associated with a single key.