/* * Ordering-inl.h * * Created on: Jan 14, 2010 * Author: nikai * Description: the inline file for Ordering */ #pragma once #include "graph-inl.h" #include "Ordering.h" using namespace std; namespace gtsam { /* ************************************************************************* */ template class ordering_key_visitor : public boost::default_bfs_visitor { public: ordering_key_visitor(std::list& ordering_in) : ordering_(ordering_in) {} template void discover_vertex(Vertex v, const Graph& g) const { Key key = boost::get(boost::vertex_name, g, v); ordering_.push_front(key); } std::list& ordering_; }; /* ************************************************************************* */ template list predecessorMap2Keys(const PredecessorMap& p_map) { typedef typename SGraph::Vertex SVertex; SGraph g; SVertex root; std::map key2vertex; boost::tie(g, root, key2vertex) = gtsam::predecessorMap2Graph, SVertex, Key>(p_map); // breadth first visit on the graph std::list keys; ordering_key_visitor vis(keys); boost::breadth_first_search(g, root, boost::visitor(vis)); return keys; } }