简体   繁体   English

boost 图形库示例六度 Kevin Bacon:示例中的 Vertex() 是什么

[英]boost graph library example six degrees of Kevin Bacon: what is Vertex() in the example

I am trying to learn Boost Graph library and came across an example called "Six Degrees of Kevin Bacon".我正在尝试学习 Boost Graph 库,并遇到了一个名为“六度 Kevin Bacon”的示例。 Here is the URL https://www.boost.org/doc/libs/1_61_0/libs/graph/doc/kevin_bacon.html这是 URL https://www.boost.org/doc/libs/1_61_0/libs/graph/doc/kevin_bacon.ZFC35FDC70D5FC69A7369883A82EZC

In that example, I see:在那个例子中,我看到:

...
boost::tie(pos, inserted) = actors.insert(std::make_pair(actors_name, Vertex()));
...

What does Vertex() refer to? Vertex()指的是什么?

I see an alias called Vertex a few lines above the Vertex() like below but I am not understanding what Vertex() is for:我在Vertex()上方几行看到一个名为Vertex的别名,如下所示,但我不明白Vertex()的用途:

typedef graph_traits<Graph>::vertex_descriptor Vertex;

Can someone please help me understand this one?有人可以帮我理解这个吗? I am new to Boost and feel like I am already lost!我是 Boost 的新手,感觉自己已经迷路了!
The documentation is very difficult to read through and understand.文档很难通读和理解。

Thanks.谢谢。

The Vertex (graph theory) is used to record an actor's connections to other actors.顶点(图论)用于记录一个演员与其他演员的联系。 They are directly connected if they have appeared in the same movie.如果他们出现在同一部电影中,则它们直接相连。

The Vertex used in the example is described here: boost::graph_traits<Graph>示例中使用的 Vertex 如下所述: boost::graph_traits<Graph>

This line:这一行:

boost::tie(pos, inserted) = actors.insert(std::make_pair(actors_name, Vertex()));

tries to insert a pair with the actor's name and a default constructed (empty) Vertex .尝试插入带有演员姓名和默认构造(空) Vertexpair If it fails ( inserted==false ), it's because the actor was already present and pos will be pointing at the existing pair with a Vertex that already has at least one connection.如果失败( inserted==false ),那是因为参与者已经存在,并且pos将指向现有的pair ,其Vertex已经至少有一个连接。 If it succeeds pos will point at the newly inserted pair with an empty Vertex .如果成功, pos将指向新插入的pair ,并带有一个空的Vertex

The add_edge step later on is what connects the two actors.稍后的add_edge步骤连接了两个参与者。 When the file has been processed you'll have a graph of how all the actors in the file are connected (via edges).处理完文件后,您将看到文件中所有参与者如何连接(通过边)的图表。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM