Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void dijkstra()
- {
- int a,b,g;
- ii f,m;
- priority_queue<ii,vii,greater<ii>>pq; //ii = pair<int,int>
- pq.push(ii(0,s));
- while(!pq.empty()){
- f=pq.top(), pq.pop();
- a=f.first, b=f.second;
- if(a>dis[b])continue;
- for(g=0;g<wq_list[b].size();g++){ //wq_list = adjacency list
- m=wq_list[b][g];
- if(dis[b]+m.second<dis[m.first]){
- dis[m.first]=dis[b]+m.second;
- pq.push(ii(dis[m.first],m.first));
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement