Welcome to this Blog . This is mainly for Bangladeshi people . This blog teach about technology and general science education .Most popular app, paid and uncommon app review are will be here.
Welcome to this Blog . This is mainly for Bangladeshi people . This blog teach about technology and general science education .Most popular app, paid and uncommon app review are will be here.
Bellman ford's Algorithm
ReplyDelete#include
using namespace std;
#define INF 0x3f3f3f3f
const int N=1e5+10;
typedef pair ipair;
vectoradj[N];
void shortestpath(int s,vector >adj[],int ver){
priority_queue,greater >pq;
vectordist(N,INF);
pq.push({0,s});
dist[s]=0;
while(!pq.empty()){
int u=pq.top().second;
pq.pop();
vector >::iterator it;
for(int i=1;i>ver;
cout<<"Enter the edges:";
cin>>edges;
for(int i=1;i<=edges;i++){
int x,y,z;
cin>>x>>y>>z;
adj[x].push_back({y,z});
}
int src;
cout<<"Enter the source vertex:";
cin>>src;
shortestpath(src,adj,ver);
}