[英]Using bgl to build search tree with dfs
我想使用dfs算法創建圖形的搜索樹。 我在代碼中反復出現編譯錯誤(編譯錯誤很長,以至於我沒有粘貼它):
typedef adjacency_list <vecS, vecS, undirectedS> Graph;
typedef graph_traits <Graph>::edge_descriptor Edge;
typedef graph_traits <Graph>::vertex_descriptor Vertex;
typedef pair<int, int> E;
vector<E> edges;
Graph g(edges.begin(), edges.end(), n);
vector<Vertex> p(n);
Vertex s = vertex(0,g);
breadth_first_search(g, s, visitor(record_predecessors(&p[0], on_tree_edge())));
部分錯誤:
instantiated from here
/usr/include/boost/graph/breadth_first_search.hpp:39:7: error: ‘struct boost::predecessor_recorder<long unsigned int*, boost::on_tree_edge>’ has no member named ‘initialize_vertex’
/usr/include/boost/graph/breadth_first_search.hpp:40:7: error: ‘struct boost::predecessor_recorder<long unsigned int*, boost::on_tree_edge>’ has no member named ‘discover_vertex’
/usr/include/boost/graph/breadth_first_search.hpp:41:7: error: ‘struct boost::predecessor_recorder<long unsigned int*, boost::on_tree_edge>’ has no member named ‘examine_vertex’
/usr/include/boost/graph/breadth_first_search.hpp:42:7: error: ‘struct boost::predecessor_recorder<long unsigned int*, boost::on_tree_edge>’ has no member named ‘examine_edge’
/usr/include/boost/graph/breadth_first_search.hpp:43:7: error: ‘struct boost::predecessor_recorder<long unsigned int*, boost::on_tree_edge>’ has no member named ‘tree_edge’
/usr/include/boost/graph/breadth_first_search.hpp:44:7: error: ‘struct boost::predecessor_recorder<long unsigned int*, boost::on_tree_edge>’ has no member named ‘non_tree_edge’
/usr/include/boost/graph/breadth_first_search.hpp:45:7: error: ‘struct boost::predecessor_recorder<long unsigned int*, boost::on_tree_edge>’ has no member named ‘gray_target’
/usr/include/boost/graph/breadth_first_search.hpp:46:7: error: ‘struct boost::predecessor_recorder<long unsigned int*, boost::on_tree_edge>’ has no member named ‘black_target’
/usr/include/boost/graph/breadth_first_search.hpp:47:7: error: ‘struct boost::predecessor_recorder<long unsigned int*, boost::on_tree_edge>’ has no member named ‘finish_vertex’
make: *** [file] Error 1
breadth_first_search
需要一個BFSVisitor
。 record_predecessors
返回一個EventVisitor
。 您需要使用make_bfs_visitor
才能使其正常工作。
breadth_first_search(g, s, visitor(make_bfs_visitor(record_predecessors(&p[0], on_tree_edge()))));
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.