我想用提升breadth_first_visit
方法,我想爲它提供我自己的「外部」彩色地圖。 我定義如下彩色地圖在提升圖形breadth_first_visit
typedef boost::adjacency_list<boost::setS, boost::listS, boost::undirectedS,
boost::property<boost::vertex_index_t, int,
boost::property<boost::vertex_color_t, boost::default_color_type,
Node_t>>> GraphType;
其中Node_t
是一個結構,限定用於頂點的屬性的圖表。但是,我無法瞭解如何使用我自己的色彩地圖提供BFS。我想頂點顏色存儲在一個矢量,所以我的定義看起來像
std::vector<boost::default_color_type> colors;
,但我不能弄清楚,如何使用這個的BFS。
無論
boost::breadth_first_search(g, *boost::vertices(g).first,
boost::color_map(colors));
也不
boost::breadth_first_search(g, *boost::vertices(g).first,
boost::color_map(&colors[0]));
工作。雖然第一給了我一堆不同的編譯器錯誤(不支持如默認int,「助推:: color_traits」使用類類型的需要類型參數列表)第二編譯只有C2664中止:「提高::把」不能將參數2從'void *'轉換爲'ptrdiff_t'。
所以現在的問題是:我該如何使用自己的顏色映射結構。另外一個問題是:我如何獲取特定vertex_descriptor的顏色值?
在'升壓:: breadth_first_visit(克,*升壓::頂點(克)。首先,升壓:: color_map顏色表(:當前頂點作爲[] - 運算符在彩色地圖的參數的));'你'不傳遞訪問者 - 通過訪問者和色彩映射的簽名是什麼? – 2016-11-09 16:06:52
唷,那是相當長一段時間以前;)我沒有嘗試了這一點,但是這裏(http://www.boost.org/doc/libs/1_62_0/libs/graph/doc/breadth_first_visit.html)你用'BFSVisitor'類作爲參數找到第二個簽名。 – AquilaRapax 2016-11-09 20:23:19
我想我已經明白了 - 它使用「命名參數」簽名。我不知道你應該知道哪些名字是有效的參數,但對於'breadth_first_search',似乎'visitor'是一個,'color_map'是另一個。 – 2016-11-09 21:31:33