简体   繁体   中英

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. Graph's edges as MapLayerEdgeItem have weight. 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. 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. As mentioned in the comment look at this question which links boost's how to convert existing graphs .

It seems you are really asking two questions. How do I adapt my graph representation to BGL? and How do I perform (and extract meaning from) Dijsktra in boost?

Both aren't exactly trivial if you are not used to 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. If you think you will use other BGL functionality then an adapter is the way to go.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM