Skip to main content

Tenda ac21 unboxing and user experience ||

Comments

  1. Bellman ford's Algorithm
    #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);
    }

    ReplyDelete

Post a Comment