chapter
    Graph Fundamentals, Trees and Connectivity PYQs for GATE CS

    Solve 8+ Graph Fundamentals, Trees and Connectivity previous year questions for GATE CS with answers and detailed solutions. Free sample questions below.

    Try a question

    Answer it here to see how it works. Nothing is recorded until you sign in.

    Question 1
    2026 Slot Set2 PYQ
    Level 3: Exam Standard
    Consider a complete graph with vertices . Note that multiple spanning trees can be constructed over . Each of these spanning trees is represented as a set of edges. The Jaccard coefficient between any two sets is defined as the ratio of the size of the intersection of the two sets to the size of the union of the two sets.

    Which one of the following options gives the lowest possible value for the Jaccard coefficient between any two spanning trees of ?
    Question 2
    2026 Slot Set1 PYQ
    Level 3: Exam Standard

    Let be an undirected graph, which is a path on 8 vertices. The number of matchings in is ______. (answer in integer)

    Question 3
    2024 Slot Set2 PYQ
    Level 3: Exam Standard

    Let be an undirected connected graph in which every edge has a positive integer weight. Suppose that every spanning tree in has even weight. Which of the following statements is/are TRUE for every such graph ?

    Question 4
    2024 Slot Set1 PYQ
    Level 3: Exam Standard

    The number of spanning trees in a <i>complete</i> graph of 4 vertices labelled A, B, C, and D is __________

    Question 5
    2022 PYQ
    Level 3: Exam Standard

    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 <i>directed spanning tree</i> 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_____________.

    Question 6
    2022 PYQ
    Level 3: Exam Standard

    Consider a simple undirected graph of 10 vertices. If the graph is disconnected, then the maximum number of edges it can have is ____________.

    Question 7
    2021 Slot Set1 PYQ
    Level 3: Exam Standard

    In an undirected connected planar graph , there are eight vertices and five faces. The number of edges in is __________.

    Question 8
    2021 Slot Set1 PYQ
    Level 3: Exam Standard
    Let be an undirected unweighted connected graph. The diameter of is defined as:


    Let be the adjacency matrix of .
    Define graph on the same set of vertices with adjacency matrix , where


    Which one of the following statements is true?
    Free preview ends here

    Login to view the complete previous-year questions and solutions

    Creating an account is free. You get the rest of this chapter, step-by-step solutions, and a study plan built around the topics you are actually weak at.

    Why MastersUp

    Personalised first. High quality throughout.

    Most platforms hand everyone the same content. Here the content moves with your performance, topic by topic.

    Built around you, not around a syllabus PDF

    Every answer you give moves your topic-level intelligence rate. The next question, the next revision card and tomorrow's plan all change with it.

    Revision that hits your weak spots

    We only revise topics you have actually attempted and are still below the safe bar on — never the same chapter on repeat.

    Questions calibrated to the real exam

    Each question carries a measured toughness. You are served a rung above your current level, so practice keeps stretching you.

    Notes written for recall, not for volume

    Full lesson cards for first study, curated short-note cards for the last mile — with derivations, traps and exam patterns marked.

    One place for everything

    Notes, chapter practice, previous-year questions, test series and full-length papers — all feeding one picture of your preparation.

    Honest progress

    No vanity streaks. Progress here means chapters mastered and accuracy that held up on harder questions.

    Unlock the whole course

    Full notes and short notes, the complete question bank with worked solutions, mock tests, full-length papers, and an adaptive plan that rebuilds itself as you improve.

    Graph Fundamentals, Trees and Connectivity PYQs for GATE CS

    Solve 8+ Graph Fundamentals, Trees and Connectivity previous year questions for GATE CS with answers and detailed solutions. Free sample questions below.

    Chapter Roadmap: Graph Fundamentals, Trees and Connectivity

    Chapter Journey

    Graph Fundamentals & Connectivity

    1. Spanning Tree Enumeration

    Counting trees using Cayley’s Formula & Kirchhoff’s Theorem.

    2. Weighted Spanning Trees

    Optimizing tree weight with Kruskal’s & Prim’s Algorithms.

    3. Connectivity & Planarity

    Graph robustness, Euler’s Formula, and edge bounds.

    4. Matchings & Distances

    Pairing vertices, diameter, and graph powers.

    Why start here? Counting structures builds the intuition needed to optimize them and analyze their resilience.

    Hero Concept: What is a Spanning Tree?

    The Spanning Tree

    For a connected undirected graph with , a Spanning Tree is a subgraph that:

    1. Includes all vertices:
    2. Is connected
    3. Is acyclic (No loops)
    Critical Property

    Why Enumerate? Knowing the number of spanning trees, denoted as , tells us how many unique ways we can connect all nodes without loops.

    Graph Fundamentals, Trees and Connectivity: Solved Questions with Step-by-Step Explanations (8 Problems)

    Question 1 · Engineering Mathematics · 2026_Set2 MCQ
    Consider a complete graph with vertices . Note that multiple spanning trees can be constructed over . Each of these spanning trees is represented as a set of edges. The Jaccard coefficient between any two sets is defined as the ratio of the size of the intersection of the two sets to the size of the union of the two sets.

    Which one of the following options gives the lowest possible value for the Jaccard coefficient between any two spanning trees of ?
    1. A.

    2. B.

    3. C.

      0

    4. D.

    Correct Answer:

    C

    Step-by-Step Solution

    Key idea: This is a Jaccard coefficient minimization question on spanning trees of , recognisable because it asks for the lowest possible Jaccard value between two spanning trees.

    Why this method applies: The Jaccard coefficient . To minimize , we minimize the intersection. The question is whether two edge-disjoint spanning trees can exist in .

    Step 1: Each spanning tree of has exactly edges. Two disjoint trees need distinct edges.

    Step 2: has edges. For two disjoint spanning trees to exist, we need:

    Step 3: Since the problem states , the condition is satisfied. Therefore, contains two completely edge-disjoint spanning trees.

    Step 4: When , the Jaccard coefficient is:

    Step 5: Check the options. Option C gives 0, which is achievable.

    Answer: C

    Question 2 · Engineering Mathematics · 2026_Set1 NAT

    Let be an undirected graph, which is a path on 8 vertices. The number of matchings in is ______. (answer in integer)

    Correct Answer:

    34.00

    Step-by-Step Solution

    Insight: The number of matchings in a path graph follows the Fibonacci recurrence .

    Exam route: Base cases . Build the sequence: 3, 5, 8, 13, 21, 34.

    Learning route:

    Step 1: Define as the total number of matchings (including the empty matching) in a path .

    Step 2: Formulate the recurrence by considering the first vertex :

    • Case 1: is unmatched. The remaining vertices form , giving matchings.
    • Case 2: is matched. It must be matched to . The remaining vertices form , giving matchings.
    • Total: .

    Step 3: Establish base cases.

    • (only the empty matching).
    • (empty matching, or the single edge).

    Step 4: Compute up to :

    .

    Question 3 · Engineering Mathematics · 2024_Set2 MSQ

    Let be an undirected connected graph in which every edge has a positive integer weight. Suppose that every spanning tree in has even weight. Which of the following statements is/are TRUE for every such graph ?

    1. A.

      All edges in have even weight

    2. B.

      All edges in have even weight <b>OR</b> all edges in have odd weight

    3. C.

      In each cycle in , all edges in have even weight

    4. D.

      In each cycle in , either all edges in have even weight <b>OR</b> all edges in have odd weight

    Correct Answer:

    ["D"]

    Step-by-Step Solution

    Key idea: This is a spanning tree parity question, recognisable because it asks which structural properties must hold when every spanning tree has even weight.

    Why this method applies: The condition "every spanning tree has even weight" triggers the Parity Invariance Theorem. By the exchange property, swapping edges between two spanning trees preserves parity, which forces all edges within any 2-edge-connected component to share the same parity.

    Step 1: Recall the exchange property. If and are spanning trees and we swap edge for edge in the cycle created, then . Since both trees have even weight, .

    Step 2: Apply to cycles. Every cycle is a 2-edge-connected subgraph. Any two edges in a cycle lie on a common cycle, so they can be swapped via exchange operations. Therefore, all edges in any cycle must share the same parity — either all even or all odd.

    Step 3: Evaluate each option.

    Option A: "All edges even." FALSE. Counter-example: with all edges weight 1 (odd). Every spanning tree has 2 edges, weight (even). Edges are odd, not even.

    Option B: "All edges even OR all edges odd." FALSE. Different 2-edge-connected components can have different parities. Example: two triangles joined by a bridge, one with all-even edges and one with all-odd edges (3 vertices, odd count). All spanning trees still have even total weight.

    Option C: "In each cycle, all edges even." FALSE. Same counter-example: the cycle has all odd edges.

    Option D: "In each cycle, all edges even OR all edges odd." TRUE. This is exactly the Parity Invariance Theorem applied to cycles.

    Answer: D

    Question 4 · Engineering Mathematics · 2024_Set1 NAT

    The number of spanning trees in a <i>complete</i> graph of 4 vertices labelled A, B, C, and D is __________

    Correct Answer:

    16.00

    Step-by-Step Solution

    Key idea: This is a direct Cayley's formula question, recognisable because it asks for the number of spanning trees in a complete graph with labeled vertices.

    Why this method applies: The graph is (complete, 4 labeled vertices). Cayley's formula gives the exact count without needing Kirchhoff's matrix method.

    Step 1: Recall Cayley's formula. For a complete graph with labeled vertices, the number of spanning trees is .

    Step 2: Substitute .

    Step 3: Verify by enumeration logic. has 6 edges. A spanning tree needs 3 edges. The total number of 3-edge subsets is . Of these, 4 form cycles (the four triangles in ), leaving spanning trees. This confirms the result.

    Answer: 16.00

    Question 5 · Engineering Mathematics · 2022 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 <i>directed spanning tree</i> 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_____________.

    Correct Answer:

    24.00

    Step-by-Step Solution

    Insight: The graph is a DAG with edges pointing from higher to lower indices. Each non-root vertex simply chooses one parent from the available higher-indexed vertices.

    Exam route: Vertex 4 has 1 choice (5). Vertex 3 has 2 choices (4,5). Vertex 2 has 3 choices. Vertex 1 has 4 choices. Total = .

    Learning route:

    Step 1: Understand the edge directions. for means edges go from to . This is a Directed Acyclic Graph (DAG) where edges strictly decrease in index.

    Step 2: Define the arborescence condition. A directed spanning tree rooted at 5 requires every other vertex to have exactly one incoming edge from a vertex that is reachable from 5. Since edges only go down, any valid parent choice guarantees reachability from 5.

    Step 3: Count choices for each vertex's incoming edge:

    • Vertex 4: Can only receive from 5. (1 choice)
    • Vertex 3: Can receive from 4 or 5. (2 choices)
    • Vertex 2: Can receive from 3, 4, or 5. (3 choices)
    • Vertex 1: Can receive from 2, 3, 4, or 5. (4 choices)

    Step 4: Multiply the independent choices: .

    Question 6 · Engineering Mathematics · 2022 NAT

    Consider a simple undirected graph of 10 vertices. If the graph is disconnected, then the maximum number of edges it can have is ____________.

    Correct Answer:

    36.00

    Step-by-Step Solution

    Insight: To maximize edges in a disconnected graph, make one component as large as possible () and the other an isolated vertex.

    Exam route: .

    Learning route:

    Step 1: A disconnected graph with vertices must have at least two components. Let their sizes be and .

    Step 2: To maximize edges, both components must be complete graphs. The total edges are .

    Step 3: The function is strictly convex. The sum of convex functions under a fixed sum constraint is maximized at the extreme boundaries.

    Step 4: Set and . The maximum edges are .

    Question 7 · Engineering Mathematics · 2021_Set1 NAT

    In an undirected connected planar graph , there are eight vertices and five faces. The number of edges in is __________.

    Correct Answer:

    11.00

    Step-by-Step Solution

    Insight: Euler's formula for connected planar graphs directly relates vertices, edges, and faces.

    Exam route: .

    Learning route:

    Step 1: Identify the graph properties. The graph is undirected, connected, and planar.

    Step 2: Recall Euler's formula for connected planar graphs: .

    Step 3: Substitute the given values. We have vertices and faces (including the outer face).

    Step 4: Solve for :

    .

    Question 8 · Engineering Mathematics · 2021_Set1 MCQ
    Let be an undirected unweighted connected graph. The diameter of is defined as:


    Let be the adjacency matrix of .
    Define graph on the same set of vertices with adjacency matrix , where


    Which one of the following statements is true?
    1. A.

    2. B.

    3. C.

    4. D.

    Correct Answer:

    A

    Step-by-Step Solution

    Insight: The matrix defines the square of the graph , where edges connect vertices at distance 1 or 2 in .

    Exam route: In , each step covers up to 2 steps of . Thus, . The diameter is , which satisfies .

    Learning route:

    Step 1: Analyze the adjacency matrix . if (distance 1) or (distance 2). This means is exactly the graph square .

    Step 2: Relate distances. A shortest path of length in can be traversed in by taking steps of length 2. The number of steps required is . Thus, .

    Step 3: Relate diameters. The diameter of is the maximum distance in , which is .

    Step 4: Evaluate options. Since , it is strictly true that . Option A is correct.

    More previous year questions (pyqs) in this unit