Please see below code for dijkstra algorithm and tell me is it perfectly correct!
typedef pair<int, int> edge;
int n, m, tc, a, b, c;
double ans;
int path[505];
vector<edge> adj[505];
void Dijkstra(){
for( int i=2; i<=n; ++i ) path[i] = INF;
path[1] = 0;
priority_queue<edge> pq;
pq.push( edge(1, 0) ); //here, edge is a pair whose first element is vertex number and second element is weight of edge
while( !pq.empty() ){
int u = pq.top().first;
int W = pq.top().second;
pq.pop();
if( path[u] != W ) continue;
for( int i=0; i<adj[u].size(); ++i ){
int v = adj[u][i].first;
int w = adj[u][i].second;
if( path[v] > W + w ){
path[v] = W + w;
pq.push( edge(v, path[v]) );
}
}
}
}