我需要为给定的图表创建一个支配树。我编译并运行的代码没有错误,但输出看起来与输入完全相同。
我为我的图表定义了以下类型(待分析)
typedef boost::adjacency_list<boost::listS, boost::vecS,
boost::bidirectionalS, vertex_info, edge_info> Graph;
我想要另一个包含相应支配树的对象。我尝试了以下方法:
// dominator tree is an empty Graph object
dominator_tree = trace;
typedef typename boost::graph_traits<Graph>::vertex_descriptor Vertex;
typedef typename boost::property_map<Graph, boost::vertex_index_t>::type IndexMap;
typedef typename boost::iterator_property_map<typename std::vector<Vertex>::iterator, IndexMap> PredMap;
IndexMap indexMap(get(boost::vertex_index, dominator_tree));
std::vector<Vertex> domTreePredVector = std::vector<Vertex>(
num_vertices(dominator_tree),
boost::graph_traits<Graph>::null_vertex());
PredMap domTreePredMap = make_iterator_property_map(
domTreePredVector.begin(), indexMap);
lengauer_tarjan_dominator_tree(dominator_tree, vertex(0, dominator_tree),
domTreePredMap);
当我将 dominator_tree 的内容输出到 .dot 文件时,它与 trace 中的内容完全相同。即看起来上面最后一行的调用没有改变任何东西。输入图如下所示: http ://s24.postimg.org/y17l17v5x/image.png
INIT 节点是节点 0。如果我选择任何其他节点作为函数的第二个参数,它仍然返回相同的结果。
我究竟做错了什么??感谢任何帮助。