Graph theory and trees — Unit 5 Notes (Discrete Structures and Theory of Logic)

BCS302 · Unit 5

Graph theory and trees notes — Unit 5

Free unit-wise study notes on graph theory and trees for Discrete Structures and Theory of Logic, Semester 3 of B.Tech — Computer Science & Engineering — key concepts, examples, important questions and a revision checklist for semester exams.

A formal mathematical treatment of Graphs. Covers Isomorphism, Euler and Hamiltonian paths, Planar Graphs, Graph Coloring, and the mathematical properties of Trees.

Notebook — 14 pages

Page 1

Wink Notes

B.Tech CSE — 3rd Semester

Discrete Structures and Theory of Logic

Unit - 5

1. Graph Theory Foundations

A graph G=(V,E)G = (V, E) consists of a non-empty set of vertices VV and a set of edges EE. In discrete mathematics, we focus heavily on the formal properties and classifications of these graphs.

1.1 Basic Terminology

  • Degree of a Vertex deg(v)\deg(v): The number of edges incident to it. A self-loop contributes 2 to the degree.
  • Isolated Vertex: A vertex with degree 0.
  • Pendant Vertex: A vertex with degree 1.
  • Simple Graph: A graph with no self-loops and no parallel (multiple) edges between the same pair of vertices.
  • Multigraph: A graph that allows parallel edges.
  • Pseudograph: A graph that allows both parallel edges and self-loops.

Next — The Handshaking Theorem

1 of 14

Page 2

Wink Notes

B.Tech CSE — 3rd Semester

Discrete Structures and Theory of Logic

Unit - 5

2. The Handshaking Theorem

One of the most fundamental theorems in Graph Theory.

2.1 Statement

In any undirected graph, the sum of the degrees of all vertices is exactly twice the number of edges.

vVdeg(v)=2E\sum_{v \in V} \deg(v) = 2|E|

2.2 Why is it true?

Every edge connects two vertices. When we sum the degrees of all vertices, every edge is counted exactly twice (once at each of its endpoints).

2.3 Important Corollary

In any graph, the number of vertices with an odd degree must be even. (If there were an odd number of odd-degree vertices, the sum of all degrees would be odd, violating the Handshaking Theorem).

Next — Special Types of Graphs

2 of 14

Page 3

Wink Notes

B.Tech CSE — 3rd Semester

Discrete Structures and Theory of Logic

Unit - 5

3. Special Types of Graphs

3.1 Complete Graph (KnK_n)

A simple graph where every pair of distinct vertices is connected by a unique edge.
Number of edges in
Kn=n(n1)2K_n = \frac{n(n-1)}{2}.

3.2 Regular Graph

A graph where every vertex has the exact same degree. If every vertex has degree rr, it is called an rr-regular graph. (Note: A complete graph KnK_n is an (n1)(n-1)-regular graph).

3.3 Bipartite Graph

A graph whose vertices can be divided into two disjoint sets UU and VV such that every edge connects a vertex in UU to one in VV. There are no edges within UU or within VV.

3.4 Complete Bipartite Graph (Km,nK_{m,n})

A bipartite graph where every vertex in set UU (size mm) is connected to every vertex in set VV (size nn).
Number of edges =
m×nm \times n.

Next — Graph Isomorphism

3 of 14

Page 4

Wink Notes

B.Tech CSE — 3rd Semester

Discrete Structures and Theory of Logic

Unit - 5

4. Graph Isomorphism

Two graphs G1G_1 and G2G_2 are Isomorphic if they contain the exact same number of graph vertices connected in the exact same way, even if they are drawn differently or their vertices have different labels.

4.1 Necessary Conditions

For G1G_1 and G2G_2 to be isomorphic, they MUST have:

  • 1. The same number of vertices.
  • 2. The same number of edges.
  • 3. The same degree sequence (the list of degrees of all vertices, sorted).

However, these conditions are necessary but not sufficient. Two graphs can share all three properties and still not be isomorphic.

4.2 Formal Definition

A bijective function f:V1V2f: V_1 \to V_2 exists such that any two vertices u,vV1u, v \in V_1 are adjacent in G1G_1 if and only if f(u)f(u) and f(v)f(v) are adjacent in G2G_2.

Next — Euler Paths and Circuits

4 of 14

Page 5

Wink Notes

B.Tech CSE — 3rd Semester

Discrete Structures and Theory of Logic

Unit - 5

5. Euler Paths and Circuits

Originated from the famous 'Seven Bridges of Königsberg' problem.

  • Euler Path: A continuous path in a graph that visits every edge exactly once.
  • Euler Circuit: An Euler path that starts and ends at the exact same vertex.

5.1 Euler's Theorems

We can determine if a graph has an Euler circuit or path purely by looking at vertex degrees (without needing to trace it!).

  • Euler Circuit Theorem: A connected multigraph has an Euler circuit if and only if every vertex has an even degree.
  • Euler Path Theorem: A connected multigraph has an Euler path (but not a circuit) if and only if it has exactly two vertices of odd degree. (The path must start at one odd vertex and end at the other).

Next — Hamiltonian Paths and Circuits

5 of 14

Page 6

Wink Notes

B.Tech CSE — 3rd Semester

Discrete Structures and Theory of Logic

Unit - 5

6. Hamiltonian Paths and Circuits

While Eulerian concepts deal with visiting every edge, Hamiltonian concepts deal with visiting every vertex.

  • Hamiltonian Path: A path that visits every vertex exactly once.
  • Hamiltonian Circuit: A cycle that visits every vertex exactly once and returns to the starting vertex.

6.1 The Challenge

Unlike Euler circuits, there is no simple degree-based rule to determine if a graph has a Hamiltonian circuit. Finding one is an NP-Complete problem (the famous Traveling Salesperson Problem is a weighted version of this).

6.2 Sufficient (but not necessary) Theorems

  • Dirac's Theorem: If GG is a simple graph with n3n \ge 3 vertices, and the degree of every vertex is n/2\ge n/2, then GG has a Hamiltonian circuit.
  • Ore's Theorem: If deg(u)+deg(v)n\deg(u) + \deg(v) \ge n for every pair of non-adjacent vertices u,vu, v, then GG has a Hamiltonian circuit.

Next — Planar Graphs

6 of 14

Page 7

Wink Notes

B.Tech CSE — 3rd Semester

Discrete Structures and Theory of Logic

Unit - 5

7. Planar Graphs

A graph is Planar if it can be drawn on a flat 2D plane without any of its edges crossing over one another.

7.1 Regions (Faces)

A planar representation of a graph splits the plane into regions, including one infinite exterior region.

7.2 Euler's Formula for Planar Graphs

For any connected planar graph, the relationship between Vertices (vv), Edges (ee), and Regions/Faces (rr) is strictly fixed:

ve+r=2v - e + r = 2

Example: A cube drawn on a plane has 8 vertices, 12 edges, and 6 faces. 812+6=28 - 12 + 6 = 2.

Next — Kuratowski's Theorem

7 of 14

Page 8

Wink Notes

B.Tech CSE — 3rd Semester

Discrete Structures and Theory of Logic

Unit - 5

8. Determining Planarity

How do we prove a graph is NOT planar? We use inequalities derived from Euler's formula.

  • If a connected planar simple graph has v3v \ge 3, then e3v6e \le 3v - 6.
  • If it has no triangles (bipartite), then e2v4e \le 2v - 4.

Using these, we can mathematically prove that K5K_5 (complete graph with 5 nodes) and K3,3K_{3,3} (complete bipartite graph with 3+3 nodes) are non-planar.

8.1 Kuratowski's Theorem

The ultimate test for planarity. A graph is non-planar if and only if it contains a subgraph that is homeomorphic (equivalent via edge subdivisions) to either K5K_5 or K3,3K_{3,3}.

In simpler terms: K5K_5 and K3,3K_{3,3} are the 'building blocks' of non-planarity. If your graph hides either of them inside it, it cannot be drawn without crossing lines. (Highly relevant in PCB circuit design).

Next — Graph Coloring

8 of 14

Page 9

Wink Notes

B.Tech CSE — 3rd Semester

Discrete Structures and Theory of Logic

Unit - 5

9. Graph Coloring

Graph coloring involves assigning a color to each vertex of a graph such that no two adjacent vertices share the same color.

9.1 Chromatic Number (χ(G)\chi(G))

The Chromatic Number is the minimum number of colors required to color the graph validly.

  • Complete Graph KnK_n: χ=n\chi = n (every vertex connects to every other).
  • Bipartite Graph: χ=2\chi = 2.
  • Cycle Graph CnC_n: χ=2\chi = 2 if nn is even, χ=3\chi = 3 if nn is odd.
  • Tree: χ=2\chi = 2.

9.2 The Four Color Theorem

Any planar graph can be colored using no more than 4 colors. (This implies any geographical map can be colored with 4 colors so no adjacent countries share a color).

Next — Mathematical Properties of Trees

9 of 14

Page 10

Wink Notes

B.Tech CSE — 3rd Semester

Discrete Structures and Theory of Logic

Unit - 5

10. Mathematical Properties of Trees

In discrete math, a Tree is defined as a connected undirected graph with no simple circuits (acyclic).

10.1 Equivalent Definitions

A graph GG with nn vertices is a tree if it satisfies any of the following equivalent properties:

  • It is connected and has exactly n1n - 1 edges.
  • It has no cycles, and has exactly n1n - 1 edges.
  • There is a unique simple path between any two of its vertices.
  • Adding any single edge creates exactly one cycle.
  • Removing any single edge disconnects the graph (every edge is a bridge).

Next — Rooted Trees and $m$-ary Trees

10 of 14

Page 11

Wink Notes

B.Tech CSE — 3rd Semester

Discrete Structures and Theory of Logic

Unit - 5

11. Rooted Trees and $m$-ary Trees

A Rooted Tree is a tree in which one vertex has been designated as the root and every edge is directed away from the root.

11.1 mm-ary Tree

A rooted tree is called an mm-ary tree if every internal vertex has no more than mm children.

  • If m=2m=2, it is a Binary Tree.
  • If every internal vertex has exactly mm children, it is a full mm-ary tree.

11.2 Node Calculations in Full mm-ary Trees

Let nn be total nodes, ii be internal nodes, and ll be leaves. Mathematical relationships include:

  • n=mi+1n = m \cdot i + 1
  • l=(m1)i+1l = (m - 1)i + 1
  • i=(l1)/(m1)i = (l - 1) / (m - 1)

Example: In a full binary tree (m=2m=2), l=i+1l = i + 1. The number of leaves is always exactly one more than the number of internal nodes.

Next — Spanning Trees (Math Context)

11 of 14

Page 12

Wink Notes

B.Tech CSE — 3rd Semester

Discrete Structures and Theory of Logic

Unit - 5

12. Spanning Trees

A Spanning Tree of a connected graph is a subgraph that contains all vertices of the graph and is a tree.

Every connected graph has at least one spanning tree. We form it by removing edges from circuits until no circuits remain, while keeping the graph connected.

12.1 Edges to Remove

If a connected graph has vv vertices and ee edges, the spanning tree will have v1v - 1 edges. Therefore, the number of edges that must be removed to create a spanning tree is:

e(v1)=ev+1e - (v - 1) = e - v + 1

This number is called the Circuit Rank or Cyclomatic Number of the graph.

Next — Cayley's Tree Formula

12 of 14

Page 13

Wink Notes

B.Tech CSE — 3rd Semester

Discrete Structures and Theory of Logic

Unit - 5

13. Cayley's Tree Formula

How many different spanning trees exist for a given graph?

13.1 Cayley's Formula

For a Complete Graph KnK_n (where every node connects to every other node), the number of distinct labeled spanning trees is given by:

nn2n^{n-2}

Example: For K4K_4 (4 vertices, 6 edges), there are 442=42=164^{4-2} = 4^2 = 16 distinct spanning trees.

13.2 Matrix Tree Theorem (Kirchhoff's Theorem)

For a general graph (not necessarily complete), the number of spanning trees can be found by constructing the Laplacian matrix of the graph and calculating the determinant of any of its cofactors.

Next — Summary & Review Checklist

13 of 14

Page 14

Wink Notes

B.Tech CSE — 3rd Semester

Discrete Structures and Theory of Logic

Unit - 5

14. Summary & Review Checklist

This concludes Discrete Structures and Theory of Logic.

14.1 University Exam Checklist

  • Use the Handshaking Theorem to prove statements about vertex degrees.
  • Determine if two given graphs are isomorphic by checking degrees and adjacencies.
  • Identify whether a graph contains an Euler path/circuit based on odd/even vertex degrees.
  • Apply Euler's formula (ve+r=2v - e + r = 2) to planar graphs.
  • Calculate the Chromatic number of given standard graphs.
  • Use the tree formulas (n=mi+1n = mi + 1) to find the number of leaves or internal nodes.

14.2 Computer Science Integrations

  • Graph Coloring: Used in compiler design for Register Allocation. Variables that are live at the same time are adjacent vertices; the chromatic number dictates the minimum hardware registers needed.
  • Euler Circuits: Used in DNA sequencing and bioinformatics.
  • Planarity: Used in VLSI (chip) design to avoid circuit shorting.

14 of 14

Continue in this subject