[英]boost graph library - minimal example of vertex colors and graphviz output
[英]boost graph library example six degrees of Kevin Bacon: what is Vertex() in the example
我正在嘗試學習 Boost Graph 庫,並遇到了一個名為“六度 Kevin Bacon”的示例。 這是 URL https://www.boost.org/doc/libs/1_61_0/libs/graph/doc/kevin_bacon.ZFC35FDC70D5FC69A7369883A82EZC
在那個例子中,我看到:
...
boost::tie(pos, inserted) = actors.insert(std::make_pair(actors_name, Vertex()));
...
Vertex()
指的是什么?
我在Vertex()
上方幾行看到一個名為Vertex
的別名,如下所示,但我不明白Vertex()
的用途:
typedef graph_traits<Graph>::vertex_descriptor Vertex;
有人可以幫我理解這個嗎? 我是 Boost 的新手,感覺自己已經迷路了!
文檔很難通讀和理解。
謝謝。
頂點(圖論)用於記錄一個演員與其他演員的聯系。 如果他們出現在同一部電影中,則它們直接相連。
示例中使用的 Vertex 如下所述: boost::graph_traits<Graph>
這一行:
boost::tie(pos, inserted) = actors.insert(std::make_pair(actors_name, Vertex()));
嘗試插入帶有演員姓名和默認構造(空) Vertex
的pair
。 如果失敗( inserted==false
),那是因為參與者已經存在,並且pos
將指向現有的pair
,其Vertex
已經至少有一個連接。 如果成功, pos
將指向新插入的pair
,並帶有一個空的Vertex
。
稍后的add_edge
步驟連接了兩個參與者。 處理完文件后,您將看到文件中所有參與者如何連接(通過邊)的圖表。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.