[英]I'm using boost::filtered_graph, but the output of print_graph and write_graphviz differ -- any idea why?
[英]Using boost filtered_graph without print_graph()
我希望是否還有其他方法可以使用boost :: filtered_graph()而不使用print_edges()或print_graph()函數。
在這里的鏈接中,似乎只有在調用print graph或print edge函數時,過濾器才能在每個節點上運行。
我確實了解謂詞在打印到std :: cout時會作用在圖的每個節點或邊上
還有其他方法可以使用嗎? 我可以使用for_each(begin_iter,end_iter)還是類似的東西? 請提出建議。
您可以使用#include <boost/graph/graph_utility.hpp>
,其中定義了很多迭代器宏:BGL_FORALL_EDGES,BGL_FORALL_VERTICES,BGL_FORALL_OUTEDGES等。
您的典型代碼如下所示:
BGL_FORALL_VERTICES(src, g, MyGraph_t )
{
BGL_FORALL_OUTEDGES(src, ed, g, MyGraph_t )
{
MyGraph_t::vertex_descriptor tgt = target(ed, g);
... do something ...
}
}
無論MyGraph_t是filtered_graph還是adjacency_list或任何其他BGL圖形類型,此代碼都將起作用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.