簡體   English   中英

沒有edge_predicate的BOOST filter_graph中的out_edges()實現

[英]out_edges() implementation in BOOST filtered_graph without edge_predicate

我有一個boost :: filtered_graph <Graph_t,boost :: keep_all,vertex_predicate>

FG是我的過濾圖。 v1是我要使用out_edge_iterators查找所有邊緣的任何節點

edge_predicate是“ keep_all”頂點謂詞,是一些謂詞,用於修改圖的節點屬性。

在文檔中,給出了:

graph_traits<filtered_graph>::out_edge_iterator 
//The type for the iterators returned by out_edges(), which is:
filter_iterator<EdgePredicate, graph_traits<Graph>::out_edge_iterator>
The iterator is a model of MultiPassInputIterator.

現在,當我定義out_edge_iterators時:

out_edge_iterator begin, end;
boost::tie( begin, end) = out_edges ( v1, FG )

我期望的是以下內容:1.應考慮所提供的edge_predicate並根據該條件過濾邊緣。 基本上, 開始結束迭代器應基於邊緣謂詞為filter_iterators。 2.我不認為應該在邊緣的其他節點上調用vertex_predicate。 例如,假設v1具有3個外邊緣(v1,v2),(v1,v4),(v1,v6)。

我的觀察是:在查找v1的 out_edges的過程中,在v1的第一個相對節點上調用了vertex_predicate。 在上述情況下,

suppose begin --> points to edge (v1, v2), then, 
out_edges(v1, G) ---> calls vertex_predicate on **v2**

為什么會這樣呢? 是否由於out_edges()函數的實現而導致查找相鄰節點並返回找到的第一個節點?

我在調用neighbor_vertices()時觀察到的情況相同。 文檔說它的模型為out_edge_iterator <edge_predicate,...>。

我得到了預期的結果。 但是我想知道我的猜測是否正確? 我沒有提供任何edge_predicate這樣的過濾圖。

請提出建議。

當過濾后的圖形排除某個頂點時,它也會排除與之關聯的所有邊。 這意味着即使您指定keep_all ,也會濾除某些邊緣。

在內部, filtered_graph具有一個特殊的邊緣謂詞(由邊緣謂詞和頂點謂詞組合而成),用於過濾邊緣。 當您要求給定頂點的邊緣時,BGL將為您提供一對過濾器迭代器。

“ End”迭代器通常基於底層圖形的功能out_edges的“ end”。 “開始”迭代器從函數out_edges的“開始”開始,並檢查邊緣的“目標”是否為圖形的一部分。 如果不是,則迭代器將跳過它,直到找到合適的頂點(或單擊“結束”)為止。

因此,迭代器不斷檢查“目標”頂點並調用頂點謂詞。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM