c++ - Provide vertex-mapping parameter to boost::graph::copy_graph -
c++ - Provide vertex-mapping parameter to boost::graph::copy_graph -
the boost function boost::graph::copy_graph
template <class vertexlistgraph, class mutablegraph> void copy_graph(const vertexlistgraph& g, mutablegraph& g_copy, const bgl_named_params<p, t, r>& params = defaults)
lists in parameter description util/out: orig_to_copy(orig2copymap c)
mapping vertices in re-create vertices in original. need mapping!
(scroll bottom on http://www.boost.org/doc/libs/1_55_0/libs/graph/doc/copy_graph.html)
how can access/provide lastly parameter orig_to_copy? can give code example, ie finish code me?
void dosomething(graph_t& g){ graph_t g_copy; copy_graph(g, g_copy, [...???...]); // here access orig2copymap }
something this:
typedef boost::graph_traits<graph_t>::vertex_descriptor vertex_t; typedef boost::property_map<graph_t, boost::vertex_index_t>::type index_map_t; //for simple adjacency_list<> type more efficient: typedef boost::iterator_property_map<typename std::vector<vertex_t>::iterator, index_map_t,vertex_t,vertex_t&> isomap; //maps vertices of g vertices of g_copy std::vector<vertex_t> isovalues( num_vertices(g)); isomap mapv( isovalues.begin()); boost::copy_graph( g, g_copy, boost::orig_to_copy(mapv) ); //means g_copy += g
c++ boost parameter-passing boost-graph
Comments
Post a Comment