/* * graph.h * @brief Graph algorithm using boost library * @author: Kai Ni * Created on: Jan 11, 2010 */ #pragma once #include #include #include #include namespace gtsam { // type definitions : /** * SDGraph is undirected graph with variable keys and double edge weights */ template class SDGraph: public boost::adjacency_list, boost::property< boost::edge_weight_t, double> > { public: typedef typename boost::graph_traits >::vertex_descriptor Vertex; }; template class SGraph : public boost::adjacency_list > { public: typedef typename boost::graph_traits >::vertex_descriptor Vertex; }; //typedef boost::graph_traits::vertex_descriptor SVertex; /** * Map from variable key to parent key */ template class PredecessorMap: public std::map { public: /** convenience insert so we can pass ints for TypedSymbol keys */ inline void insert(const Key& key, const Key& parent) { std::map::insert(std::make_pair(key, parent)); } }; /** * Generate a list of keys from a spanning tree represented by its predecessor map */ template std::list predecessorMap2Keys(const PredecessorMap& p_map); /** * Convert the factor graph to an SDGraph * G = Graph type * F = Factor type * Key = Key type */ template SDGraph toBoostGraph(const G& graph); /** * Build takes a predecessor map, and builds a directed graph corresponding to the tree. * G = Graph type * V = Vertex type */ template boost::tuple > predecessorMap2Graph(const PredecessorMap& p_map); /** * Compose the poses by following the chain specified by the spanning tree */ template boost::shared_ptr composePoses(const G& graph, const PredecessorMap& tree, const Pose& rootPose); } // namespace gtsam