简体   繁体   English

用boost :: graph包装我的自定义图并计算dijkstra_shortest_paths

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

相关问题 Boost中的自定义图形距离dijkstra_shortest_paths - Custom graph distance in Boost dijkstra_shortest_paths boost :: dijkstra_shortest_paths覆盖内部图形权重? - boost::dijkstra_shortest_paths overwriting internal graph weights? dijkstra_shortest_paths Boost Graph Lib 1.57.0失败 - dijkstra_shortest_paths Boost Graph Lib 1.57.0 fails 增强图:dijkstra_shortest_paths:无法形成对“ void”的引用 - Boost graph: dijkstra_shortest_paths: cannot form a reference to 'void' 当特定节点对之间存在多条最短路径时,boost graph dijkstra_shortest_paths 如何选择最短路径? - How does boost graph dijkstra_shortest_paths pick the shortest path when there are multiple shortest paths between a specific pair of nodes? 我可以在“循环”有向图的 BGL 中使用 dijkstra_shortest_paths - Can I use dijkstra_shortest_paths in BGL on "cyclic" directed graph boost的dijkstra_shortest_paths中的负边权重检查 - Negative edge weight check in boost's dijkstra_shortest_paths 如何从 GraphML 获取边权重到 boost::dijkstra_shortest_paths? - How do I get edge weights from GraphML into boost::dijkstra_shortest_paths? 使用 Dijkstra 在提升图中找到最短路径 - Finding the shortest path in a boost graph using Dijkstra 具有VertexList的Dijkstra最短路径=增强图中的ListS - Dijkstra Shortest Path with VertexList = ListS in boost graph
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM