/* ** This is Bellman-Ford's algorithm for finding Single-Source-Shortest-Paths ** on a weighted graph that contains negetive weight cycle. It's runtime complexity ** is O(VE) */ #include <cstdio> #include <cstring> #include <vector> using namespace std; class Edge { public: int u,v,w; Edge(int u_,int v_,int w_) {u=u_,v=v_,w=w_;} }; #define MAX 100 #define min(a,b) (a)<(b)?(a):(b) #define INF 214748364 vector<Edge> edgeList; int V, dist[MAX+7]; int process(int s,int t) { int u,v,w; dist[s]=0; for(int d=0;d<V-1;d++) for(int i=0;i<(int)edgeList.size();i++) { u=edgeList[i].u, v=edgeList[i].v, w=edgeList[i].w; dist[v]=min(dist[v],dist[u]+w); } return dist[t]; } int main() { /* code */ return 0; }