我一直试图让升级图lib的dijkstra_shortest_paths编译大约一个星期,现在没有用.我试图使用外部属性映射来模板化方法所需的不同命名参数.我的图形使用顶点和边缘的捆绑属性,我已经能够成功构建图形.我会告诉你我的代码:
// vertex bundled properties
struct BusStop
{
unsigned int id; //used for creating vertex index property map
string name;
Location* pLocation;
};
// edge bundled properties:
struct Route
{
string routeName;
BusType type;
float distance;
};
Run Code Online (Sandbox Code Playgroud)
这是我的图表声明:
typedef boost::adjacency_list<boost::vecS, boost::setS, boost::undirectedS, BusStop, Route> BusRouteGraph;
这是我尝试在给定图形上执行dijkstra最短路径的方法:
template<typename Graph>
bool shortestPathSearch(Graph& g, typename
boost::graph_traits<Graph>::vertex_descriptor src,
typename boost::graph_traits<Graph>::vertex_descriptor dest)
{
bool bPathFound = false;
VertexIndexMap index_map = get(&BusStop::id, g);
// Initialize index_map
typedef typename graph_traits<Graph>::vertex_iterator V_Iter;
V_Iter v_iter, v_iter_end;
int c = …Run Code Online (Sandbox Code Playgroud)