[英]Wrap my custom graph with boost::graph and calculate dijkstra_shortest_paths
I've got a project with a large graph filled like this: 我有一个项目,其中填充了一个大图,如下所示:
struct EdgeItem{
int mPid1;
int mPid2;
double weight;
};
struct StationItem{
int mPid;
QString mName;
};
QMap<int, StationItem> StationsMap;
QList<EdgeItem> mEdgesList;
QVector<EdgeItem*> GetEdgesByPid(int Pid);
// and some other service methods
Stations map indexed by Pid. 车站地图按Pid索引。 Graph's edges as MapLayerEdgeItem have weight.
作为MapLayerEdgeItem的图形的边缘具有权重。 It's inmportant no not have to copy graph's data and use existing structures.
不必复制图的数据并使用现有的结构就很重要。 I need to run and calculate dijkstra_shortest_paths on it.
我需要运行并计算它的dijkstra_shortest_paths。 Please suggest what I need to start with.
请提出我需要开始的事情。
In order do this you need to first adapt your graph to the boost graph library (BGL) interface. 为此,您需要首先使图形适应增强图形库(BGL)界面。 As mentioned in the comment look at this question which links boost's how to convert existing graphs .
正如评论中提到的,请看这个问题 ,它链接了boost的如何转换现有图形的方法 。
It seems you are really asking two questions. 看来您确实在问两个问题。 How do I adapt my graph representation to BGL?
如何使我的图形表示适应BGL? and How do I perform (and extract meaning from) Dijsktra in boost?
以及如何在Boost中执行Dijsktra(并从中提取含义)?
Both aren't exactly trivial if you are not used to BGL. 如果您不习惯BGL,两者都不是完全无关紧要的。 Why not try to tackle the adapter then ask a more specific question when you run into trouble?
为什么不尝试解决适配器问题,然后在遇到麻烦时提出一个更具体的问题?
If all you need is Djikstra, I would suggest using your own implementation. 如果您只需要Djikstra,我建议您使用自己的实现。 If you think you will use other BGL functionality then an adapter is the way to go.
如果您认为您将使用其他BGL功能,则可以使用适配器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.