Copy the code newint.h from line 8 to 75 to Label 1
Here are some algorithms solving above problems.
You can use them for it.
Use type adjacent_table to storage a graph.
Use the function the set the size of the graph.
gp.resize(V);
Use operator= to set the value of a directed edge.
gp[u][v] = w;
Use the function SPFA to solve the problem.
SPFA_Result r1 = SPFA(gp, source);
Here, SPFA_result r1 saves the solution.
mindist[i] : the distance from the source to vertex i.
inf_sp : all the vertexes what have an minus infinity solution.
Warning. If the graph has minus weight, do not use it.
Use the function Dijkstra to solve the problem.
vector<ll> r2 = Dijkstra(gp, source); // long long
r2 saves all the sp from source to all vertexes.
Here are some algorithms solving above problems.
You can use them for it.
Use type adjacent_matrix to storage a graph.
Use the function the set the size of the graph.
gp.resize(V); for (int i=0;i<V;i++) gp[i].resize(V);
Use operator= to set the value of a directed edge.
gp[u][v] = w;
Use the function Floyd to solve the problem.
vector<vector<ll> > r3 = Floyd(gp);
Here, r3 saves the distance from any node u to any other node v.