module 4 (3)
module 4 (3)
Graph vertices: a, b, c, d, e, f, g, h
Edges (from the image):Left square with a diagonal:
Vertices: a, b, c, d
Edges: a–b, a–c, b–c, c-d, b–d
•Connecting edge: b-g
•Right square with a diagonal:
•Vertices: e, f, g, h
•Edges: e–f, e–g, f–g, f–h
Find all simple paths from a to h Count how many of these have length Path: a → b → g → f →h
1) a–b–g–f–h 1) a–b–g–f–h → length 4 Count the edges:
2) a–b–g–e–f–h 2) a–b–g–e–f–h → length 5 ✅
1.a–b → 1 edge
3) a–c–b–g–f–h 3) a–c–b–g–f–h → length 5 ✅
4) a–c–b–g–e–f–h → length 6 2.b–g → 1 edge
4) a–c–b–g–e–f–h
5) a–c-d–b–g–f–h 5) a–c-d–b–g–f–h→ length 6 3.g–f → 1 edge
6) a–c-d–b–g–e–f–h 6) a–c-d–b–g–e–f–h→ length 7 4.f–h → 1 edge
Total valid simple paths from a to h: 6 ✅ Paths of length 5: paths 2, 3 ✅ Total edges = 4
Subgraphs, Complements, Isomorphism
a) What types of substructures are present in a graph?
b) Is it possible to draw two graphs that appear distinct but have the same
underlying structure?
What types of substructures are present in a graph?
In graph theory, a substructure refers to a portion or part of a graph. Here are common types:
1) Subgraph:
• A graph formed from a subset of the vertices and edges of another graph.
• Induced subgraph: Formed by taking a subset of the vertices and all edges between them from
the original graph.
• Spanning subgraph: Includes all the vertices of the original graph but only a subset of the edges.
2) Path:
• A sequence of vertices where each adjacent pair is connected by an edge, and no vertex is
repeated (in a simple path).
3) Cycle:
• A path that starts and ends at the same vertex, with no other vertex repeated.
6)Component:
• A maximal connected subgraph. In an undirected graph, a component includes
all nodes connected to each other.
7) Cut:
• A substructure that partitions the graph into two disjoint subsets, often used
in network flow and connectivity studies.
Is it possible to draw two graphs that appear distinct but have
the same underlying structure?
• Yes, absolutely! These are called isomorphic graphs.
incident with vertices in V1. It must have at least one vertex (∅ ∉ V₁ means
a subgraph of G if ∉ ⊆ V1 ⊆ V and E1 ⊆ E, where each edge in E1 is
• Figure provides an undirected graph G and two of its subgraphs, G1 and G2.
• The vertices a, b are isolated in subgraph G1.
• Part (b) of the figure provides a directed graph where vertex w is isolated
in the subgraph G'.
Spanning Subgraph
• Given a (directed or undirected) graph G = (V, E), let G1 = (V1, E1) be a
subgraph of G. If V1 = V, then G1 is called a spanning subgraph of G.
• The subgraphs G3 and G4- shown in part a of Figure below are both
spanning subgraphs of G.
• In part(b) of Figure the directed graphs G" and G"' are two of the 24 = 16
possible spanning subgraphs.
• In part (a) of Figure neither G1 nor G2 is a spanning subgraph of G.
• The directed graph G' in part (b) of Figure is a subgraph, but not a spanning
subgraph, of the directed graph G. A spanning graph (more commonly
called a spanning subgraph) is a subgraph that includes all the vertices of
the original graph, but possibly only some of the edges.
Induced Subgraph
• Let G = (V, E) be a graph (directed or undirected). If ∅∉ U ⊆ V , the
subgraph of G induced by U is the subgraph whose vertex set is U and
which contains all edges (from G) of either the form
a) (x, y), for x, y ∈ U (when G is directed), or
b) {x, y}, for x, y ∈ U (when G is undirected).
• This subgraph is denoted by <U>.
• One possibility for the corresponding edges in graph (b) is {q, w}, {w, z}, {z, y}, {y, r}, and {r,
q}, which also provides a cycle of length 5.
• A second choice is given by the edges in the cycle y r s t u y.
• In addition, starting at vertex a in graph (a), we find a path that will "visit" each vertex
only once – a f h c b g j e d i
• For the graphs to be isomorphic there must be a corresponding path in graph (b) – q w
tuvxsryz
• Are the 2 isomorphic?
• Adjacency of a and d is 2, adjacency of b and f is 3, adjacency of c and e is 4
• Adjacency of u, x, and z is 2, adjacency of v, w, and y is 4
• Hence not isomorphic
• It can also be checked with cycles, circuits and trails.
Problems
Vertex Degree – Euler Trails and circuits
• Let G be an undirected graph or multigraph. For
each vertex v of G, the degree of v, written deg(v),
is the number of edges in G that are incident with
v.
• A loop at a vertex v is considered as two incident
edges for v.
• For the graph in Figure, deg(b) = deg(d) = deg( f) =
deg(g) = 2, deg(c) = 4, deg(e) = 0, and deg(h) = 1.
• For vertex a, deg(a) = 3 because a loop is counted
twice.
• Since h has degree 1, it is called a pendant vertex.
Theorem(Handshaking Property)
• If G = (V, E) is an undirected graph or multigraph, then ∑v∈V deg(v) = 2|E|.
• Proof:
• As we consider each edge {a, b} in graph G, we find that the edge contributes a count of 1 to each of
deg(a), deg(b), and consequently a count of 2 to ∑v∈V deg(v).
• Thus 2|E| accounts for deg(v), for all v ∈ V, and ∑v∈V deg(v) = 2|E|.
• This theorem provides an insight on odd-degree vertices in a graph
• For any undirected graph or multigraph, the number of vertices of odd degree must be even.
• simple graph: A — B — C
• A has degree 1 (odd),
• B has degree 2 (even),
• C has degree 1 (odd)
• So there are 2 vertices (A and C) with odd degrees, which is an even number.
Theorem
Proof:
Let G=(V,E) be an undirected graph, where: V is the set of vertices and
E is the set of edges
Each edge connects two vertices and thus contributes 2 to the total
sum of degrees of all vertices.
So, ∑v∈V deg(v) = 2|E|.
This means the sum of all vertex degrees is an even number because
it's twice the number of edges.
Contd...
• The sum of an odd number of odd numbers is odd.
• But the total sum is even, so the number of odd-degree vertices must be
even.
But the total sum is even, so the number of odd-degree vertices must be even.
• An undirected graph (or multigraph) where each vertex has the same degree
is called a regular graph.
• If deg(v) = k for all vertices v, then the graph is called k-regular.
• Is it possible to have a 4-regular graph with 10 edges?
• From previous theorem 2|E| = 20 = 4|V|, so we have five vertices of degree 4.
• Figure provides two non-
isomorphic examples that satisfy
the requirements.
• If each vertex has degree 4, with
15 edges in the graph, then 2|
E| = 30 = 4|V|, from which it
follows that no such graph is
possible.
Applications
• Multiprocessor Architecture in parallel processing – Grid or Mesh connectivity between processors for
communication during processing and transfer of intermediate results.
• In parallel processing, multiple processors work together to solve a problem faster by dividing the work.
These processors need to communicate with each other, especially to share data or intermediate results.
• Problem – The distances between pairs of processors get longer and longer as the number of processors
increases
• Solution???
As you add more processors:
• The grid grows larger.
• The distance (in number of hops) between far-apart
processors also increases.
• This leads to longer communication times for data
that needs to move across the grid.
• These delays hurt performance and scalability.
Applications
Euler trails and Euler circuits are not directly used as a solution to the mesh/grid
communication delay problem in multiprocessor architectures, but they do have
applications in related areas of computer science, especially where graph traversal and
optimization are involved.
Euler trails and circuits are used in:
• Routing problems – like finding a path that goes over every road (edge) without
repeating.
• Postman Problems – e.g., a postman wants to deliver mail by walking every street once.
• Circuit Design – tracing wires or designing efficient PCB layouts.
• Network Testing – ensuring every link is tested exactly once.
• DNA Sequencing – reconstructing DNA sequences using Eulerian paths.
Hypercube
• A compromise that weighs the number of edges against the distance
between pair of vertices ( processors) is represented in the regular graph –
Hypercube
• In general, for n>=0, Qn+1 is constructed recursively from two copies of Qn
• In Q4 there are 16 vertices
(processors) and the longest
distance between vertices is 4.
V1 ⋂ V2 = ∅.
• Then every vertex of G is in V1 U V2 and
V1' ⋂ V2' = ∅.
• Then every vertex of G' is in V1' U V2' and
•
• Since G has nine vertices, if there is a Hamilton cycle in G it must contain nine edges.
• Start at vertex b and try to build a Hamilton cycle. (Because of the symmetry in the graph, it
doesn't matter whether we go from b to c or to a)
• At c move to, either to f or to i - Using symmetry again, go to f .
• Then delete edge {c, i} from further consideration because it is not possible to return to
vertex c.
• In order to include vertex i in our cycle, we must now go from f to i (to h to g).
• With edges {c, f} and {f, i} in the cycle, cannot have edge {e. f} in the cycle
• But then once reached e, its terminated. Hence there is no Hamilton cycle for the graph.
Hints
• for trying to find a Hamilton cycle in a graph G = (V, E).
1. If G has a Hamilton cycle, then for all v ∈ V, deg(v) >= 2.
2. If a ∈ V and deg(a) = 2, then the two edges incident with vertex a must
appear in every Hamilton cycle for G.
3. If a ∈ V and deg(a) > 2, then in the process of building a Hamilton cycle,
once vertex a is passed through, any unused edges incident with a are
deleted from further consideration.
4. In building a Hamilton cycle for G, a cycle for a subgraph of G cannot be
obtained unless it contains all the vertices of G.
• There exists a Sufficient condition for the existence of a Hamilton Cycle in a
loop-free graph
• Let G = (V, E) be a loop-free undirected graph with |V| = n>= 3.
If deg(x) + deg(y) >= n for all nonadjacent x, y ∈ V, then G contains a
Hamilton cycle.-----ORE’S Theorem
• Let G = (V, E) be a loop-free undirected graph with |V| = n>= 3, and
If deg(v) >= n/2 for all v ∈ V, then G contains a Hamilton cycle.---DIRAC’s
Theorem
Theorem
Find a Hamilton cycle, if one exists, for each of the graphs. If the graph has no
Hamilton cycle, find if it has a Hamilton Path
Example
Contd....
Königsberg bridge problem
• The Königsberg bridge problem is a famous historical problem in
mathematics that led to the foundation of graph theory and topology.
• In the 18th century, the city of Königsberg in Prussia (now Kaliningrad,
Russia) was set on both sides of the Pregel River, with two large islands
connected to each other and the mainland by seven bridges.
• An edge between two nodes means those committees share at least one
person (i.e., they conflict and cannot meet at the same time).
E F
How many hours are needed?
Each node represents a committee (A–J).
An edge between two nodes means those committees
G
share at least one person (i.e., they conflict and cannot
meet at the same time).
Determine the minimum number of time slots
H I
(chromatic number)
from λ options.
If λ<n, then P(Kn,λ)=0---not enough colors
to color all vertices differently.
For K3, the triangle graph, and λ=3:
P(K3,3)=3⋅2⋅1=6
so P(G,λ)=λ^2 (λ−1)^2
Summary
The Chromatic Polynomial Pk(G).
• The chromatic polynomial Pk(G) gives a formula for the
number of ways to properly color G with k colors. The
formula is polynomial in k.
Example 7: Chromatic Polynomial – Complete Graph Kn.
• Let us consider K4. Obviously
• P1(K4) = 0
• P2(K4) = 0
• P3(K4) = 0
• P4(K4) = 4.3.2.1
• P5(K4) = 5.4.3.2
• P6(K4) = 6.5.4.3
• P7(K4) = 7.6.5.4
• In general:
• Pk(K4) = k.(k-1)(k-2).(k-3)
• More generally:
• Pk(Kn) = k.(k-1).(k-2) ... (k – n+1)
• This is because:
• First vertex: k choices
• Second vertex: k−1 choices (must differ from the first)
• Third vertex: 𝑘−2
• Fourth vertex: 𝑘−3
The Chromatic Polynomial Pk(G).
• The chromatic polynomial Pk(G) gives a formula for the
number of ways to properly color G with k colors. The
formula is polynomial in k.
Example 7: Chromatic Polynomial – Complete Graph Kn.
• Let us consider K4. Obviously
• P1(K4) = 0
• P2(K4) = 0
• P3(K4) = 0
• P4(K4) = 4.3.2.1
• P5(K4) = 5.4.3.2
• P6(K4) = 6.5.4.3
• P7(K4) = 7.6.5.4
• In general:
• Pk(K4) = k.(k-1)(k-2).(k-3)
• More generally:
• Pk(Kn) = k.(k-1).(k-2) ... (k – n+1)
• This is because:
• First vertex: k choices
• Second vertex: k−1 choices (must differ from the first)
• Third vertex: 𝑘−2
• Fourth vertex: 𝑘−3
Chromatic Polynomial – Circuit C4.
Pk(C4) = k(k-1)2 + k(k-1)(k-2)2.
There are two kinds of proper colorings of C4 :
Case 1: Opposite vertices get the same color
•Think of the square: A–B–C–D–A
•Suppose vertex A = C (same color), and B = D (same color), and all adjacent
vertices are different. This can only happen if you use exactly 2 colors,
alternating
•Number of such colorings: k(k−1)
But there are multiple ways this can happen.
So the total number of 2-colorings of C4 is:k(k-1)2
Case 2: All 4 vertices use 3 or more distinct colors
Now we use more than 2 colors, so that all adjacent vertices are different
and not opposite. This more general case yields:k(k-1)(k-2)2
✅ Total Chromatic Polynomial:
So, putting both cases together:Pk(C4)=k(k-1)2 + k(k-1)(k-2)2
Example: Triangle Graph K3
Let: