Skip to main content

GATE CSE 2021Algorithms › Graph AlgorithmsVerified

GATE CSE 2021 PYQ: In a directed acyclic graph with a source vertex s \textsf{s} s , the quality-score \textit{quality-score}…

In a directed acyclic graph with a source vertex s\textsf{s}, the quality-score\textit{quality-score} of a directed path is defined to be the product of the weights of the edges on the path. Further, for a vertex vv other than s\textsf{s}, the quality-score of vv is defined to be the maximum among the quality-scores of all the paths from s\textsf{s} to vv. The quality-score of s\textsf{s} is assumed to be 1.

GATE CSE 2021 Graph Algorithms diagram: In a directed acyclic graph with a source vertex s \textsf{s

The sum of the quality-scores of all vertices on the graph shown above is _______

    Answer

    929

    Approach

    Because the graph is a DAG, compute each vertex's quality-score in topological order. For any vertex v ≠ s, its quality-score is the maximum product of edge weights among all paths from s to v; thus $Q(v)=max_{u→v}(Q(u)·w(u,v))$, with Q(s)=1.

    The recurrence over the DAG gives the quality-scores: s=1, c=1, f=9, a=9, d=9, g=81, b=9, e=81, t=729. Their sum is 929.

    Reviewed by GateIQ Editorial Team: IIT & IISc Alumni.