How to fit a custom graph to the boost graph library template?

前端 未结 2 464
鱼传尺愫
鱼传尺愫 2021-02-06 01:05

I\'m rusty on C++ templates and I\'m using the boost graph library (a fatal combination). I\'ve searched the web and can\'t find any direct instructions on how to take a custom

2条回答
  •  星月不相逢
    2021-02-06 01:23

    The approach, as I understand it, is to specialize the boost::graph_traits structure for your graph type. This configures BGL with various important properties it needs to know about your graph. You then specialize global template functions for your graph's specialized type of graph_traits to implement whatever boost graph interfaces might apply to your specific kind of graph.

    An example is right there in the BGL documentation:

    http://www.boost.org/doc/libs/1_43_0/libs/graph/doc/leda_conversion.html

    There are links for several of the different interfaces there, which indicate which global template functions you'll need to specialize for your graph if you want to support that interface. The full list of interfaces is here:

    http://www.boost.org/doc/libs/1_43_0/libs/graph/doc/graph_concepts.html

提交回复
热议问题