简体   繁体   English

使用Boost Graph Library(BGL)和现有的图形数据结构

[英]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.

相关问题 使用 BOOST 库以 BGL 图的形式存储嵌套的 XML 结构 - Storing a nested XML structure in form of BGL graph using BOOST library 在Fortran程序中使用Boost Graph Library(BGL) - Using Boost Graph Library (BGL) in Fortran program 使用BGL(Boost图形库)查找DAG中的所有拓扑排序 - Find all topological sorts in a DAG using BGL (Boost graph library) 使用Boost Graph Library(BGL)识别连接的组件 - Using Boost Graph Library (BGL) to identify connected components BGL中的Lengauer Tarjan算法(增强图库) - Lengauer Tarjan Algorithm in BGL (boost graph library) 使用现有数据结构提升图表或将其用作数据结构 - Boost graph with existing data structure or using it as the data structure 自定义InputIterator用于Boost图形(BGL) - Custom InputIterator for Boost graph (BGL) Boost Graph Library:BGL内置了一个用于社区检测的简洁算法吗? - Boost Graph Library: Is there a neat algorithm built into BGL for community detection? 如何将一组C ++动态分配的对象表示为BGL(提升图库)图以获得其依赖图? - How to represent a group of C++ dynamically allocated objects as a BGL (Boost Graph Library) graph in order to obtain their dependency graph? 使用Boost Graph库创建图 - Creating a graph using Boost Graph library
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM