#include #include#include#include
using namespacestd;structnode_info
{public:
node_info (int i,intw)
: index (i), weight (w) {}
node_info ()
: index(0),weight(0) {}
node_info (const node_info &ni)
: index (ni.index), weight (ni.weight) {}
friendbool operator < (const node_info& lth,const node_info&rth) {return lth.weight > rth.weight ; //为了实现从小到大的顺序
}public:int index; //结点位置
int weight; //权值
};structpath_info
{public:
path_info ()
: front_index(0), weight (numeric_limits::max()) {}public:intfront_index;intweight;
};//single source shortest paths
classss_shortest_paths
{public:
ss_shortest_paths (const vector >& g,intend_location)
:no_edge (-1), end_node (end_location), node_count (g.size()) , graph (g)
{}//打印最短路径
void print_spaths (