[英]Using Boost Graph Library (BGL) with existing graph data structure
I have an existing graph, built from my own vertex and edge classes, as follows: 我有一个现有的图形,由我自己的顶点和边类构建,如下所示:
struct Graph;
struct OutPort {};
struct InPort {
OutPort* connectedOutput;
};
struct Node {
Graph* graph;
std::list<InPort> inputs;
std::list<OutPort> outputs;
};
struct Graph {
std::list<Node> nodes;
}
That is, the graph is composed of nodes, which have 0..* input and output ports. 也就是说,图形由节点组成,节点具有0 .. *输入和输出端口。 An input port be connected to to 0..1 output ports of any node (including its own). 输入端口连接到任何节点(包括其自身)的0..1输出端口。
I would like to apply the BGL algorithms to this graph, but cannot figure out how to do it while using either keeping my existing data structures above, or provide a suitable mapping between them and the BGL data structures. 我想将BGL算法应用于此图,但无法弄清楚如何使用上面的现有数据结构,或者在它们和BGL数据结构之间提供合适的映射。
I would be grateful for an introductory example. 我将很感激一个介绍性的例子。
Making the example is a little bit involved. 举个例子就是一个例子。 However, you need to model a graph concept of your choosing. 但是,您需要为您选择的图形概念建模。
http://www.boost.org/doc/libs/1_63_0/libs/graph/doc/graph_concepts.html http://www.boost.org/doc/libs/1_63_0/libs/graph/doc/graph_concepts.html
I find it hard to see from your model how edges are represented (ports could well be disconnected, or maybe OutPort
refers back to a Node
etc.). 我发现很难从你的模型中看到边缘是如何表示的(端口可以很好地断开连接,或者OutPort
可能OutPort
返回Node
等)。 I sense you might want to model AdjacencyGraph. 我觉得你可能想要模拟AdjacencyGraph。 The required operations are listed on the linked page. 链接页面上列出了所需的操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.