分析:经典的传递闭包,用floyd-warshall算法,是O(n^3)。
for(int k = 1; k <= n; k++)
for(int i = 1; i <= n; i++)
for(int j = 1; j <= n; j++)