简体   繁体   中英

BGL graph with map on edges list

I'm trying to create some specific structure with 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.

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. (you can choose mapS as a type but it is implemented as std::set and I cannot get the value by key)

And I have a couple of questions:

  1. Is it possible to use std::map? If yes how?
  2. How can I iterate throught inputs of vertex when using 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 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. AFAIK BGL supports both lists on vertexes.

I would recommend you to modify (hack) BGL and see what will happen. The change might be not small. You will have to provide adjacency_list specializations for your new type of container. Most likely this will work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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