Let GV E be the following weighted undirected graph V1 2 3 4

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=l, 2, 3, 4, 5.

Solution

Sage: from sage. graphs.distances_all_pairs introduce diameter

Sage: G = graphs. Petersen Graph ()

Sage: diameter (G, algorithm=\'iFUB\')

2

Then

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,

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site