Skip to main content

GATE CSE 2016Algorithms › Graph AlgorithmsVerified

GATE CSE 2016 PYQ: Consider the following directed graph: The number of different topological orderings of the vertices of the…

Consider the following directed graph:

GATE CSE 2016 Graph Algorithms diagram: Consider the following directed graph: The number of differe

The number of different topological orderings of the vertices of the graph is _____________.

    Answer

    6

    Approach

    Treat the topological orderings as linear extensions of the directed graph's precedence constraints. The graph forces vertex a to precede all others and vertex f to follow all others, reducing the problem to interleaving the two ordered pairs (b < c) and (d < e).

    The graph has two independent precedence chains among the middle vertices, b before c and d before e, with a forced first and f forced last. Their interleavings give 4!/(2!2!) = 6 topological orderings.

    Reviewed by GateIQ Editorial Team: IIT & IISc Alumni.