ora*_*001 3 c++ depth-first-search boost-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));
Run Code Online (Sandbox Code Playgroud)
似乎总是从节点0启动dfs.
如何告诉算法从已知的"根节点"开始?
小智 9
在这里,您可以找到所有重载的列表depth_first_search.你需要的是" 命名参数版本".您需要使用的参数是"root_vertex",您的调用depth_first_search只是:
depth_first_search(graph, visitor(vis).root_vertex(root_vertex_descriptor));
Run Code Online (Sandbox Code Playgroud)