前向星
void add_edge(int u, int v, int w) {
edge[cnt].to = v;
edge[cnt].w = w;
edge[cnt].next = head[u];
head[u] = cnt++;
}
弗洛伊德(floyd)
void Floyd(MGraph *mGraph, int **iArrPath) {
for (int i = 1; i <= mGraph->iVertexCount; i++) {
for (int j = 1; j <= mGraph->iVertexCount; j++) {
iArrPath[i][j] = i;
}
}
for (int k = 1; k <= mGraph->iVertexCount; k++) {
for (int i = 1; i <= mGraph->iVertexCount; i++) {
for (int j = 1; j <= mGraph->iVertexCount; j++) {
if (mGraph->edges[i][k] + mGraph->edges[k][j] < mGraph->edges[i][j]) {
mGraph->edges[i][j] = mGraph->edges[i][k] + mGraph->edges[k][j