简体   繁体   English

边列表上带有地图的 BGL 图

[英]BGL graph with map on edges list

I'm trying to create some specific structure with Boost Graph Library.我正在尝试使用 Boost Graph Library 创建一些特定的结构。 I need to have nodes (vertexes) with input and output ports.我需要有带有输入和输出端口的节点(顶点)。 Each ouput port could be connected to any input port of other node.每个输出端口可以连接到其他节点的任何输入端口。 I want to be able to check if specific output or input port is connected to any other port.我希望能够检查特定的输出或输入端口是否连接到任何其他端口。

The idea is to use std::map as OutEdgeList inside of adjacency_list.这个想法是在 adjacency_list 中使用 std::map 作为 OutEdgeList 。

According to: http://www.boost.org/doc/libs/1_52_0/libs/graph/doc/using_adjacency_list.html#sec:choosing-graph-type I'm only able to select one of std::vector, std::list, std::slist, std::set, std::multiset and std::hash_set.根据: http : //www.boost.org/doc/libs/1_52_0/libs/graph/doc/using_adjacency_list.html#sec :choosing-graph-type 我只能选择 std::vector 之一, std::list、std::slist、std::set、std::multiset 和 std::hash_set。 (you can choose mapS as a type but it is implemented as std::set and I cannot get the value by key) (您可以选择 mapS 作为类型,但它实现为 std::set 并且我无法通过键获取值)

And I have a couple of questions:我有几个问题:

  1. Is it possible to use std::map?是否可以使用 std::map? If yes how?如果是如何?
  2. How can I iterate throught inputs of vertex when using std::map?使用 std::map 时如何遍历顶点的输入?
  3. If the above is impossible, how can I implement structures that suits the problem?如果以上是不可能的,我该如何实现适合问题的结构?

Thank you!谢谢!

我终于切换到Lemon 图形库,它不像 BGL 那样 hacky

I do not see reasons why map cannot be used as data structure to store outgoing edges.我不明白为什么 map 不能用作存储传出边缘的数据结构。 Map has iterators that work in the similar way to say std::vector , etc. To handle incoming edges you will need 2 maps on each vertex. Map 的迭代器的工作方式与std::vector等类似。要处理传入的边,每个顶点上需要 2 个映射。 AFAIK BGL supports both lists on vertexes. AFAIK BGL 支持顶点上的两个列表。

I would recommend you to modify (hack) BGL and see what will happen.我建议你修改(hack)BGL,看看会发生什么。 The change might be not small.变化可能不小。 You will have to provide adjacency_list specializations for your new type of container.您必须为您的新型容器提供 adjacency_list 专业化。 Most likely this will work.这很可能会奏效。

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

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