Let GVE be the following weighted undirected graph V12345 an
Let G=(V,E) be the following weighted undirected graph: V={1,2,3,4,5} and E={[(4, 2) 8], [(4, 5) 10], [(5, 2) 3], [(4, 1) 3], [(1, 3) 2], [(5, 1) 5], [(3, 5) 2]} where [(i,j) a] means that (i,j) is an edge of weight a. Apply the all pairs shortest path algorithm to find the distance between every pair of nodes in G. (Represent the weights by a matrix A, and show the matrix A(k) after each step, for k=1,2,3,4,5.
Solution
sage: from sage.graphs.distances_all_pairs import diameter
sage: G = graphs.PetersenGraph()
sage: diameter(G, algorithm=\'iFUB\')
2
sage: G = Graph( { 0 : [], 1 : [], 2 : [1] } )
sage: diameter(G, algorithm=\'iFUB\')
+Infinity
![Let G=(V,E) be the following weighted undirected graph: V={1,2,3,4,5} and E={[(4, 2) 8], [(4, 5) 10], [(5, 2) 3], [(4, 1) 3], [(1, 3) 2], [(5, 1) 5], [(3, 5) 2] Let G=(V,E) be the following weighted undirected graph: V={1,2,3,4,5} and E={[(4, 2) 8], [(4, 5) 10], [(5, 2) 3], [(4, 1) 3], [(1, 3) 2], [(5, 1) 5], [(3, 5) 2]](/WebImages/21/let-gve-be-the-following-weighted-undirected-graph-v12345-an-1050042-1761546799-0.webp)