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