简体   繁体   English

BGL中的Lengauer Tarjan算法(增强图库)

[英]Lengauer Tarjan Algorithm in BGL (boost graph library)

I need to create a dominator tree for a given graph. 我需要为给定的图形创建一个控制树。 The code I have compiles and runs without errors, but the output looks exactly the same as the input. 我拥有的代码可以编译并运行,没有错误,但是输出看起来与输入完全相同。

I have defined the following type for my graph (to be analyzed) 我为图表定义了以下类型(待分析)

typedef boost::adjacency_list<boost::listS, boost::vecS,
  boost::bidirectionalS, vertex_info, edge_info> Graph;

and I would like to have another object containing the corresponding dominator tree. 我想让另一个对象包含相应的支配者树。 I tried the following: 我尝试了以下方法:

  // 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);

When I output the content of dominator_tree to a .dot file, it is exactly the same as in trace. 当我将dominator_tree的内容输出到.dot文件时,它与trace中的内容完全相同。 Ie it looks like the call of the last line above did not change anything. 即看起来上面最后一行的调用没有更改任何内容。 The input graph looks like this: http://s24.postimg.org/y17l17v5x/image.png 输入图如下所示: http : //s24.postimg.org/y17l17v5x/image.png

The INIT node is the node 0. If I choose any other node as the second argument of the function, it still returns an identical result. INIT节点是节点0。如果我选​​择其他任何节点作为该函数的第二个参数,它仍将返回相同的结果。

What am I doing wrong?? 我究竟做错了什么?? Apreciate any help. 感谢任何帮助。

Taking a look at the documentation ( http://www.boost.org/doc/libs/1_40_0/libs/graph/doc/lengauer_tarjan_dominator.htm ) I see that the first parameter is marked IN. 看一下文档( http://www.boost.org/doc/libs/1_40_0/libs/graph/doc/lengauer_tarjan_dominator.htm ),我看到第一个参数标记为IN。

This means that this is an input parameter ONLY. 这意味着这仅是输入参数。 So you should not expect it to be changed! 因此,您不应期望它会被更改!

The THIRD parameter is marked OUT. THIRD参数标记为OUT。 So this is the value that will be changed following the call. 因此,这是将在调用后更改的值。 According to the documentation: 根据文档:

OUT: DomTreePredMap domTreePredMap The dominator tree where parents are each children's immediate dominator. OUT:DomTreePredMap domTreePredMap父级树,其中父级是每个孩子的直接父级。

So, if you want the graph to be changed, you will have to do it yourself: remove all existing edges and then iterate through the tree adding edges to the graph as specified by the tree. 因此,如果要更改图形,则必须自己做:删除所有现有边,然后遍历树,按照树指定的方式将边添加到图形中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 Boost 的 Lengauer Tarjan 算法计算支配图并使用 graphviz 显示它 - Computing a dominator graph using Boost's Lengauer Tarjan algorithm and display it using graphviz Boost Graph Library:BGL内置了一个用于社区检测的简洁算法吗? - Boost Graph Library: Is there a neat algorithm built into BGL for community detection? 在Fortran程序中使用Boost Graph Library(BGL) - Using Boost Graph Library (BGL) in Fortran program 使用Boost Graph Library(BGL)和现有的图形数据结构 - Using Boost Graph Library (BGL) with existing graph data structure 使用BGL(Boost图形库)查找DAG中的所有拓扑排序 - Find all topological sorts in a DAG using BGL (Boost graph library) 使用 BOOST 库以 BGL 图的形式存储嵌套的 XML 结构 - Storing a nested XML structure in form of BGL graph using BOOST library 使用Boost Graph Library(BGL)识别连接的组件 - Using Boost Graph Library (BGL) to identify connected components 自定义InputIterator用于Boost图形(BGL) - Custom InputIterator for Boost graph (BGL) 如何将一组C ++动态分配的对象表示为BGL(提升图库)图以获得其依赖图? - How to represent a group of C++ dynamically allocated objects as a BGL (Boost Graph Library) graph in order to obtain their dependency graph? 通过使用boost spirit qi解析器迭代填充BGL图 - Iteratively populate a BGL graph by use of a boost spirit qi parser
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM