ð Lecture 40 â Paths and Circuits
ð Overview: This lecture introduces fundamental concepts of graph theory by examining walks, paths, circuits, and their properties. It begins with the classic Königsberg bridges problem and progresses to Euler and Hamiltonian circuits, which are essential for understanding network connectivity and traversal problems in computer science and mathematics.
ðïž Topics Covered
This lecture covers the definitions and distinctions between walks, closed walks, circuits, simple circuits, paths, and simple paths. It introduces the concept of graph connectedness and presents Euler circuits and Euler's theorem relating vertex degrees to circuit existence. The lecture concludes with Hamiltonian circuits and a proposition for identifying them based on subgraph properties.
ð Lecture Summary
PATHS AND CIRCUITS â KONIGSBERG BRIDGES PROBLEM
The lecture begins with the famous Königsberg bridges problem: Is it possible for a person to take a walk around town, starting and ending at the same location and crossing each of the seven bridges exactly once? This is equivalent to asking whether one can trace the graph (starting and ending at the same point) without lifting the pencil from the paper, where vertices A, B, C, D represent land masses and edges represent bridges.
DEFINITIONS:
Let G be a graph and let v and w be vertices in graph G.
1. WALK A walk from v to w is a finite alternating sequence of adjacent vertices and edges of G. A walk has the form vâ eâ vâ eâ ... vâââ eâ vâ where vâ=v, vâ=w, and for all i=1,2...n, váµ¢ââ and váµ¢ are endpoints of eáµ¢. The trivial walk from v to v consists of the single vertex v.
2. CLOSED WALK A closed walk is a walk that starts and ends at the same vertex.
3. CIRCUIT A circuit is a closed walk that does not contain a repeated edge. Thus a circuit is a walk of the form vâ eâ vâ eâ ... vâââ eâ vâ where vâ = vâ and all the eáµ¢'s are distinct.
4. SIMPLE CIRCUIT A simple circuit is a circuit that does not have any other repeated vertex except the first and last. Thus a simple circuit is a walk of the form vâ eâ vâ eâ ... vâââ eâ vâ where all the eáµ¢'s are distinct and all the vⱌ's are distinct except that vâ = vâ.
5. PATH A path from v to w is a walk from v to w that does not contain a repeated edge. Thus a path is a walk of the form v = vâ eâ vâ eâ ... vâââ eâ vâ = w where all the eáµ¢'s are distinct.
6. SIMPLE PATH A simple path from v to w is a path that does not contain a repeated vertex. Thus a simple path is a walk of the form v = vâ eâ vâ eâ ... vâââ eâ vâ = w where all the eáµ¢'s are distinct and all the vⱌ's are also distinct.
ð Definition â Summary Table:
| Type | Repeated Edge | Repeated Vertex | Ends at Same Point |
|---|---|---|---|
| Walk | allowed | allowed | allowed |
| Closed Walk | allowed | allowed | yes |
| Circuit | no | allowed | yes |
| Simple Circuit | no | first and last only | yes |
| Path | no | allowed | allowed |
| Simple Path | no | no | no |
EXERCISE â Determining Walk Types
In the given graph (with vertices vâ through vâ and edges eâ through eââ), determine whether the following walks are paths, simple paths, closed walks, circuits, simple circuits, or just walks.
(a) vâ eâ vâ eâ vâ eâ vâ eâ vâ eâ vâ eâ vâ This starts at vertex vâ, goes to vâ along edge eâ, moves continuously, and ends going from vâ to vâ along eâ. Vertex vâ and edge eâ are repeated twice, and the walk starts and ends at different points. Hence this is just a walk.
(b) vâ vâ vâ vâ vâ vâ Vertex vâ is repeated twice. No edge is repeated, so this is a path.
(c) vâ vâ vâ vâ vâ vâ vâ Vertices vâ and vâ are repeated, and the graph starts and ends at the same point vâ. The edge eâ connecting vâ and vâ is repeated, so this is a closed walk.
(d) vâ vâ vâ vâ vâ vâ vâ Vertex vâ is repeated, and the graph starts and ends at the same vertex vâ. No edge is repeated, hence this is a circuit.
(e) vâ vâ vâ vâ vâ vâ vâ Vertex vâ is repeated and no edge is repeated, so this is a path.
(f) vâ vâ vâ vâ Neither any vertex nor any edge is repeated, so this is a simple path.
CONNECTEDNESS
Let G be a graph. Two vertices v and w of G are connected if, and only if, there is a walk from v to w. The graph G is connected if, and only if, given any two vertices v and w in G, there is a walk from v to w. Symbolically: G is connected â â vertices v, w â V(G), â a walk from v to w.
EULER CIRCUITS
ð Definition â Euler circuit: An Euler circuit for G is a circuit that contains every vertex and every edge of G. That is, an Euler circuit for G is a sequence of adjacent vertices and edges in G that starts and ends at the same vertex, uses every vertex of G at least once, and uses every edge of G exactly once.
ð Theorem: A graph G has an Euler circuit if, and only if, G is connected and every vertex of G has an even degree.
KONIGSBERG BRIDGES PROBLEM â Euler Solution
For the Königsberg bridges graph: deg(A)=3, deg(B)=3, deg(C)=3, and deg(D)=5. Since all vertices have odd degree, there is no possibility of an Euler circuit.
ð Example: Determine whether the following graph has an Euler circuit: Graph with vertices vâ-vâ: deg(vâ)=5 (odd degree), so this graph does not have an Euler circuit.
ð Example: Determine whether the following graph (with vertices a through i) has an Euler circuit: deg(a)=2, deg(b)=4, deg(c)=4, deg(d)=4, deg(e)=2, deg(f)=4, deg(g)=4, deg(h)=4, deg(i)=4 Since every vertex has even degree and the graph is connected, it has an Euler circuit. One such circuit is: a b c d e f g d f i h c g h b i a
EULER PATH
ð Definition â Euler path: Let G be a graph and let v and w be two vertices of G. An Euler path from v to w is a sequence of adjacent edges and vertices that starts at v, ends at w, passes through every vertex of G at least once, and traverses every edge of G exactly once.
ð Corollary: Let G be a graph and let v and w be two vertices of G. There is an Euler path from v to w if, and only if, G is connected, v and w have odd degree, and all other vertices of G have even degree.
HAMILTONIAN CIRCUITS
ð Definition â Hamiltonian circuit: Given a graph G, a Hamiltonian circuit for G is a simple circuit that includes every vertex of G. That is, a Hamiltonian circuit for G is a sequence of adjacent vertices and distinct edges in which every vertex of G appears exactly once.
ð Example: Find Hamiltonian Circuit for a graph with vertices a-g: The Hamiltonian Circuit is: a b d e f c g h a Another Hamiltonian Circuit for the same graph: a b c d e f g h a
ð Proposition: If a graph G has a Hamiltonian circuit then G has a subgraph H with the following properties:
- H contains every vertex of G
- H is connected
- H has the same number of edges as vertices
- Every vertex of H has degree 2
ð Example: Show that the following graph does not have a Hamiltonian circuit: Graph with vertices a-g: deg(c)=5. If we remove 3 edges from vertex c then deg(b)<2, deg(g)<2 or deg(f)<2, deg(d)<2. This means the graph does not satisfy the desired properties, so the graph does not have a Hamiltonian circuit.
ð¡ Why this matters: Euler circuits focus on traversing every edge exactly once, while Hamiltonian circuits focus on visiting every vertex exactly once. These are different problems with different solution criteria, and both have important applications in route planning, network design, and the famous Traveling Salesman Problem.
â Key Takeaways
A walk allows repeated edges and vertices; a circuit is a closed walk with distinct edges; a simple circuit has only the first/last vertex repeated; a path forbids repeated edges; a simple path forbids both repeated edges and vertices. For Euler circuits, a graph must be connected and all vertices must have even degree. For Euler paths between two vertices, those two vertices must have odd degree and all others even. Hamiltonian circuits require visiting every vertex exactly once, and a necessary condition is the existence of a connected subgraph where every vertex has degree 2 with the same number of edges as vertices.
ð§ Quick Revision Questions
- What are the six types of walks defined in this lecture, and what distinguishes a simple path from a path?
- State Euler's theorem for the existence of an Euler circuit in a graph.
- What condition must be satisfied for a graph to have an Euler path between two specific vertices?
- What is the difference between an Euler circuit and a Hamiltonian circuit?
- List the four properties of the subgraph H that must exist if a graph G has a Hamiltonian circuit.
ð Lecture 41 â Matrix Representation of Graphs
ð Overview: This lecture introduces matrix representations of graphs, focusing on adjacency and incidence matrices as algebraic tools for analyzing graph structures. It covers fundamental matrix concepts, operations like multiplication and transposition, and demonstrates how matrices can encode graph properties and count walks of various lengths.
ðïž Topics Covered
This lecture begins with fundamental matrix concepts including definitions, square matrices, transpose, symmetric matrices, and matrix multiplication with worked examples. It then defines the adjacency matrix of undirected graphs, directed graphs (digraphs), and proves a theorem relating powers of the adjacency matrix to the number of walks of a given length. Finally, it introduces the incidence matrix of a simple graph.
ð Lecture Summary
MATRIX
An m à n matrix A over a set S is a rectangular array of elements of S arranged into m rows and n columns. Briefly written as: A = [aᵢⱌ]âââ
ð Definition â Matrix: A rectangular array of elements arranged in rows and columns. The size is given as m à n (rows à columns).
ð Notation: aᵢⱌ refers to the element at the i-th row and j-th column.
ð Example:
A = [4 -2 0 6]
[2 -3 1 9]
[0 7 5 -1]
This is a 3 Ã 4 matrix. aââ = 4, aââ = -2, aââ = 1, etc.
SQUARE MATRIX
A matrix for which the number of rows and columns are equal is called a square matrix. A square matrix of order n à n has a main diagonal consisting of all entries aââ, aââ, aââ, ..., aᵢᵢ, ..., aââ.
ð Definition â Square matrix: A matrix where m = n (same number of rows and columns). The entries aââ, aââ, ..., aââ form the main diagonal.
TRANSPOSE OF A MATRIX
The transpose of a matrix A of size m à n, denoted by Aáµ, is of size n à m, obtained by writing the rows of A, in order, as columns.
ð Definition â Transpose of a matrix: To find Aáµ, write the rows of A as columns.
ð Example: If A = [4 -2 0 6; 2 -3 1 9; 0 7 5 -1] (3Ã4 matrix), then Aáµ = [4 2 0; -2 -3 7; 0 1 5; 6 9 -1] (4Ã3 matrix)
SYMMETRIC MATRIX
A square matrix A = [aᵢⱌ] of size n à n is called symmetric if, and only if, Aᵠ= A, i.e., for all i, j = 1, 2, ..., n, aᵢⱌ = aⱌᵢ.
ð Definition â Symmetric matrix: A square matrix equal to its own transpose.
ð Example:
B = [4 2 0]
[2 -3 1]
[0 1 5]
Since Báµ = B, B is symmetric. Note that A = [1 3; 5 2] is not symmetric because Aáµ = [1 5; 3 2] â A.
MATRIX MULTIPLICATION
Suppose A is an m à p matrix and B is a p à n matrix. Then the product AB is the m à n matrix whose ij-th entry is obtained by multiplying the elements of the i-th row of A by the corresponding elements of the j-th column of B and then adding: cᵢⱌ = aáµ¢âbâⱌ + aáµ¢âbâⱌ + ... + aáµ¢âbâⱌ = Σâââáµ aáµ¢âbâⱌ
ð Definition â Matrix multiplication: For AB to be defined, the number of columns of A must equal the number of rows of B.
ð Example: Find AB where A = [1 3; 2 -1] and B = [2 0 -4; 3 -2 6]. AB = [(1)(2)+(3)(3) (1)(0)+(3)(-2) (1)(-4)+(3)(6); (2)(2)+(-1)(3) (2)(0)+(-1)(-2) (2)(-4)+(-1)(6)] AB = [11 -6 14; 1 2 -14] (2Ã3 matrix). BA is not defined because B has 3 columns and A has 2 rows (3 â 2).
ADJACENCY MATRIX OF A GRAPH
Let G be a graph with ordered vertices vâ, vâ, ..., vâ. The adjacency matrix of G is the matrix A = [aᵢⱌ] over the set of non-negative integers such that aᵢⱌ = the number of edges connecting váµ¢ and vⱌ for all i, j = 1, 2, ..., n.
Alternatively: aᵢⱌ = 1 if {vᵢ, vⱌ} is an edge of G, and 0 otherwise.
ð Definition â Adjacency matrix: A symmetric matrix where entry (i,j) counts the edges between vertices váµ¢ and vⱌ.
ð Example: A graph with vertices vâ, vâ, vâ, vâ where edges include a loop at vâ and parallel edges (multiple edges between two vertices):
A = [0 0 1 1]
[0 2 0 0]
[1 0 0 0]
[1 0 0 0]
Nonzero entries along the main diagonal (aââ = 2) indicate loops. Entries larger than 1 correspond to parallel edges. A is symmetric.
ð Example: Find a graph with adjacency matrix:
A = [0 2 0]
[2 1 0]
[0 0 1]
The graph has 3 vertices: vâ, vâ, vâ. There are two parallel edges between vâ and vâ (aââ = aââ = 2), a loop at vâ (aââ = 1), and a loop at vâ (aââ = 1).
ADJACENCY MATRIX OF A DIRECTED GRAPH
A directed graph (digraph) consists of a set V(G) of vertices and a set D(G) of directed edges, where each edge is associated with an ordered pair (v, w) called its end points, represented by an arrow from v to w.
The adjacency matrix of a digraph with ordered vertices vâ, vâ, ..., vâ is the matrix A = [aᵢⱌ] such that aᵢⱌ = the number of arrows from váµ¢ to vⱌ.
ð Definition â Adjacency matrix of a digraph: Entry (i,j) counts the number of directed edges from váµ¢ to vⱌ.
ð Example: A digraph with vertices vâ, vâ, vâ, vâ:
A = [1 0 1 0]
[0 0 1 0]
[1 0 0 1]
[0 1 0 0]
This shows loops at vâ and vâ, an arrow from vâ to vâ, from vâ to vâ, from vâ to vâ and vâ, and from vâ to vâ.
ð¡ Why this matters: Unlike undirected graphs, the adjacency matrix of a digraph is not necessarily symmetric.
THEOREM: Walks and Powers of the Adjacency Matrix
If G is a graph with vertices vâ, vâ, ..., vâ and A is the adjacency matrix of G, then for each positive integer n, the ij-th entry of Aâ¿ = the number of walks of length n from váµ¢ to vⱌ.
ð Definition â Walk: A sequence of vertices and edges where each edge is incident with the vertices before and after it. Length equals the number of edges.
ð Theorem: (Aâ¿)ᵢⱌ = number of walks of length n from váµ¢ to vⱌ.
ð Problem: Let A = [1 1 2; 1 0 1; 2 1 0] be the adjacency matrix of a graph G with vertices vâ, vâ, vâ. (a) Find the number of walks of length 2 from vâ to vâ. A² = A à A = [1 1 2; 1 0 1; 2 1 0] à [1 1 2; 1 0 1; 2 1 0] = [6 3 3; 3 2 2; 3 2 5] Entry (2,3) = 2. So there are 2 walks of length 2 from vâ to vâ.
(b) Find the number of walks of length 3 from vâ to vâ. A³ = A à A² = [1 1 2; 1 0 1; 2 1 0] à [6 3 3; 3 2 2; 3 2 5] = [15 9 15; 9 5 8; 15 8 8] Entry (1,3) = 15. So there are 15 walks of length 3 from vâ to vâ.
By visual inspection of the graph (edges: vâ-vâ loop, vâ-vâ, vâ-vâ twice, vâ-vâ, vâ-vâ twice? â based on A): The two walks of length 2 from vâ to vâ are: (i) vâ eâ vâ eâ vâ, (ii) vâ eâ vâ eâ vâ.
INCIDENCE MATRIX OF A SIMPLE GRAPH
Let G be a graph with vertices vâ, vâ, ..., vâ and edges eâ, eâ, ..., eâ. The incidence matrix of G is the matrix M = [mᵢⱌ] of size n à m defined by: mᵢⱌ = 1 if the vertex váµ¢ is incident on the edge eⱌ, and 0 otherwise.
ð Definition â Incidence matrix: Rows represent vertices, columns represent edges. Entry is 1 if the vertex is an endpoint of the edge.
ð Example: A graph with vertices vâ, vâ, vâ and edges eâ, eâ, eâ, eâ, eâ :
M = [1 0 1 0 0]
[0 0 0 1 1]
[0 0 1 1 1]
[1 1 0 0 0]
- Multiple edges are represented by columns with identical entries (eâ and eâ ).
- Loops are represented using a column with exactly one entry equal to 1 (eâ is a loop at vâ).
â Key Takeaways
The adjacency matrix is a powerful algebraic representation of graphs, encoding edge connections in a format suitable for computation. For undirected graphs, the adjacency matrix is always symmetric, with diagonal entries indicating loops. The critical theorem states that the (i,j) entry of A⿠gives the exact number of walks of length n from vertex vᵢ to vertex vⱌ, enabling walk counting through matrix multiplication. Directed graphs require asymmetric adjacency matrices where entries count arrows from row vertex to column vertex. The incidence matrix provides an alternative representation where columns correspond to edges and rows to vertices.
ð§ Quick Revision Questions
- What condition must be satisfied for matrix multiplication AB to be defined?
- If A is the adjacency matrix of an undirected graph, what property must A satisfy?
- What does the entry (i,j) of Aâ¿ represent, where A is the adjacency matrix of a graph?
- In the incidence matrix of a simple graph, how are loops and multiple edges represented?
- For a directed graph, how does the adjacency matrix differ from that of an undirected graph?
ð Lecture 42 â Isomorphism of graphs
ð Overview: This lecture introduces the concept of graph isomorphism, which determines when two graphs that look different are actually structurally identical. It covers the formal definition, isomorphic invariants, degree sequences, and provides multiple exercises to practice determining whether pairs of graphs are isomorphic or not.
ðïž Topics Covered
The lecture begins by comparing two graphs with different vertex and edge labelings, then formally defines isomorphic graphs as having one-to-one correspondences between vertices and edges that preserve edge-endpoint relationships. It discusses isomorphism as an equivalence relation (reflexive, symmetric, transitive) and introduces isomorphic invariants â properties that must be preserved for graphs to be isomorphic. The concept of degree sequence is explained, followed by the specific case of isomorphism for simple graphs. The remainder of the lecture consists of several exercises determining if given graph pairs are isomorphic, with detailed reasoning.
ð Lecture Summary
ISOMORPHISM OF GRAPHS
Two graphs that are the same except for the labeling of their vertices are not considered different. If there is a one-to-one correspondence between the vertices of G and Gâ, and also a one-to-one correspondence between the edges of G and Gâ, then the graphs may be isomorphic.
ð Definition â Isomorphic Graphs: Let G and Gâ be graphs with vertex sets V(G) and V(Gâ) and edge sets E(G) and E(Gâ), respectively. G is isomorphic to Gâ if, and only if, there exist one-to-one correspondences g: V(G)âV(Gâ) and h: E(G)âE(Gâ) that preserve the edge-endpoint functions of G and Gâ in the sense that for all v â V(G) and e â E(G): v is an endpoint of e â g(v) is an endpoint of h(e).
ð¡ Why this matters: This definition ensures the two graphs have identical structure; only the names of vertices and edges differ.
EQUIVALENCE RELATION
Graph isomorphism is an equivalence relation on the set of graphs.
- Reflexive: A graph is isomorphic to itself.
- Symmetric: If G is isomorphic to Gâ, then Gâ is isomorphic to G.
- Transitive: If G is isomorphic to Gâ and Gâ is isomorphic to Gââ, then G is isomorphic to Gââ.
ISOMORPHIC INVARIANT
A property P is called an isomorphic invariant if, and only if, given any graphs G and Gâ, if G has property P and Gâ is isomorphic to G, then Gâ has property P.
THEOREM OF ISOMORPHIC INVARIANT
Each of the following properties is an invariant for graph isomorphism, where n, m and k are all non-negative integers, if the graph:
- has n vertices.
- has m edges.
- has a vertex of degree k.
- has m vertices of degree k.
- has a circuit of length k.
- has a simple circuit of length k.
- has m simple circuits of length k.
- is connected.
- has an Euler circuit.
- has a Hamiltonian circuit.
DEGREE SEQUENCE
The degree sequence of a graph is the list of the degrees of its vertices in non-increasing order.
ð Example: Find the degree sequence of the graph with vertices a, b, c, d, e where: Degree of a = 2, Degree of b = 3, Degree of c = 1, Degree of d = 2, Degree of e = 0. Solution: By definition, degrees must be in decreasing (non-increasing) order. Therefore, the degree sequence is: 3, 2, 2, 1, 0.
GRAPH ISOMORPHISM FOR SIMPLE GRAPHS
If G and Gâ are simple graphs (graphs which have no loops or parallel edges), then G is isomorphic to Gâ if, and only if, there exists a one-to-one correspondence g from V(G) to V(Gâ) that preserves the edge-endpoint functions. For all vertices u and v of G: {u, v} is an edge in G â {g(u), g(v)} is an edge in Gâ. Equivalently, u and v are adjacent in G â g(u) and g(v) are adjacent in Gâ.
Note: There is no efficient method for checking whether two graphs are isomorphic. Despite that, there is a simple condition: two graphs are isomorphic if they have the same number of vertices and the same number of edges, and vertices should have the same degree.
EXERCISE 1
Determine whether graph G and Gâ are isomorphic. G has vertices a,b,c,d,e and edges; Gâ has vertices n,m,o,p,q and edges.
Solution: Both graphs have the same number of vertices. But graph G has 7 edges and graph Gâ has only 6 edges. Therefore, the two graphs are not isomorphic.
EXERCISE 2
Determine whether graph G and Gâ are isomorphic.
Solution: Both graphs have 5 vertices and 7 edges. The vertex q of Gâ has degree 5. However, G does not have any vertex of degree 5. Hence, the two graphs are not isomorphic.
EXERCISE 3
Determine whether graph G and Gâ are isomorphic. G has vertices a,b,c,d,e,f; Gâ has vertices u,v,w,x,y,z.
Solution: Both graphs have the same number of vertices and edges, and all vertices have degree 2. However, Gâ is a connected graph but G is not connected (it has two components: eca and bdf). Therefore, the two graphs are non-isomorphic.
EXERCISE 4
Determine whether graph G and Gâ are isomorphic.
Solution: Both graphs have 6 vertices. G has two simple circuits of length 3: abca and defd. Gâ does not have any simple circuit of length 3 (it has a simple circuit uxwv of length 4). Therefore, the two graphs are non-isomorphic.
Note: A simple circuit is a circuit that does not have any other repeated vertex except the first and last.
EXERCISE 5
Determine whether graph G and Gâ are isomorphic. Both have vertices a,b,c,d and e,f,g,h respectively.
Solution: Both graphs have 8 vertices and 12 edges, and are regular graphs (each vertex has degree 3). G has two simple circuits of length 5: abcfea and cdhgfc. Gâ does not have any simple circuit of length 5 (it has simple circuits tyxut, vwxuv of length 4). Therefore, the two graphs are non-isomorphic.
EXERCISE 6 (Proving Isomorphism)
Determine whether graph G and Gâ are isomorphic. G has vertices a,b,c,d,e,f; Gâ has vertices u,v,w,x,y,z.
Solution: All isomorphism invariants seem true. G has four vertices of degree 2 and two vertices of degree 3, same for Gâ. Both have circuits of length 4. A one-to-one correspondence is defined:
- aâŠu, bâŠv, câŠw, dâŠx, eâŠy, fâŠz
The edge-preserving property is verified:
- {a,b}â{u,v}, {b,c}â{v,y}, {c,d}â{y,x}, {d,e}â{x,w}, {e,f}â{w,z}, {a,f}â{u,z}, {c,f}â{y,z}
Thus, the graphs are isomorphic.
Alternative Solution: A different mapping can also be defined: aâŠu, bâŠv, câŠw, dâŠx, eâŠy, fâŠz with the same verification.
EXERCISE 7 (Proving Isomorphism)
Determine whether graph G and Gâ are isomorphic. G has vertices a,b,c,d,e,f,g,h; Gâ has vertices s,t,u,v,w,x,y,z.
Solution: All isomorphism invariants seem true. Define function f: V(G)âV(Gâ) as:
- aâŠs, bâŠt, câŠu, dâŠv, eâŠw, fâŠz, gâŠy, hâŠx
The edge-preserving property is verified:
- {a,b}â{s,t}, {b,c}â{t,u}, {c,d}â{u,v}, {a,d}â{s,v}, {a,f}â{s,z}, {b,g}â{t,y}, {c,h}â{u,x}, {d,e}â{v,w}, {e,f}â{w,z}, {f,g}â{z,y}, {g,h}â{y,x}, {h,e}â{x,w}
Therefore, the graphs are isomorphic.
EXERCISE 8
Find all non-isomorphic simple graphs with three vertices.
Solution: There are four non-isomorphic simple graphs with three vertices.
EXERCISE 9
Find all non-isomorphic simple connected graphs with three vertices.
Solution: There are two non-isomorphic connected simple graphs with three vertices.
EXERCISE 10
Find all non-isomorphic simple connected graphs with four vertices.
Solution: There are six simple connected graphs with four vertices.
â Key Takeaways
The most critical concepts from this lecture are: (1) Two graphs are isomorphic if there exist one-to-one correspondences between their vertices and edges that preserve edge-endpoint relationships, meaning they have identical structure. (2) Isomorphic invariants like number of vertices, number of edges, degree sequence, connectivity, and existence of circuits of specific lengths must all match for graphs to be isomorphic. (3) If any invariant differs, the graphs cannot be isomorphic â this provides a quick way to disprove isomorphism. (4) For simple graphs, isomorphism reduces to a bijection between vertex sets that preserves adjacency. (5) Proving graphs are isomorphic requires explicitly defining a mapping and verifying it preserves all edge-endpoint relationships.
ð§ Quick Revision Questions
- What is the formal definition of graph isomorphism?
- List at least five isomorphic invariants that must be preserved for two graphs to be isomorphic.
- How do you compute the degree sequence of a graph, and why is it useful for checking isomorphism?
- What distinguishes the isomorphism condition for simple graphs versus general graphs?
- If two graphs have the same number of vertices, same number of edges, and same degree sequence, are they necessarily isomorphic? Explain with a counterexample from the lecture.
ð Lecture 43 â Planar Graphs
ð Overview: This lecture introduces planar graphsâgraphs that can be drawn on a flat surface without crossing edgesâand explores their fundamental properties. It also covers graph coloring, the chromatic number, and the famous Four Color Theorem, demonstrating practical applications such as map coloring and chemical storage problems.
ðïž Topics Covered
Planar graphs definition and examples including Kâ and Qâ; Euler's Formula relating faces, edges, and vertices; proofs that Kâ,â and Kâ are non-planar; graph coloring definitions; the Four Color Theorem; application of graph coloring to chemical storage problems.
ð Lecture Summary
PLANAR GRAPHS
A planar graph is a graph that can be drawn in the plane without any edge crossed (crossing means the intersection of lines). Such a drawing is called a plane drawing of the graph. A graph is planar if its crossing number is "0".
ð Example: Kâ â The complete graph on 4 vertices can be drawn with crossed edges, but it can also be redrawn with no crossed edges, so Kâ is planar.
ð¡ Why this matters: Planarity determines which graphs can be represented without overlapping edges, which is essential for circuit design, map drawing, and network visualization.
Note: Complete graphs are planar only for n †4.
ð Example: The 3-cube (Qâ) has 8 vertices and 12 edges. Although the common representation includes many edge crossings, a plane drawing with no crossing is possible.
ð Exercise: A bipartite graph Kâ (with circuit afcebda) can be redrawn so that no edges cross, proving it is planar.
THEOREM: Show that Kâ,â is not planar
Proof: Kâ,â is a complete bipartite graph with vertices partitioned into two sets of three vertices each. When redrawing, after placing edges a-z, c-x, and b-y, the edge ay can be drawn without crossing. However, edge bz cannot be drawn without crossings. Similarly, if ay is drawn inside and bz drawn outside, the same problem occurs. Therefore, Kâ,â is non-planar.
THEOREM: Show that Kâ is non-planar
Proof: Kâ is a complete graph on 5 vertices where every vertex connects to every other vertex. When redrawing Kâ , edges wy and zx still contain lines that cross each other. Therefore, Kâ is non-planar.
FACES AND REGIONS
A plane drawing of a planar graph divides the plane into regions, including an unbounded region, called faces. The unbounded region is called the infinite face.
ð Example: In a graph with 6 faces, 7 vertices, and 10 edges, fâ is the unbounded region or infinite face because fâ is outside of the graph.
ð Example: In a graph with 8 faces, 9 vertices, and 14 edges, fâ is the infinite face.
EULER'S FORMULA
ð Definition â Euler's Formula: Let G be a connected planar simple graph with e edges and v vertices. Let f be the number of faces in a plane drawing of G. Then:
ð Formula: f = e â v + 2
ð Example: Suppose a connected planar simple graph has 30 edges and 20 faces. Using Euler's Formula: 20 = 30 â v + 2 v = 30 â 20 + 2 = 12 Therefore, the graph has 12 vertices.
GRAPH COLORING
Graph coloring addresses problems like map coloring where adjacent regions cannot have the same color. The goal is to determine the least number of colors needed.
ð Example 1: In one map, 4 colors are necessary but 3 colors are not enough. ð Example 2: In another map, 3 colors are necessary but 2 colors are not enough.
HOW TO DRAW A GRAPH FROM A MAP
- Each map in the plane can be represented by a graph.
- Each region is represented by a vertex.
- If regions share a common border, an edge connects the two vertices.
- Two regions that touch at only one point are not adjacent.
DEFINITIONS
ð Definition â Coloring of a simple graph: The assignment of a color to each vertex of the graph so that no two adjacent vertices are assigned the same color.
ð Definition â Chromatic number of a graph: The least (minimum) number of colors needed for a coloring of the graph.
ð Example: For graph G, vertices a, b, and c are adjacent to each other so they receive different colors (red, blue, green). Vertex d is colored red (adjacent to blue and green), e is green (adjacent to blue and red), f is blue (adjacent to red and green), and g is red (adjacent to green and blue). The chromatic number of G is 3.
ð Example: For graph H, using the same process, the chromatic number is 4.
THE FOUR COLOR THEOREM
ð Definition â Four Color Theorem: The chromatic number of a simple planar graph is no greater than four.
APPLICATION OF GRAPH COLORING
ð Example: A chemist needs to store five chemicals a, b, c, d, and e. Some chemicals react violently and must be kept in separate areas. The table shows asterisks (*) for pairs that must be separated.
We draw a graph where vertices correspond to the five chemicals, with two vertices adjacent whenever the corresponding chemicals must be kept apart. The chromatic number of this graph is 4, so four areas are needed for storage.
â Key Takeaways
Euler's Formula (f = e â v + 2) is essential for connecting the number of faces, edges, and vertices in connected planar graphs. Kâ,â and Kâ are the two fundamental non-planar graphs that every student must recognize. The chromatic number of a planar graph never exceeds 4 according to the Four Color Theorem, and graph coloring assigns colors to vertices such that adjacent vertices never share the same color. The practical application of graph coloring extends from map coloring to real-world problems like chemical storage separation.
ð§ Quick Revision Questions
- What is Euler's Formula for a connected planar simple graph, and how many vertices does a graph have if it has 30 edges and 20 faces?
- Why are Kâ,â and Kâ considered non-planar graphs?
- What is the chromatic number of a graph, and what does the Four Color Theorem state about planar graphs?
- How do you draw a graph from a map, and why do regions touching at only one point not count as adjacent?
- In the chemical storage application, how many areas were needed for five chemicals and why?
ð Lecture 44 â Trees
ð Overview: This lecture introduces trees as a fundamental data structure in graph theory and computer science. It defines trees, explores their properties, and covers special types like rooted trees and binary trees, along with their applications in problem-solving and data representation.
ðïž Topics Covered
The lecture covers the definition and application areas of trees, special trees including trivial trees, empty trees, and forests, properties of trees with exercises on non-isomorphic trees, definitions of terminal and internal vertices, rooted trees with level and height concepts, binary trees and full binary trees with theorems, exercises on tree specifications, and representation of algebraic expressions using binary trees.
ð Lecture Summary
TREES
APPLICATION AREAS: Trees are used to solve problems in a wide variety of disciplines. In computer science trees are employed to:
- construct efficient algorithms for locating items in a list.
- construct networks with the least expensive set of telephone lines linking distributed computers.
- construct efficient codes for storing and transmitting data.
- model procedures that are carried out using a sequence of decisions, which are valuable in the study of sorting algorithms.
ð Definition â Tree: A tree is a connected graph that does not contain any non-trivial circuit (i.e., it is circuit-free). A trivial circuit is one that consists of a single vertex.
ð Example: Examples of trees are provided in the lecture text. Examples of non-trees include graphs with a circuit, disconnected graphs, and graphs with a circuit (including loops).
SOME SPECIAL TREES
-
TRIVIAL TREE: A graph that consists of a single vertex is called a trivial tree or degenerate tree.
-
EMPTY TREE: A tree that does not have any vertices or edges is called an empty tree.
-
FOREST: A graph is called a forest if, and only if, it is circuit-free. OR "Any non-connected graph that contains no circuit is called a forest." Hence, it clears that the connected components of a forest are trees.
ð Example: As in both the graphs above, there exists no circuit, so called forest.
PROPERTIES OF TREES
- A tree with n vertices has n - 1 edges (where n ⥠0).
- Any connected graph with n vertices and n - 1 edges is a tree.
- A tree has no non-trivial circuit; but if one new edge (but no new vertex) is added to it, then the resulting graph has exactly one non-trivial circuit.
- A tree is connected, but if any edge is deleted from it, then the resulting graph is not connected.
- Any tree that has more than one vertex has at least two vertices of degree 1.
- A graph is a tree iff there is a unique path between any two of its vertices.
ð Formula: For a tree with n vertices, number of edges = n - 1.
ð Example (EXERCISE): Explain why graphs with the given specification do not exist.
- Tree, twelve vertices, fifteen edges. â Any tree with 12 vertices will have 12 - 1 = 11 edges, not 15.
- Tree, five vertices, total degree 10. â Any tree with 5 vertices will have 5 - 1 = 4 edges. Since total degree = 2(edges) = 2(4) = 8, a tree with 5 vertices would have total degree 8, not 10.
ð Example (EXERCISE): Find all non-isomorphic trees with four vertices. â Any tree with four vertices has 3 edges, total degree = 6. Possible degree combinations: 1, 1, 1, 3 and 1, 1, 2, 2. The corresponding trees are non-isomorphic.
ð Example (EXERCISE): Find all non-isomorphic trees with five vertices. â There are three non-isomorphic trees with five vertices (4 edges). In part (a), tree has 2 vertices of degree â1â and 3 vertices of degree â2â. In part (b), 3 vertices have degree â1â, 1 has degree â2â and 1 vertex has degree â3â. In part (c), possible combinations of degree are 1, 1, 1, 1, 4.
ð Example (EXERCISE): Draw a graph with six vertices, five edges that is not a tree. â Two such graphs are shown. First graph is not a tree because it is not connected and also there exists a circuit. Similarly, second graph is not a tree.
DEFINITION
ð Definition â Terminal vertex or leaf: A vertex of degree 1 in a tree. ð Definition â Internal vertex or branch vertex: A vertex of degree greater than 1 in a tree.
ð Example: The terminal vertices of the tree are vâ, vâ, vâ , vâ and vâ and internal vertices are vâ, vâ, vâ.
ROOTED TREE
ð Definition â Rooted tree: A rooted tree is a tree in which one vertex is distinguished from the others and is called the root. ð Definition â Level: The level of a vertex is the number of edges along the unique path between it and the root. ð Definition â Height: The height of a rooted tree is the maximum level to any vertex of the tree. ð Definition â Children: The children of any internal vertex v are all those vertices that are adjacent to v and are one level farther away from the root than v. ð Definition â Parent: If w is a child of v, then v is called the parent of w. ð Definition â Siblings: Two vertices that are both children of the same parent are called siblings. ð Definition â Ancestor and descendant: Given vertices v and w, if v lies on the unique path between w and the root, then v is an ancestor of w and w is a descendant of v.
ð Example: Consider the rooted tree shown with root vâ. a. What is the level of vâ? â 3 (covers 3 edges). b. What is the level of vâ? â 0 (no edge from vâ to vâ). c. What is the height of this tree? â 5 (maximum level). d. What are the children of vââ? â vââ, vââ and vââ. e. What are the siblings of vâ? â vâ, vâ, and vâ . f. What are the descendants of vââ? â vââ, vââ, and vââ.
BINARY TREE
ð Definition â Binary tree: A binary tree is a rooted tree in which every internal vertex has at most two children. Every child in a binary tree is designated either a left child or a right child (but not both). ð Definition â Full binary tree: A full binary tree is a binary tree in which each internal vertex has exactly two children.
ð Example: In the example, v is the left child of u.
THEOREMS:
- If k is a positive integer and T is a full binary tree with k internal vertices, then T has a total of 2k + 1 vertices and has k + 1 terminal vertices.
- If T is a binary tree that has t terminal vertices and height h, then t †2ʰ. Equivalently, logâ t †h.
ð¡ Why this matters: The maximum number of terminal vertices of a binary tree of height h is 2ʰ.
ð Formula: Full binary tree: total vertices = 2k + 1, terminal vertices = k + 1. Binary tree: t †2ʰ.
ð Example (EXERCISE): Explain why graphs with the given specification do not exist.
- full binary tree, nine vertices, five internal vertices. â Any full binary tree with five internal vertices has six terminal vertices, for a total of eleven vertices (2(5)+1=11), not nine. OR total vertices = 2k+1 = 9 â k=4, but given internal vertices = 5, which is a contradiction.
- binary tree, height 4, eighteen terminal vertices. â Any binary tree of height 4 has at most 2⎠= 16 terminal vertices. Hence, no such tree exists.
ð Example (EXERCISE): Draw a full binary tree with seven vertices. â Total vertices = 2k + 1 = 7 â k = 3 internal vertices, k+1 = 4 terminal vertices. A full binary tree with seven vertices is shown with root a and children b, c, etc.
ð Example (EXERCISE): Draw a binary tree with height 3 and having seven terminal vertices. â Height = h = 3. Any binary tree with height 3 has at most 2³ = 8 terminal vertices. With 7 terminal vertices and k = 6 internal vertices, a binary tree exists.
REPRESENTATION OF ALGEBRAIC EXPRESSIONS BY BINARY TREES
Binary trees are specially used in computer science to represent algebraic expression with arbitrary nesting of balanced parentheses.
ð Example: Binary tree for a/b â The operator (/) is the root and a and b are the left and right children.
ð Example: Binary tree for a/(c+d) â The operator (/) is the root. The terminal vertices are variables (here a, c and d), and the internal vertices are arithmetic operators (+ and /).
ð Example (EXERCISE): Draw a binary tree to represent the expression a/(b-c·d). â The internal vertices are arithmetic operators, the terminal vertices are variables, and the operator at each vertex acts on its left and right subtrees in left-right order.
â Key Takeaways
Trees are fundamental connected, circuit-free graphs where a tree with n vertices always has exactly n-1 edges, and any tree with more than one vertex must have at least two vertices of degree 1 (leaves). Rooted trees introduce hierarchical structure with root, levels, and height, while binary trees restrict internal vertices to at most two children, and full binary trees require exactly two children per internal vertex. Key formulas include the full binary tree vertex count (2k+1 total, k+1 terminal) and the binary tree terminal vertex bound (t †2ʰ). These concepts are directly applied to verify tree properties, draw non-isomorphic trees, and represent algebraic expressions.
ð§ Quick Revision Questions
- What is a tree in graph theory, and what are its two defining properties?
- How many edges does a tree with n vertices have, and why?
- What is the difference between a terminal vertex (leaf) and an internal vertex in a tree?
- In a binary tree of height 3, what is the maximum number of terminal vertices, and what theorem gives this bound?
- How would you represent the expression (a + b) / (c - d) as a binary tree?
ð Lecture 45 â Spanning Trees
ð Overview: This lecture introduces the concept of spanning trees in graph theory, explaining how to find them from connected graphs and their practical applications in network design. It covers Kirchhoff's Matrix-Tree Theorem for counting spanning trees and presents both Kruskal's and Prim's algorithms for finding minimal spanning trees in weighted graphs.
ðïž Topics Covered
The lecture covers spanning trees definition and properties, methods for finding spanning trees by edge deletion from cycles, complete enumeration of all spanning trees for small graphs, Kirchhoff's Matrix-Tree Theorem for counting spanning trees, weighted graphs and minimal spanning trees, Kruskal's algorithm for building minimal spanning trees, and Prim's algorithm with comparison of minimal spanning trees.
ð Lecture Summary
SPANNING TREES
A spanning tree is needed when developing a system of roads between six major cities, where economic reasons require constructing the least possible number of roads while still connecting all cities. The subgraph representing these roads must be connected and circuit-free.
ð Definition â Spanning Tree: A spanning tree for a graph G is a subgraph of G that contains every vertex of G and is a tree.
REMARKS:
- Every connected graph has a spanning tree.
- A graph may have more than one spanning trees.
- Any two spanning trees for a graph have the same number of edges.
- If a graph is a tree, then its only spanning tree is itself.
EXERCISE: Find a spanning tree for a graph with vertices a, b, c, d, e, f and 9 edges.
SOLUTION: The graph has 6 vertices and 9 edges, so we must delete 9 - 6 + 1 = 4 edges (as a tree of n vertices has n-1 edges). We delete one edge in each cycle:
- Delete af
- Delete fe
- Delete be
- Delete ed
The resulting spanning tree connects a-b, b-c, c-d, d-e, e-f, but there is no path from a to e, a to d, or a to c.
EXERCISE: Find all spanning trees of the graph with vertices vâ, vâ, vâ, vâ.
SOLUTION: The graph has n = 4 vertices and e = 5 edges. We must delete e - v + 1 = 5 - 4 + 1 = 2 edges from cycles to obtain a spanning tree.
Eight spanning trees are found by deleting different pairs of edges:
- Delete vâvâ & vâvâ
- Delete vâvâ & vâvâ
- Delete vâvâ & vâvâ
- Delete vâvâ & vâvâ
- Delete vâvâ & vâvâ
- Delete vâvâ & vâvâ
- Delete vâvâ & vâvâ
- Delete vâvâ & vâvâ
EXERCISE: Find a spanning tree for (a) kâ,â (b) kâ
SOLUTION (a): kâ,â is a complete bipartite graph on (1,5) vertices. The graph itself is a tree (six vertices and five edges), so it is its own spanning tree.
SOLUTION (b): kâ is a complete graph on four vertices. With n = 4 vertices and e = 6 edges, we must remove e - v + 1 = 6 - 4 + 1 = 3 edges. Removing edges ab, bd, and cd yields a spanning tree.
KIRCHHOFF'S THEOREM OR MATRIX-TREE THEOREM
ð Definition â Kirchhoff's Theorem: Let M be the matrix obtained from the adjacency matrix of a connected graph G by changing all 1's to -1's and replacing each diagonal 0 by the degree of the corresponding vertex. Then the number of spanning trees of G is equal to the value of any cofactor of M.
EXAMPLE: Find the number of spanning trees of the graph with vertices a, b, c, d.
Adjacency matrix A(G):
a: [0, 1, 0, 1]
b: [1, 0, 1, 1]
c: [0, 1, 0, 1]
d: [1, 1, 1, 0]
Matrix M (from Kirchhoff's theorem):
M = [ 2 -1 0 -1 ]
[-1 3 -1 -1 ]
[ 0 -1 2 -1 ]
[-1 -1 -1 3 ]
ð Formula: Cofactor of element at (1,1)
| 3 -1 -1 |
| -1 2 -1 |
| -1 -1 3 |
ð Example computation: = 3(6-1) + (-1)(-3-1) + (-1)(1+2) = 15 - 4 - 3 = 8 spanning trees
EXERCISE: How many non-isomorphic spanning trees does a given simple graph have?
SOLUTION: There are eight spanning trees numbered 1-8. Trees 1 and 6 are isomorphic, and trees 2, 3, 4, 5, 7, 8 are isomorphic. Hence there are only two non-isomorphic spanning trees.
EXERCISE: An oil company wants to build pipelines between six storage facilities to move oil between any two facilities, constructing as few pipelines as possible.
SOLUTION: Find a set of edges that forms a connected graph containing all vertices with no cycles â a tree containing all vertices. This allows oil to go from any storage facility to any other without unnecessary building costs.
WEIGHTED GRAPHS AND MINIMAL SPANNING TREES
ð Definition â Weighted Graph: A graph for which each edge has an associated real number weight. The sum of the weights of all edges is the total weight of the graph.
ð Example: A weighted graph with edge weights 2, 6, 3, 2, 3, 1 has total weight = 2 + 6 + 3 + 2 + 3 + 1 = 17
ð Definition â Minimal Spanning Tree: A spanning tree for a weighted graph that has the least possible total weight compared to all other spanning trees of the graph.
If G is a weighted graph and e is an edge, then w(e) denotes the weight of e and w(G) denotes the total weight of G.
EXERCISE: Find three spanning trees of a weighted graph and indicate the minimal one.
Tâ: w(Tâ) = 14 Tâ: w(Tâ) = 11 â Minimal spanning tree Tâ: w(Tâ) = 15
KRUSKAL'S ALGORITHM
Input: G [a weighted graph with n vertices]
Algorithm:
- Initialize T (the minimal spanning tree of G) to have all vertices of G and no edges.
- Let E be the set of all edges of G and let m = 0.
- While (m < n - 1): 3a. Find an edge e in E of least weight. 3b. Delete e from E. 3c. If addition of e to T does not produce a circuit, then add e to T and set m = m + 1 end while Output: T
EXERCISE: Use Kruskal's algorithm to find a minimal spanning tree.
SOLUTION: Order of adding edges:
- {a, b}
- {e, f}
- {e, d}
- {c, d}
- {g, f}
- {b, c}
PRIM'S ALGORITHM
Input: G [a weighted graph with n vertices]
Algorithm Body:
- Pick a vertex v of G and let T be the graph with one vertex, v, and no edges.
- Let V be the set of all vertices of G except v.
- For i = 1 to n - 1: 3a. Find an edge e of G such that: (1) e connects T to one of the vertices in V, and (2) e has the least weight of all edges connecting T to a vertex in V. 3b. Let w be the endpoint of e that is in V. 3c. Add e and w to T, delete w from V. next i Output: T
EXERCISE: Use Prim's algorithm starting with vertex a to find a minimal spanning tree.
SOLUTION: Order of adding edges:
- {a, b}
- {b, c}
- {c, d}
- {d, e}
- {e, f}
- {f, g}
EXERCISE: Find all minimal spanning trees using (a) Kruskal's algorithm (b) Prim's algorithm starting with vertex a.
SOLUTION (a) â Kruskal's algorithm: Edges can be added in one of two orders:
- {c, d}, {c, e}, {c, b}, {d, a}
- {c, d}, {d, e}, {c, b}, {d, a} Thus there are two distinct minimal spanning trees.
SOLUTION (b) â Prim's algorithm starting at a: Edges can be added in one of two orders:
- {a, d}, {d, c}, {c, e}, {c, b}
- {a, d}, {d, c}, {d, e}, {c, b} Thus there are two distinct minimal spanning trees.
ð¡ Why this matters: Both Kruskal's and Prim's algorithms can produce the same set of minimal spanning trees, but the order of edge selection differs. A weighted graph may have multiple minimal spanning trees with the same total weight.