[英]C++ Boost Graph Library:- Specifying Root Node for a DFS
Using the standard on a directed graph, 在有向图上使用标准,
std::vector<size_type> dtime(N);
std::vector<size_type> ftime(N);
size_type t = 0;
dfs_time_visitor<size_type*> vis(&dtime[0], &ftime[0], t);
depth_first_search(graph, visitor(vis));
appears to always start the dfs from node 0. 似乎总是从节点0启动dfs。
How does one tell the algorithm to start from a known "root node"? 如何告诉算法从已知的“根节点”开始?
Here you can find a list of all the overloads for depth_first_search
. 在这里,您可以找到
depth_first_search
的所有重载列表。 The one you need is the " named parameter version". 你需要的是“ 命名参数版本”。 The parameter you need to use is "root_vertex" and your invocation of
depth_first_search
would simply be: 您需要使用的参数是“root_vertex”,而您对
depth_first_search
的调用只是:
depth_first_search(graph, visitor(vis).root_vertex(root_vertex_descriptor));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.