For an undirected graph, obtain two values, the shortest distance sum between all vertices and all other vertices, and delete the value after an edge.
The data size is 100 points and 1000 edges.
For example in the White Book, we will not mention finding the Shortest Path Tree for each vertex. If it is not the edge of the shortest path tree, we do not need to calculate the shortest path. because the number of points is only 100, the edge of the tree is only n-1. Therefore, for the tree with each vertex as the Source Vertex, you only need to re-calculate the n-1 shortest path. The complexity of each calculation is N * m, and the final complexity is N * n * m * log (). I personally think it is a little high, but it runs very fast.
Pay attention to the heavy edge. You need to make more judgments.
Summon code:
#include <iostream>#include <cstdio>#include <cstring>#include <queue>#define maxn 2222typedef long long ll;using namespace std;struct heapnode{ ll D,U; bool operator < (heapnode ND) const { return D>ND.D; }};ll inf=~0U>>2;ll to[maxn],c[maxn],next[maxn],first[maxn],edge;ll u[maxn],v[maxn],w[maxn],minlen[maxn][maxn],tim[maxn][maxn];ll dis[maxn],from[maxn],C[maxn],f[maxn][maxn];bool key[maxn],akey[maxn],done[maxn];ll n,m,L,ans,sum;void _init(){ edge=-1,sum=ans=0; for (int i=1; i<=n; i++) { first[i]=-1,C[i]=0; for (int j=1; j<=n; j++) minlen[i][j]=inf; for (int j=1; j<=m; j++) f[i][j]=0; }}void addedge(int U,int V,int W){ edge++; to[edge]=V,c[edge]=W,next[edge]=first[U],first[U]=edge; edge++; to[edge]=U,c[edge]=W,next[edge]=first[V],first[V]=edge;}ll dijkstra(int S,int EG,ll Dis[],ll From[],bool Key[]){ priority_queue