Graph 1
Graph 1
• What is a graph?
A graph G = (V, E) is a pair of sets (both of which will be finite sets for this course). The first set is
V called the set of vertices or set of nodes. The second set E is called the set of edges or set of links.
Elements of E are unordered pairs (subsets of size 2) of distinct vertices.
Example: Say V = {1, 2, 3, 4}. Say E = {(1, 2), (2, 3), (1, 4), (3, 4), (2, 4)}. Then G = (V, E) is
one graph on 4 vertices and 5 edges.
Remark: Although every element of E is a subset itself, instead of using curly braces we use
parenthesis. This is just convention, and in my mind it distinguishes an edge from an arbitrary
pair of vertices. Some textbooks (especially ones on graph theory) use curly braces for edges.
Pictorial Representation. Almost everyone I know thinks about graphs pictorially. The vertices of
the graph are drawn as points/circles on the plane. The edges are drawn as straight (or sometime
non-straight) lines. For example, the graph above is pictorially represented as follows
1 4
2 3
Remark: The pictures are good for intuition. The final proof however, as you know, should never
be using a picture. It should be formal, and I’ll try to give proofs with only words. A picture is
okay for illustration, not demonstration.
• Why graphs? Graphs are amazing objects to argue about things which have pairwise relations
between them. Perhaps the graph which affects all our lives is the Web Graph. The nodes are all
web-pages in the world; there is an edge between two web-pages if they link each other. Then there is
the Social/Facebook Graph. The nodes are individuals; there is an edge between two nodes if they
are friends.
But graphs come up every where. Molecules are often modeled as graphs in computational biology.
Agents and Items they wish to purchase are often modeled as graphs in economics. Processors and
Jobs are modeled as graphs in scheduling. The list is endless, and Graph Theory is an extremely
important object of study.
1
Lecture notes by Deeparnab Chakrabarty. Last modified : 28th Aug, 2021
These have not gone through scrutiny and may contain errors. If you find any, or have any other comments, please email me at
[email protected]. Highly appreciated!
1
• Notations. There is a lot of notation in graph theory; but they are often picturesque and intuitive. One
of the goals of this module is to actually acquaint you of these. Below we fix a graph G = (V, E).
– Given an edge e = (u, v), the vertices u and v are the endpoints of e. We say e connects u and
v. We say that u and v are incident to e.
– Two vertices u, v ∈ V are adjacent or neighbors if and only if (u, v) is an edge.
– The incident edges on v is denoted using the set ∂G (v). So,
∂G (v) := {(u, v) : (u, v) ∈ E}
We lose the subscript if the graph G is clear from context.
– Given a vertex v, the neighborhood of v is the set of neighbors of v. This is denoted sometimes
as NG (v) or sometimes as ΓG (v). So,
NG (v) := {u : (u, v) ∈ E}
We lose the subscript if the graph G is clear from context.
– The cardinality of NG (v) is called the degree of vertex v. We denote it using degG (v). This
counts the number of neighbors of v. Note that,
degG (v) = |NG (v)| = |∂G (v)|
– A vertex v is isolated if its degree is 0. That is, it has no edges connected to it.
– A graph G = (V, E) is called regular if all degrees are equal, that is, degG (v) = degG (u) for
all u and v.
– Given a graph G = (V, E), we use V (G) to denote V and E(G) to denote E. This notation is
useful when we are talking about multiple graphs.
• Deleting and Inserting Edges and Vertices from a graph.
Fix a graph G = (V, E). Let e = (u, v) be an edge in E. We get a new graph by deleting the edge e
from G. This graph is denoted as G − e or G \ e. V (G \ e) = V and E(G \ e) = E \ e.
G − e := G \ e := (V, E \ e)
Note |V (G \ e)| = |V (G)| but |E(G \ e)| = |E(G)| − 1.
Given a susbet F ⊆ E of edges, we can delete all the edges in F iteratively to get the graph G − F
(this is not a usual notation). In particular, we get the graph G0 defined as G0 = (V (G), E(G) \ F ).
Similarly, we can add/insert edges to G. Let e = (u, v) be a pair of vertices. Then, we get a new
graph by inserting the edge e in G. This graph is denoted as G + e or G ∪ e. Note if e was already
present in E, then G + e = G.
G + e := G ∪ e := (V (G), E(G) ∪ e)
We can also delete a vertex. When we delete a vertex, we delete that vertex from the vertex set and
also all the edges adjacent to v. This new graph is called G − v or G \ v.
G − v := G \ v = (V (G) \ v, E(G) \ ∂(v))
Note that |V (G − v)| = |V (G)| − 1 and |E(G − v)| = |E(G)| − degG (v). Note that |E(G − v)| may
be equal to |E(G)|; this occurs if v was an isolated vertex in G.
2
• Subgraphs and Induced Subgraphs.
A graph H = (W, F ) is a subgraph of a graph G = (V, E) if W ⊆ V and F ⊆ E, and if (W, F ) is a
valid graph. That is, for any edge (u, v) ∈ F , both u and v are in the set W
Given a graph G = (V, E) and a subset W ⊆ V of vertices, the induced subgraph G[W ] = (W, F )
where F ⊆ E and any original edge (u, v) ∈ E with both endpoints u, v ∈ W lies in F .
• The Handshake Lemma. The first proof in graph theory is something you have already seen before
in a UGP.
Proof. We will give “three” proofs of the above theorem. The last two are basically the same, although
they may feel different. The first is based on the combinatorial idea of showing that the LHS and RHS
actually count the same set.
Proof 1. Given the graph G = (V, E), consider the following set
X = {(e, v) : e ∈ E, v ∈ V, v ∈ e}
That is, X is a set of tuples whose first entry is an edge in G, and the second entry is a vertex incident
on that edge.
One way of counting X is using the product rule from left to right. There are |E(G)| choices for the
first index e. Given any such e, there are 2 choices of vertices incident on it. Therefore,
|X| = 2|E(G)|
Next, we count the set X from right to left. Here, we first pick a vertex v. Then, given any v, how
many edges e can go in the first coordinate? We see that all such e’s must be incident on v. The
number is precisely degG (v). We cannot apply the product rule as the degrees could be different
for different vertices. But we just apply the sum rule, vertex-per-vertex. Formally, given any vertex
a ∈ V , we define the set
Proof 2. Next, we see a proof by induction. Induction on graphs is something we need to get used to.
Fast.
3
Let P (m) be the predicate that is true if for all graphs G = (V, E) with |E| = m, the equality (1)
holds. Note that P (m) itself is a predicate logic statement. Also note that the theorem statement is
asking us to prove that ∀m ∈ N ∪ {0} : P (m) is true. We add the {0} because there can be graph with
0 edges (E(G) = ∅). (This kind of predicate should remind you of predicates we defined for proving
correctness of code.)
Base Case: Is P (0) true? We need to show for all graphs G = (V, E) with |E| = 0, (1) holds. If
G has no edges, then the RHS equates to 0. However, no edges also implies degG (v) = 0 for all
v ∈ V (G). Thus, the LHS of (1) is also 0. The base case is established.
Inductive Case: Fix a natural number k ≥ 0. Assume P (k) is true. We need to show P (k + 1) is
true.
Once again, let us spell out what we have assumed and what we need to show. We have assumed that
for all graphs with k edges, the equality (1) is true. We need to show for any graph with k + 1 edges,
the equality (1) holds. To this end, fix a graph G = (V, E) with |E| = k + 1.
Let (u, v) be an arbitrary edge in G. Consider the graph G0 := G − (u, v) (recall the definition of
deletion of an edge). By definition of deletion, we have the following,
(
degG (w) − 1 if w = u or w = v
degG0 (w) = (2)
degG (w) otherwise
Now, note by Induction Hypothesis, since |E(G0 )| = k and P (k) is true, we get
X
degG0 (w) = 2|E(G0 )| (IH)
w∈V (G0 )
Finally, note
|E(G0 )| = |E(G)| − 1 (3)
We established P (k + 1) and thus, by induction, P (m) is true for all m ∈ N ∪ {0}. That is, the
theorem holds.
Proof 3. We will re-cast the above induction proof into a proof which looks at a minimal counter-
example. This is a method which is similar to induction, but may help some picture what is happening
better. Use whatever works. The proof goes as follows.
Suppose, for contradiction’s sake, the theorem is false, and there exist graphs for which (1) is not true.
Among all such counterexample graphs, pick a G with the smallest number of edges.
4
Observe, |E(G)| > 0, since a graph with zero edges does satisfy (1) (this argument is the same as the
base case of the induction proof).
Let (u, v) be any edge in G, and consider G0 := G − (u, v). Since G0 has strictly fewer edges than
in G, we see that (1) must hold for G0 since G was the counterexample with the smallest number of
edges. Thus, we get (IH) is true (the induction hypothesis). The rest of the argument is similar to
one above, and this shows (1) holds for G as well. Which is a contradiction to the fact that G was a
counterexample.
Where the above proof “wins” is that one doesn’t need to define a predicate, etc. But it is the same
induction proof. See more details in the supplementary lecture notes of the induction lectures.