Graph Theory for GATE CS: Concepts and Worked Examples

Build graph theory from two fully specified examples. Work through degree counts, connectivity, spanning trees, bipartiteness, planarity, and Euler and Hamilton checks.

KnowledgeGate Team

Exam prep & CS education

Updated 8 Aug 20266 min read

Graph theory questions can look like a collection of unrelated terms: degree, path, tree, planar graph, colouring, Euler, and Hamilton. The difficulty reduces when the same small graph connects those ideas. Two small graphs are enough to settle all of them for GATE CS preparation: a six-vertex graph GG with seven edges, and a six-cycle HH carrying one chord. Every degree, bridge, spanning tree, colouring and face count comes straight off those two edge lists, so keep them beside you.

1. Graph basics: the language every solution needs

A graph is written as G=(V,E)G=(V,E), where VV is its vertex set and EE is its edge set. Its order is n=∣V∣n=|V|, and its size is m=∣E∣m=|E|. Two vertices are adjacent when an edge joins them. A vertex and an edge are incident when that edge touches the vertex. The degree counts incident edge ends. A loop begins and ends at the same vertex, while parallel edges join the same pair more than once.

Our main graph is finite, simple, and undirected:

V={A,B,C,D,E,F},E={AB,AC,BC,BD,CE,DE,EF}.V=\{A,B,C,D,E,F\},\qquad E=\{AB,AC,BC,BD,CE,DE,EF\}.

Thus n=6n=6 and m=7m=7. Its edges are unordered pairs, with no loops or parallel edges. An edge list is compact for calculation, an adjacency list records each vertex's neighbours, and an adjacency matrix gives a square lookup table. Because GG has only seven edges, every claim about it can be settled by reading that list line by line.

2. Degree, edge count, and the complement of a graph

Read each degree directly from the seven edges:

  • AA touches AB,ACAB,AC, so deg⁡(A)=2\deg(A)=2.

  • BB touches AB,BC,BDAB,BC,BD, so deg⁡(B)=3\deg(B)=3.

  • CC touches AC,BC,CEAC,BC,CE, so deg⁡(C)=3\deg(C)=3.

  • DD touches BD,DEBD,DE, so deg⁡(D)=2\deg(D)=2.

  • EE touches CE,DE,EFCE,DE,EF, so deg⁡(E)=3\deg(E)=3.

  • FF touches only EFEF, so deg⁡(F)=1\deg(F)=1.

The degree sum is

2+3+3+2+3+1=14=2m=2×7.2+3+3+2+3+1=14=2m=2\times 7.

This verifies the handshaking lemma. The odd-degree vertices are B,C,E,FB,C,E,F, four in total, which is correctly an even number.

A simple undirected graph on six labelled vertices can contain at most

(62)=6×52=15\binom{6}{2}=\frac{6\times 5}{2}=15

edges. The complement G‾\overline G therefore has 15−7=815-7=8 edges. At AA, the complement-degree rule gives deg⁡G‾(A)=5−deg⁡G(A)=5−2=3\deg_{\overline G}(A)=5-\deg_G(A)=5-2=3. Indeed, AA is not adjacent to D,E,FD,E,F in GG, so those are exactly its three complement neighbours.

Graph G on six vertices A to F, each labelled with its degree, with edge EF marked as a bridge.

3. Walks, trails, paths, cycles, and connectivity

A walk is any sequence of vertices in which each consecutive pair is joined by an edge, and both vertices and edges may repeat. So A−B−C−A−BA-B-C-A-B is a walk in GG, even though it reuses edge ABAB and revisits AA and BB. Trails, paths and cycles are walks with restrictions added.

Check each sequence against repeated edges first, then repeated vertices. A−B−C−E−D−BA-B-C-E-D-B uses the edges AB,BC,CE,ED,DBAB,BC,CE,ED,DB once each, so it is a trail. It is not a path because vertex BB repeats. By contrast, F−E−C−AF-E-C-A is a path because every vertex, and therefore every used edge, is distinct. The sequence A−B−C−AA-B-C-A returns to its starting vertex without repeating another vertex, so it is a cycle.

The graph is connected, but some single removals can disconnect it. Removing EFEF isolates FF, so EFEF is a bridge. Removing vertex EE, together with its incident edges, also isolates FF, so EE is an articulation vertex. However, DEDE is not a bridge. If it is removed, DD can still reach EE along D−B−C−ED-B-C-E. Connectivity must be checked using an alternative route, not by judging how important an edge looks in a drawing.

4. Trees and spanning trees from a connected graph

A tree is connected and acyclic. A tree with nn vertices has n−1n-1 edges, and every pair of its vertices has one unique simple path between them. The edge count alone is not sufficient: a disconnected graph with a cycle can also have n−1n-1 edges. Pair the count with connectivity or acyclicity.

For GG, take

T={AB,AC,BD,CE,EF}.T=\{AB,AC,BD,CE,EF\}.

This subgraph contains all six vertices, has five edges, and is connected. It is therefore a spanning tree. The omitted edges are BCBC and DEDE. Each would close a cycle if restored, so removing them preserves connectivity while eliminating cycles. Edge EFEF cannot be omitted from any spanning tree of GG, because it is the only edge incident on FF and is already a bridge.

5. Bipartiteness, colouring, and planar faces

Now define a second graph HH by

V(H)={1,2,3,4,5,6},E(H)={12,23,34,45,56,61,25}.V(H)=\{1,2,3,4,5,6\},\qquad E(H)=\{12,23,34,45,56,61,25\}.

It is a six-cycle with chord 2525. Use the partition

X={1,3,5},Y={2,4,6}.X=\{1,3,5\},\qquad Y=\{2,4,6\}.

Every listed edge has one endpoint in XX and one in YY, including the chord 2525. Hence HH is bipartite. Colour all vertices in XX blue and all vertices in YY orange to get a proper two-colouring. Its chromatic number is exactly 22: two colours suffice, and one cannot suffice because the graph has edges.

In the planar embedding drawn below, n=6n=6, m=7m=7, and f=3f=3, where the faces are the two bounded regions and the outer face. Euler's planar formula checks the count:

n−m+f=6−7+3=2.n-m+f=6-7+3=2.

This formula concerns vertices, edges, and faces in a connected planar embedding. It is different from an Euler trail or Euler circuit, which asks for a traversal using every edge exactly once.

Graph H as a hexagon with chord 2-5, vertices two-coloured into bipartite parts, and its three planar faces labelled.

6. How GATE CS questions combine graph theory concepts

A problem may ask you to reconstruct an edge count from degrees, decide whether a degree sequence is graphical, identify a bridge or articulation vertex, choose a spanning tree, or test bipartiteness and planarity. Another common reasoning split is between Euler conditions and Hamilton conditions. Treat each as a request for a specific property, then apply only the relevant test.

For GG, the four odd-degree vertices B,C,E,FB,C,E,F mean that the connected graph has neither an Euler circuit nor an Euler trail. A circuit requires zero odd-degree vertices, while a trail requires exactly two. The leaf FF rules out a Hamiltonian cycle, because a vertex on such a cycle needs two cycle edges. One Hamiltonian path does exist, however:

F−E−D−B−A−CF-E-D-B-A-C

The edges FE,ED,DB,BA,ACFE,ED,DB,BA,AC are all in GG, and the sequence visits every vertex exactly once. For the same concepts pushed further, read Graph Theory: Euler and Hamiltonian Paths, Coloring and Connectivity. For the same ideas in question form, work through Graph MCQs: 10 solved questions on representations, BFS, DFS and connectivity.

7. Graph theory traps that cost correct answers

First identify the graph type. A loop contributes two to the degree of its vertex, not one, and formulas for simple graphs may fail on a multigraph. Next, keep walk, trail, and path separate: check repeated edges for a trail, then repeated vertices for a path.

Do not transfer Euler's degree criterion to Hamilton questions. Write two prompts on the page: “uses every edge” for Euler, and “visits every vertex” for Hamilton. Similarly, do not declare a graph a tree merely because it has n−1n-1 edges. Verify that it is connected and acyclic. For Euler's planar formula, count every face, including the unbounded outer face. These short checks prevent a correct calculation from being attached to the wrong definition.

8. Graph theory recall chain and your next practice step

Use this recall chain: identify the graph type, write VV and EE, compute degrees and 2m2m, inspect cycles and cuts, then test the required tree, bipartite, or planar condition. Finally, separate edge-covering Euler questions from vertex-covering Hamilton questions.

If you need full subject sequencing, continue with GATE Guidance by Sanchit Sir. If you have revised the concepts and want timed practice, use the GATE Test Series. KnowledgeGate's practice bank also holds more than 350 graph theory questions, so your next step can be simple: revise one condition, solve a set, and explain every rejected option.