8 4 5 18 6 8 (a) Graph G 12 3 8 (E) 6 (b) Tree Ti 12 F E 5 18 6 (c) Tree T₂ B

Linear Algebra: A Modern Introduction
4th Edition
ISBN:9781285463247
Author:David Poole
Publisher:David Poole
Chapter3: Matrices
Section3.7: Applications
Problem 74EQ
icon
Related questions
Question
=
Question 1 (SPTree Verification
You are given a directed weighted graph G (V, E, W), a vertex s E V
and a tree T such that each vertex vi E V maps to a node in T. The root of T is s. For each node n in T we define the
predecessor n. as its parent in the tree. By definition, s. =Nil for the root node s. For any other node n₁.π =
n2, there
must be a direct edge (n2, n₁) EE. You need to develop an algorithm that tests whether T is a shortest-path tree from the
single-source s to all destinations in G. In particular, the algorithm should return true if T is a shortest path tree and false,
otherwise. Notice that your algorithm should be more efficient than the Bellman-Ford algorithm which runs in O(VE).
A
E
5
18
6
8
(a) Graph G
12
F
3
B
A
8
E
D
6
(b) Tree T₁
12
F
B
A
8
E
5
18
6
(c) Tree T₂
F
B
An example is given in the figure above. Assume that for the graph G we would like to test two trees rooted at A. The
first tree, Ti is a shortest path tree. Your algorithm should return true when running on G, T₁. On the other hand, the tree
T2 is not a shortest path tree and your algorithm should return false.
Transcribed Image Text:= Question 1 (SPTree Verification You are given a directed weighted graph G (V, E, W), a vertex s E V and a tree T such that each vertex vi E V maps to a node in T. The root of T is s. For each node n in T we define the predecessor n. as its parent in the tree. By definition, s. =Nil for the root node s. For any other node n₁.π = n2, there must be a direct edge (n2, n₁) EE. You need to develop an algorithm that tests whether T is a shortest-path tree from the single-source s to all destinations in G. In particular, the algorithm should return true if T is a shortest path tree and false, otherwise. Notice that your algorithm should be more efficient than the Bellman-Ford algorithm which runs in O(VE). A E 5 18 6 8 (a) Graph G 12 F 3 B A 8 E D 6 (b) Tree T₁ 12 F B A 8 E 5 18 6 (c) Tree T₂ F B An example is given in the figure above. Assume that for the graph G we would like to test two trees rooted at A. The first tree, Ti is a shortest path tree. Your algorithm should return true when running on G, T₁. On the other hand, the tree T2 is not a shortest path tree and your algorithm should return false.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Recommended textbooks for you
Linear Algebra: A Modern Introduction
Linear Algebra: A Modern Introduction
Algebra
ISBN:
9781285463247
Author:
David Poole
Publisher:
Cengage Learning