假装以下typedef和defintiontions:
#include <boost/graph/adjacency_list.hpp>
using namespace boost;
int main()
{
typedef adjacency_list<vecS, vecS, directedS, property<vertex_index_t, int> > GraphTC;
GraphTC g;
typedef typename property_map<GraphTC, vertex_index_t>::const_type VertexIndexMap;
VertexIndexMap index_map = get(vertex_index, g);
typedef typename graph_traits<GraphTC>::vertex_descriptor tc_vertex;
std::vector<tc_vertex> to_tc_vec(num_vertices(g));
iterator_property_map < tc_vertex *, VertexIndexMap, tc_vertex, tc_vertex&>
g_to_tc_map(&to_tc_vec[0], index_map);
}
我有一个输出g和g_to_tc_map的算法(如上所述) . 现在,我需要通过g_to_tc_map来置换节点(我认为,这类似于整数数组或std :: map) .
注意:我发现有一个boost / graph / detail / permutation.hpp,但我不知道如何使用它(甚至只包含此文件的bug,与其他头文件冲突) .
感谢任何想法/代码如何做这个排列 .
1 回答
如果您可以使用创建图表的置换副本,则可以使用迭代器范围创建新图形:
PS:在
vecS
顶点容器的图形中不需要vertex_index_t
属性;它是自动创建(并填写) .