#include <stdio.h>int main () {int m, n, I, J, K, T1, T2, T3, e[10][10];scanf_s ("%d%d", &n, &m); for (i = 1; i <= n;i++) for (j = 1; J <= N; j + +)//initialize the matrix{if (i = = j) E[i][j] = 0;elsee[i][j] = 99999;} for (i = 1; I <= m; i++)//read the vertex{scanf_s ("%d%d%d", &t1, &t2, &T3); e[t1][t2] = t3;} for (k = 1, K <= n;k++) for (i = 1, i <= n;i++) for (j = 1; J <= N; j + +) {if (E[i][j] > E[i][k] + e[k][j]) E[i][j] = E[i][k] + e[k][j];} for (i = 1; l <= N; i++) {for (j = 1; J <= N; j + +) printf_s ("%d", E[i][j]);p rintf_s ("\ n");} GetChar (); return 0;}
n represents the number of nodes, and M represents the number of edges. At the time of input T1 T2 represents two sides, T3 represents the weight value, K represents the middle node, finally can output any two points between the shortest path (code from Guile).
Floyd algorithm to find the shortest path of multiple sources