/* * EliminationTree.h * Created on: Feb 4, 2010 * @Author: Kai Ni * @Author: Frank Dellaert * @brief: The elimination tree */ #pragma once #include #include #include namespace gtsam { template class _EliminationTreeTester; /** * An elimination tree (see Gilbert01bit) associated with a factor graph and an ordering * is a cluster-tree where there is one node j for each variable, and the parent of each node * corresponds to the first variable up the ordering in the Cholesky factor that j is connected to. */ template class EliminationTree: public ClusterTree { public: // In an elimination tree, the clusters are called nodes typedef typename ClusterTree::Cluster Node; typedef typename Node::shared_ptr sharedNode; // we typedef the following handy list of ordered factor graphs typedef std::pair NamedGraph; typedef std::list OrderedGraphs; private: /** Number of variables */ size_t nrVariables_; /** Map from ordering index to Nodes */ typedef std::vector Nodes; Nodes nodes_; /** * add a factor graph fragment with given frontal key into the tree. Assumes * parent node was already added (will throw exception if not). */ // void add(const FG& fg, Index key); /** * Add a pre-created node by computing its parent and children. */ void add(const sharedNode& node); public: /** Default constructor creates an empty elimination tree. */ EliminationTree() {} /** * Constructor variant 1: from an ordered list of factor graphs * The list is supposed to be in elimination order, and for each * eliminated variable a list of factors to be eliminated. * This function assumes the input is correct (!) and will not check * whether the factors refer only to the correct set of variables. */ // EliminationTree(const OrderedGraphs& orderedGraphs); /** * Constructor variant 2: given a factor graph and the elimination ordering */ EliminationTree(FG& fg); friend class _EliminationTreeTester; }; // EliminationTree /** Class used to access private members for unit testing */ template struct _EliminationTreeTester { EliminationTree& et_; public: _EliminationTreeTester(EliminationTree& et) : et_(et) {} typename EliminationTree::sharedNode& root() { return et_.ClusterTree::root_; } typename EliminationTree::Nodes& nodes() { return et_.nodes_; } }; } // namespace gtsam