9.1 Graph Formalisms, Degree Sequences & the Handshaking Lemma
π‘ Core Intuition: The 3-Second Mental Modelβ
π³ The Everyday Analogy: The Cocktail Party & Highway Bridgesβ
Think of graphs as mathematical blueprints of relationships between entities:
- The Handshaking Principle: Imagine entering a room with guests. When two guests shake hands, one single handshake adds 2 to the total count of handshakes given (1 to Person A's tally, and 1 to Person B's tally).
- If 10 handshakes take place in the room, the sum of all individual handshakes recorded is exactly .
- Because every handshake contributes 2 to the global tally, the sum of all degrees across the universe is always an even number!
- Consequently, the number of guests who shook an odd number of hands must be an even number!
- Simple Graphs vs Multigraphs:
- Simple Graph: At most one direct flight between any two cities, and no flight that takes off and immediately lands at the exact same airport (no self-loops).
- Multigraph: Multiple competing airlines flying between the same pair of cities (parallel edges).
- The Havel-Hakimi Test: A group of people claim: "I have 3 friends, she has 3, he has 3, they have 1." Is that network physically possible, or are they lying? Havel-Hakimi recursively strips the highest degree to test whether a degree sequence can actually form a simple graph!
π» Bridging to Computer Science: Networks, Social Graphs & Compilersβ
In computer systems:
- Computer Networks: Routers are vertices; fiber-optic cables are edges. Degree represents port bandwidth and network resilience.
- Social Networks (LinkedIn / Facebook): Users are vertices; bidirectional friendships form undirected edges; unidirectional follow relationships form directed edges.
- Compiler Register Allocation: Program variables are vertices; interference (overlapping live ranges) forms edges. The graph is colored to assign variables to physical CPU registers.
πTable of Contents
- πΈοΈ Formal Graph Taxonomy & Combinatorial Counting
- π’ Vertex Degrees & The Handshaking Lemma
- ποΈ Standard Graph Families
- π Bipartite Graphs & TurΓ‘n's Bound
- π Graph Complement & Self-Complementary Graphs
- π The Havel-Hakimi Theorem: Is a Sequence Graphical?
- π Step-by-Step Worked Examples
- π― Exam & Interview Pitfall Check
πΈοΈ Formal Graph Taxonomy & Combinatorial Countingβ
A Graph consists of:
- A non-empty set whose elements are called vertices (or nodes).
- A set whose elements are called edges (or links), where each edge is associated with an unordered pair (for undirected graphs) or an ordered pair (for directed graphs) of vertices from .
- Order of : The number of vertices: .
- Size of : The number of edges: .
- Null Graph (): A graph containing vertices and edges ().
- Trivial Graph (): A graph with exactly vertex and edges.
The Spectrum of Graph Topologies
Classifying graphs based on directionality, edge duplication, and self-loops
Simple Graph
Standard Model- Undirected edges.
- NO self-loops (no edge connecting a vertex to itself).
- NO multiple / parallel edges (at most one edge between any pair).
- Maximum possible edges: C(n, 2) = n(n - 1) / 2.
Multigraph
Parallel Channels- Allows multiple edges connecting the exact same pair of vertices.
- Models redundant network links or multi-lane highways.
- Zero self-loops allowed.
Pseudograph
Loops Allowed- Allows both parallel edges AND self-loops (edges from v to v).
- A self-loop contributes 2 to the degree of its incident vertex!
Directed Graph (Digraph)
Asymmetric Flow- Edges are ordered pairs e = (u, v) with a designated direction.
- u is the initial vertex (source); v is the terminal vertex (target).
π’ Combinatorial Counting of Labeled Simple Graphsβ
Let be a set of labeled vertices:
- Total Number of Potential Edges:
- Total Number of Labeled Simple Graphs: Every potential edge can either be present or absent (2 independent binary choices):
- Number of Labeled Simple Graphs with exactly edges: Choosing edges out of the available slots:
π’ Vertex Degrees & The Handshaking Lemmaβ
Let be an undirected graph, and let :
- The degree of vertex (denoted or ) is the number of edges incident with . Each self-loop counts as two incident edges.
- Isolated Vertex: A vertex with degree ().
- Pendant (Leaf) Vertex: A vertex with degree ().
- Minimum and Maximum Degrees:
- For a directed graph:
- In-Degree (): Number of edges terminating at .
- Out-Degree (): Number of edges originating from .
In any undirected graph :
Proof: Every edge has two distinct endpoints ( and ). When summing the degrees of all vertices across the graph, each edge is counted exactly twice: once at vertex and once at vertex . (A self-loop at contributes 2 to , again contributing 2 to the sum). Therefore, the sum of all vertex degrees must equal exactly twice the number of edges.
Directed Graph Analogue:
Average Degree Inequality: The average vertex degree is . Consequently:
In any undirected graph, the number of vertices of odd degree is ALWAYS EVEN!
Proof: Partition the vertex set into two disjoint subsets:
- : The set of vertices with even degree.
- : The set of vertices with odd degree. By the Handshaking Lemma:
Notice that:
- is strictly an even integer.
- is a sum of even numbers, which is strictly even. Rearranging:
The sum of an odd number of odd terms is odd! Therefore, for the sum of odd degrees to be even, there must be an even number of terms in .
ποΈ Standard Graph Familiesβ
Fundamental Families of Simple Graphs
Classical symmetric topologies forming the building blocks of network theory
Complete Graph (Kβ)
All-to-All Mesh- Every pair of distinct vertices is connected by an edge.
- Degree of every vertex: n - 1.
- Total edges: |E| = n(n - 1) / 2 = C(n, 2).
- Hamiltonian cycles: (n - 1)! / 2.
- Spanning trees (Cayley's Formula): n^(n - 2).
Cycle Graph (Cβ)
Closed Ring (n β₯ 3)- A single closed loop with vertices vβ, vβ, ..., vβ.
- Every vertex has degree exactly 2 (2-regular).
- Total edges: |E| = n.
- Bipartite if and only if n is EVEN.
Path Graph (Pβ)
Linear Chain- A single non-branching chain with n vertices.
- Two leaf endpoints of degree 1; n - 2 internal vertices of degree 2.
- Total edges: |E| = n - 1.
- Always bipartite for all n β₯ 1.
Wheel Graph (Wβ)
Hub & Spokes (n β₯ 3)- Formed by adding a central hub vertex to a cycle Cβ.
- Total vertices: n + 1. Total edges: 2n.
- Central hub has degree n; rim vertices have degree 3.
Regular Graphsβ
A graph is -regular if every vertex has the exact same degree :
By the Handshaking Lemma, the number of edges in a -regular graph with vertices is:
Immediate Invariant: For a -regular graph to exist, the product must be an even integer! At least one of or must be even (e.g., a 3-regular graph cannot have 7 vertices because , which is odd).
π Bipartite Graphs & TurΓ‘n's Boundβ
A simple graph is bipartite if its vertex set can be partitioned into two non-empty disjoint sets and () such that every edge in connects a vertex in to a vertex in . No edge connects two vertices within the same partition!
- Complete Bipartite Graph ():
Every vertex in () is connected to every vertex in ().
- Total vertices: .
- Total edges: .
- Degrees: Vertices in have degree ; vertices in have degree .
- Total spanning trees: .
- TurΓ‘n's Maximum Edge Bound for Bipartite Graphs: In any bipartite graph with vertices, the maximum possible number of edges occurs when the partitions are balanced as equally as possible ():
A graph is bipartite if and only if contains NO ODD CYCLES!
Intuition: To traverse a cycle in a bipartite graph, you must alternately step from . To return to your starting partition, you must take an even number of steps. Thus, every cycle in a bipartite graph must have even length!
- : Bipartite (even cycles).
- : NOT Bipartite (contain odd cycles).
- Trees and Forests: Always bipartite (contain zero cycles).
π Graph Complement & Self-Complementary Graphsβ
Let be a simple graph. The complement of , denoted , has the identical vertex set , and two distinct vertices are adjacent in if and only if they are NOT adjacent in :
Fundamental Properties of Graph Complements:β
- Edge Sum Conservation:
- Complement Degree Formula: For every vertex :
- Self-Complementary Graphs: A simple graph is self-complementary if it is isomorphic to its own complement: If is self-complementary, then . Substituting into the conservation formula: Because must be a non-negative integer: (e.g., for , and for are self-complementary).
π The Havel-Hakimi Theorem: Is a Sequence Graphical?β
A non-increasing sequence of non-negative integers is called graphical if there exists a simple graph whose vertex degree sequence is precisely .
The Havel-Hakimi Algorithm for Graphical Sequences
Recursive greedy stripping algorithm to determine if a degree sequence is physically realizable
Parity & Range Pre-Flight Check
Pre-Flight ChecksCheck: (1) Max degree dβ β€ n - 1. (2) Sum of all degrees is EVEN. (3) Number of odd-degree elements is EVEN. If any check fails, IMMEDIATELY NOT GRAPHICAL!
Sort in Descending Order
SortArrange the sequence so dβ β₯ dβ β₯ ... β₯ dβ.
Extract the Leading Degree dβ
Greedy StripRemove the first element dβ. Subtract 1 from each of the next dβ elements in the sequence.
Repeat Until Termination Base Case
Base CaseRe-sort and repeat. If all elements reduce to zeros (0, 0, ..., 0) βΉ GRAPHICAL! If any element becomes negative (-1) βΉ NOT GRAPHICAL!
π Step-by-Step Worked Examplesβ
Example 1: Applying the Havel-Hakimi Algorithmβ
Problem Statement: Determine whether the following degree sequence is graphical (can form a simple graph):
Step-by-Step Solution:
-
Step 1: Pre-Flight Parity Check
- Number of vertices: .
- Max degree is (valid).
- Sum of degrees: (Even! Passes the Handshaking Lemma).
- Odd-degree vertices: (4 odd vertices Even count! Passes).
-
Step 2: Iteration 1 of Havel-Hakimi
- Current sequence (sorted): .
- Remove the leading element .
- Subtract from the next elements:
- Unaltered remaining elements: .
- Resulting sequence: .
- Re-sort in descending order:
-
Step 3: Iteration 2 of Havel-Hakimi
- Remove leading element .
- Subtract from the next elements:
- Unaltered elements: .
- Resulting sequence: .
- Re-sort:
-
Step 4: Iteration 3 of Havel-Hakimi
- Remove leading element . Subtract from next element: .
- Re-sort: .
- Continuing the greedy strip terminates in all zeros .
- Conclusion: The sequence IS GRAPHICAL! A simple graph with this degree sequence exists.
Key Takeaway: Always re-sort the remaining elements in non-increasing order after every subtraction step in Havel-Hakimi!
Example 2: Handshaking Lemma & Bipartite TurΓ‘n Limitsβ
Problem Statement:
- A bipartite graph has 12 vertices. What is the maximum number of edges can have?
- If a simple graph has 10 vertices and is 3-regular, how many edges does it contain? What if it is 3-regular with 11 vertices?
Step-by-Step Solution:
-
Part 1: Maximum Edges in Bipartite Graph ()
- By TurΓ‘n's theorem for bipartite graphs:
- This occurs in the complete bipartite graph with and .
-
Part 2: 3-Regular Graph with 10 Vertices
- By the Handshaking Lemma:
- Since and is even, a 3-regular graph with 10 vertices exists.
-
Part 3: 3-Regular Graph with 11 Vertices
- Sum of degrees: .
- is an ODD integer, which violates the Handshaking Lemma ( must be even).
- Alternatively, it would require 11 vertices of odd degree, violating the Odd-Degree Parity Theorem!
- Conclusion: NO such graph can exist.
Key Takeaway: For a -regular graph to exist, the product must be strictly even, and .
π― Exam & Interview Pitfall Checkβ
Question 1: Can a simple graph with 7 vertices have degree sequence ? Key Focus Points: No! Let us analyze the structural constraints:
- There are 7 vertices in total (). A vertex of degree 6 connects to every single other vertex in the graph (it is a universal neighbor).
- Here, there are three distinct vertices of degree 6 (). Each of these three vertices must connect to every other vertex in the graph.
- Therefore, every remaining vertex in the graph must connect to at least and , meaning every vertex must have degree at least 3!
- The sequence contains vertices of degree 1 and 2, which contradicts the existence of three degree-6 vertices. Thus, it cannot form a simple graph!
Question 2: If a self-complementary graph has vertices, why is possible but or impossible? Key Focus Points: For a graph to be self-complementary ():
- For : (integer, valid since ).
- For : (impossible).
- For : (impossible). Self-complementary graphs can only exist when or .
Trap 1: Forgetting to re-sort after each step in Havel-Hakimi Why it fails: In Havel-Hakimi, after subtracting 1 from the adjacent elements, the resulting numbers may no longer be in descending order. Subtracting from a non-sorted list invalidates the greedy invariant and produces false negatives!
Trap 2: Counting a self-loop as degree 1 Why it fails: A self-loop connects vertex back to itself. Both endpoints of the edge attach to , contributing +2 to the degree of ! Counting it as 1 violates the Handshaking Lemma ().