IAE Academy

GATE 2022 CS Q.58: solution and answer

GATE 2022 · CSQ.58 · 2 marks · NAT

Let be a directed graph, where is the set of vertices and is the set of directed edges, as defined by the following adjacency matrix .

indicates a directed edge from node to node . A directed spanning tree of , rooted at , is defined as a subgraph of such that the undirected version of is a tree, and contains a directed path from to every other vertex in . The number of such directed spanning trees rooted at vertex is ______.

See the question in the paper

Answer and solution

ANSWER

The number of directed spanning trees rooted at vertex 5 is 24.

Official answer: 24Source: Official answer key, GATE 2022 CS (IIT Kharagpur)

  1. Read the matrix: exactly when . So there is an edge for every pair with , plus a self-loop at every vertex. A self-loop can never lie in a tree, so ignore the loops.

  2. Edges therefore go only from a larger-numbered vertex to a smaller one. Vertex has incoming edges exactly from the vertices with . Vertex has no incoming edge at all.

  3. A spanning tree on vertices has exactly edges. Each vertex must be reached by a directed path from , so the last edge of that path enters . That gives each of the non-root vertices at least one incoming tree edge. With only edges in total, each non-root vertex has exactly one incoming tree edge and the root has none.

  4. Conversely, pick any one parent for each . This gives edges. Starting at any and repeatedly moving to its parent, the label strictly increases, so no cycle can form and the walk must stop at a vertex with no parent, which is . Reversing the walk gives a directed path from to . The graph is therefore connected with edges on vertices, so its undirected version is a tree. Every such choice is a valid directed spanning tree rooted at .

  5. Count the choices of parent. Vertex may choose from , so way. Vertex from , so ways. Vertex from , so ways. Vertex from , so ways.

  6. The choices are independent, so the number of trees is

KEY IDEA

A directed spanning tree rooted at is the same as choosing exactly one incoming edge (a parent) for every non-root vertex, provided the choices create no cycle. Here all edges point from larger to smaller labels, so no cycle is possible and the choices are free.

WATCH OUT FOR

Counting self-loops as available parents, which gives an extra factor for each vertex. Another slip is using the matrix-tree theorem on the undirected version, or forgetting that edges only go from larger to smaller labels, so vertex has possible parents and not .

From the GATE 2022 CS paper. Every question of this paper · Download the full paper · All 14 Graph theory questions, with notes

More Graph theory questions