如何为我的图提供 vertex_index 属性
由于我的图使用 setS 作为顶点,我必须为我的图提供 vertex_index 属性映射,或者为 write_graphviz 提供显式的 vertex_id 参数,以便能够使用 write_graphviz。 我的图定义为: typedef adjacency_list
其中 NodeData 和 EdgeData 是结构体。 您能否给我一个非常简单的示例,说明如何为我的图提供 vertex_index 属性映射?或者如何向 write_graphviz 提供显式的 vertex_id 参数?
谢谢
Since my graph use setS for vertex, I have to either provide a vertex_index property map for my graph, or give an explicit vertex_id argument to write_graphviz, to be able to use write_graphviz.My graph is defined as: typedef adjacency_list<setS, setS, undirectedS, NodeData, EdgeData> Graph;
Where NodeData and EdgeData are structures.
Can you please give me a very simple example of how to provide a vertex_index property map for my graph ? or how to give an explicit vertex_id argument to write_graphviz ?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
解决办法就是:
1) 假设顶点描述符定义为
typedef Graph::vertex_descriptor NodeID;
那么您需要定义一个关联属性映射,如下所示:2) 在代码中,按如下方式索引所有顶点:
3) 您现在可以使用 graphvize 绘制/可视化您的图表,如下所示:
该图表将在 example.txt 中描述,您可以使用 graphviz 可视化它。
The solution is just to:
1) Say the vertex descriptor is defined as
typedef Graph::vertex_descriptor NodeID;
then you need to define an associative property map as following:2) In the code, index all vertices as following:
3) You can now use graphvize to drow/visualize your graph as following:
The graph will be described in example.txt, you can visualize it using graphviz.