Bell
Bell
SOURCE CODE:
#include <iostream>
#include <vector>
#include <limits.h>
using namespace std;
struct Edge
{
int src, dest, weight;
};
int main()
{
int V, E;
cout << "Enter the number of vertices: ";
cin >> V;
cout << "Enter the number of edges: ";
cin >> E;
vector<Edge> edges(E);
cout << "Enter the edges with their weights (source destination weight):\n";
for (int i = 0; i < E; ++i)
{
cin >> edges[i].src >> edges[i].dest >> edges[i].weight;
}
int src;
cout << "Enter the source vertex: ";
cin >> src;
BellmanFord(edges, V, E, src);
return 0;
}
INPUT AND OUTPUT:
OUTPUT GRAPH: