Home /
Expert Answers /
Computer Science /
you-are-given-the-adjacency-list-representation-of-a-directed-acyclic-graph-g-v-e-with-n-vert-pa681
(Solved):
You are given the adjacency-list representation of a directed acyclic graph G = (V, E) with n vert ...
You are given the adjacency-list representation of a directed acyclic graph G = (V, E) with n vertices and m edges. Furthermore, for every vertex v € V with in-degree zero, you are given a number value(v). For every vertex v € V with positive in-degree, we define value(v) = value(u), (u, v) EE ? the sum of the values of all of v's predecessors in the graph. For example, in the graph below, the gray vertices have in-degree zero, so their values deter- mine the values of all other vertices in the graph. 3 3 10 2 3 6 13 5 7 Design a O(n + m)-time algorithm to compute value (v) for all vertices v € V. co 3 ??