Welcome to the second module of your GATE preparation. Having built a strong foundation in logic, sets, and combinatorics in Module 1, we now venture into one of the most important and visually intuitive areas of discrete mathematics: Graph Theory. Graphs are mathematical structures used to model pairwise relations between objects, and they appear everywhere in computer science—from network routing and database dependencies to the control flow of a program.
In this first lesson on graphs, our objective is to master the absolute fundamentals. We will learn how to describe graphs, identify their key properties like degree sequences and bipartiteness, and apply the foundational Handshaking Lemma. These concepts are not just theoretical; they are the basis for a significant number of GATE questions and are prerequisites for the advanced graph algorithms we will study later.
What is a Graph? Basic Terminology
At its heart, a graph is a simple concept. It's a way to represent connections between things. Formally, a graph is defined as a pair , where:
- is a finite set of vertices (or nodes).
- is a set of edges (or arcs), where each edge connects a pair of vertices.
Think of a computer network: the computers and routers are the vertices, and the physical or logical connections between them are the edges.
Let's establish a clear vocabulary, which is critical for understanding problems accurately.
- Undirected vs. Directed Graphs: If the edges have no direction (e.g., a friendship on Facebook), the graph is undirected. The edge is the same as . If the edges have a direction (e.g., following someone on Twitter), the graph is directed. The edge is an arrow from to . Unless specified, GATE problems usually refer to undirected graphs.
- Adjacency and Incidence: If an edge exists between vertices and , they are adjacent. The edge is said to be incident to both and .
- Degree of a Vertex:
- In an undirected graph, the degree of a vertex , denoted , is the number of edges incident to it.
- In a directed graph, we distinguish between in-degree (number of incoming edges) and out-degree (number of outgoing edges).
- Simple Graph: A graph with no self-loops (an edge from a vertex to itself) and no multiple edges between the same pair of vertices. This is the default assumption for most GATE problems.
- Complete Graph (): A simple undirected graph with vertices where every pair of distinct vertices is adjacent. has edges. For example, is a triangle.
The Handshaking Lemma and Degree Sequences
A degree sequence of a graph is the list of its vertex degrees, typically written in non-increasing order. For example, for a square (), the degree of every vertex is 2, so the degree sequence is (2, 2, 2, 2).
There's a fundamental relationship between the degrees of a graph and its number of edges. This is known as the Handshaking Lemma.
Handshaking Theorem in Graph Theory | Imp for UGC NET and GATE
This concise video from Gate Smashers introduces the Handshaking Theorem, explains its formula, and demonstrates its direct applications, including a very important corollary.
Please watch the video in its entirety. As you watch, focus on three key points: The Statement: The video begins by stating the theorem: the sum of degrees of all vertices is equal to twice the number of edges. The Intuition: Understand why this is true. The instructor explains that each edge contributes to the degree of exactly two vertices. This is the core logic behind the theorem. The Applications: Pay close attention to the examples, especially the proof that the number of vertices with an odd degree must be even. This is a classic GATE question.
As the video explained, the Handshaking Lemma is formally stated as:
This simple formula has a powerful consequence that is frequently tested:
Corollary: In any undirected graph, the number of vertices with an odd degree must be even.
- Proof Sketch: The sum of all degrees, , is an even number. We can split this sum into two parts: the sum of degrees of vertices with even degree () and the sum of degrees of vertices with odd degree ().
Since is a sum of even numbers, it is even. Because the total sum is even, must also be even. A sum of odd numbers can only be even if there is an even number of them. Therefore, there must be an even count of odd-degree vertices.
GATE-Style Check: Can a simple graph have a degree sequence of {3, 3, 3, 2, 1}?
- Count odd-degree vertices: The degrees {3, 3, 3, 1} are odd. There are four such vertices. Since 4 is an even number, the graph passes this necessary condition.
- Check the sum: The sum of degrees is . By the Handshaking Lemma, , so the graph must have edges.
These checks are quick ways to eliminate invalid graph structures in multiple-choice questions.
Bipartite Graphs
Another fundamental property a graph can have is bipartiteness. This concept is crucial for matching algorithms and scheduling problems.
A graph is bipartite if its vertex set can be partitioned into two disjoint sets, say and , such that every edge in the graph connects a vertex in to a vertex in . There are no edges between two vertices in , and no edges between two vertices in .
A key theorem provides a simple test for bipartiteness:
Theorem: A graph is bipartite if and only if it has no odd-length cycles.
How can we test this efficiently? By trying to "2-color" the graph.
13- Bipartite Graph in Discrete Mathematics
This video from KnowledgeGATE by Sanchit Sir provides a clear definition of bipartite graphs and demonstrates the standard 2-coloring algorithm used to identify them.
Please watch the initial part of the video, focusing on these two aspects: Definition and Intuition: The video starts by defining a bipartite graph using the two-set partition (often called bipartition). Understand this core concept. The 2-Coloring Method: The instructor then demonstrates how to check for bipartiteness. Pick a starting vertex, assign it a color (e.g., Red), and then assign the opposite color (e.g., Blue) to all its neighbors. Continue this process. If you ever find two adjacent vertices that must have the same color, the graph is not bipartite. This conflict is the manifestation of an odd-length cycle.
Let's solidify this with two classic examples:
-
Cycle (a square):
- Let the vertices be in order.
- Color Red.
- Its neighbors, and , must be Blue.
- The neighbor of (other than ) is . It must be Red.
- Now check all edges. The edge connects a Red vertex to a Blue one. No conflicts.
- The partition is (Red) and (Blue). Thus, is bipartite.
-
Cycle (a triangle):
- Let the vertices be .
- Color Red.
- Its neighbors, and , must be Blue.
- But and are adjacent! We have an edge connecting two Blue vertices. This is a conflict.
- Therefore, is not bipartite. This is because it is a cycle of odd length (3).
Any graph containing a triangle (like ) cannot be bipartite. Trees, on the other hand, have no cycles at all, so they are always bipartite.
Conclusion
In this lesson, we have laid the groundwork for our study of graph theory. We defined the basic components of graphs and established a vocabulary that will serve us throughout this module and beyond.
Key Takeaways:
- A graph is a set of vertices and edges. Key distinctions include directed vs. undirected and simple vs. multigraph.
- The Handshaking Lemma () provides a fundamental constraint on the structure of any graph.
- A direct result of this lemma is that the number of odd-degree vertices is always even, a quick and useful check for GATE problems.
- A graph is bipartite if it can be 2-colored without conflict, which is equivalent to saying it has no odd-length cycles.
With these fundamental properties in hand, we are now ready to start exploring graphs algorithmically. In the next lesson, we will introduce Depth-First Search (DFS), a powerful traversal technique that allows us to discover the structure of a graph, including its connected components, cut vertices, and cut edges.