0001 template <typename Tv, typename Te> struct DijkstraPU { //针对Dijkstra算法的顶点优先级更新器 0002 virtual void operator() ( Graph<Tv, Te>* g, int uk, int v ) { 0003 if ( UNDISCOVERED == g->status ( v ) ) //对于uk每一尚未被发现的邻接顶点v,按Dijkstra策略 0004 if ( g->priority ( v ) > g->priority ( uk ) + g->weight ( uk, v ) ) { //做松弛 0005 g->priority ( v ) = g->priority ( uk ) + g->weight ( uk, v ); //更新优先级(数) 0006 g->parent ( v ) = uk; //并同时更新父节点 0007 } 0008 } 0009 };