Menu

(Solved) : Given Undirected Graph G V E Square Graph G2 V E2 Two Nodes U V V U V E2 Distance U V G 2 Q27789604 . . .

Given an undirected graph G = (V, E), the square of it is thegraph G2 = (V, E2 ) such that for any two nodes u, v ? V , {u, v} ?E2 if and only if the distance between u and v in G is at most 2,i.e., {u, v} ? E or there is a w ? V such that {u, w}, {w, v} ? E.(Therefore, it is clear that any e ? E will remain an edge also inE2 .)

1.) Propose an algorithm that takes as an input a graph G with amax-degree of ? in the adjacency list model and outputs G2 inO(?2n)-time, and prove the running time of your algorithm.

2.) Propose an algorithm that takes as an input a graph G in theadjacency matrix model and outputs G2 in o(n 3 )-time. Prove thecorrectness and running time of your algorithm. (Hint: We call itan adjacency matrix for a reason…)

Expert Answer


Answer to Given Undirected Graph G V E Square Graph G2 V E2 Two Nodes U V V U V E2 Distance U V G 2 Q27789604 . . .

OR