Chapter 10 Graphs
Definition: A graph G = (V, E) consists of a nonempty set V of vertices (or nodes) and a set E of edges. Each edge has either one or two vertices associated with it, called its endpoints. An edge is said to connect its endpoints.
Basic Types of GRAPH
Some Terminology
Remark: There is no standard terminology for graph theory. So, it is crucial that you understand the terminology being used whenever you read material about graphs.
Example:
This pseudograph has both multiple edges and a loop.
a
b
c
Directed Graphs
Definition: An directed graph (or digraph)�G = (V, E) consists of a nonempty set V of vertices (or nodes) and a set E of directed edges (or arcs). Each edge is associated with an ordered pair of vertices. The directed edge associated with the ordered pair (u,v) is said to start at u and end at v.
Remark:
Some Terminology (continued)
a
b
c
c
a
b
In this directed multigraph the multiplicity of (a,b) is 1 and the multiplicity of (b,c) is 2.
Example:
This is a directed graph with three vertices and four edges.
Example:
Graph Terminology: Summary
10.1 Graphs and Graph Models
Graph Models: �Computer Networks (continued)
Graph Models: Computer Networks
Graph Models: Computer Networks
Graph Models: Social Networks
Graph Models: Social Networks
Example: A friendship graph where two people are connected if they are Facebook friends.
Graph Models: Social Networks
Example: An influence graph
Applications to Information Networks
Transportation Graphs
Software Design Applications
Software Design Applications
Example: The dependencies between the seven modules in the design of a web browser are represented by this module dependency graph.
Software Design Applications
Example: This precedence graph shows which statements must already have been executed before we can execute each of the six statements in the program.
Biological Applications
Example: This is the niche overlap graph for a forest ecosystem with nine species.
Biological Applications
Biological Applications
Example: This is a module of the protein interaction graph of
proteins that degrade RNA in a human cell.
Graph Terminology�and �Special Types of Graphs
Section 10.2
FREE: For Complete Playlist: https://www.youtube.com/c/FahadHussaintutorial/playlists
For Code, Slide and Books: https://fahadhussaincs.blogspot.com/
Basic Terminology
Definition 1. Two vertices u, v in an undirected graph G are called adjacent (or neighbors) in G if there is an edge e between u and v. Such an edge e is called incident with the vertices u and v and e is said to connect u and v.
Definition 2. The set of all neighbors of a vertex v of G = (V, E), denoted by N(v), is called the neighborhood of v. If A is a subset of V, we denote by N(A) the set of all vertices in G that are adjacent to at least one vertex in A. So,
Definition 3. The degree of a vertex in a undirected graph is the number of edges incident with it, except that a loop at a vertex contributes two to the degree of that vertex. The degree of the vertex v is denoted by deg(v).
FREE: For Complete Playlist: https://www.youtube.com/c/FahadHussaintutorial/playlists
For Code, Slide and Books: https://fahadhussaincs.blogspot.com/
Degrees and Neighborhoods of Vertices
Example: What are the degrees and neighborhoods of the vertices in the graphs G and H?
Solution:
G: deg(a) = 2, deg(b) = deg(c) = deg(f ) = 4, deg(d ) = 1, deg(e) = 3, deg(g) = 0.
N(a) = {b, f }, N(b) = {a, c, e, f }, N(c) = {b, d, e, f }, N(d) = {c},
N(e) = {b, c , f }, N(f) = {a, b, c, e}, N(g) = ∅ .
H: deg(a) = 4, deg(b) = deg(e) = 6, deg(c) = 1, deg(d) = 5.
N(a) = {b, d, e}, N(b) = {a, b, c, d, e}, N(c) = {b}, N(d) = {a, b, e},
N(e) = {a, b ,d}.
Handshaking Theorem
Theorem: If G is any graph, then the sum of the degrees of all the vertices of G equals twice the number of edges of G.
COROLLARY: The total degree of G is an even number
FREE: For Complete Playlist: https://www.youtube.com/c/FahadHussaintutorial/playlists
For Code, Slide and Books: https://fahadhussaincs.blogspot.com/
Example: How many edges are there in a graph with 10 vertices of degree six?
Solution: Because the sum of the degrees of the vertices is 6 ⋅ 10 = 60, the handshaking theorem tells us that 2m = 60. So the number of edges m = 30.
Example: If a graph has 5 vertices, can each vertex have degree 3?
Solution: This is not possible by the handshaking theorem, because the sum of the degrees of the vertices 3 ⋅ 5 = 15 is odd.
Handshaking Theorem
FREE: For Complete Playlist: https://www.youtube.com/c/FahadHussaintutorial/playlists
For Code, Slide and Books: https://fahadhussaincs.blogspot.com/
Theorms of Graph
FREE: For Complete Playlist: https://www.youtube.com/c/FahadHussaintutorial/playlists
For Code, Slide and Books: https://fahadhussaincs.blogspot.com/
Degree of Vertices
FREE: For Complete Playlist: https://www.youtube.com/c/FahadHussaintutorial/playlists
For Code, Slide and Books: https://fahadhussaincs.blogspot.com/
Directed Graphs (continued)
Definition: The in-degree of a vertex v, denoted deg−(v), is the number of edges which terminate at v. The out-degree of v, denoted deg+(v), is the number of edges with v as their initial vertex. Note that a loop at a vertex contributes 1 to both the in-degree and the out-degree of the vertex.
Example: In the graph G we have
deg−(a) = 2, deg−(b) = 2, deg−(c) = 3, deg−(d) = 2, deg−(e) = 3, deg−(f) = 0.
deg+(a) = 4, deg+(b) = 1, deg+(c) = 2, deg+(d) = 2, deg+ (e) = 3, deg+(f) = 0.
FREE: For Complete Playlist: https://www.youtube.com/c/FahadHussaintutorial/playlists
For Code, Slide and Books: https://fahadhussaincs.blogspot.com/
Special Types of Simple Graphs: �Complete Graphs
A complete graph on n vertices, denoted by Kn, is the simple graph that contains exactly one edge between each pair of distinct vertices.
FREE: For Complete Playlist: https://www.youtube.com/c/FahadHussaintutorial/playlists
For Code, Slide and Books: https://fahadhussaincs.blogspot.com/
Special Types of Simple Graphs: �Cycles and Wheels
A cycle Cn for n ≥ 3 consists of n vertices v1, v2 ,⋯ , vn, and edges {v1, v2}, {v2, v3} ,⋯ , {vn-1, vn}, {vn, v1}.
A wheel Wn is obtained by adding an additional vertex to a cycle Cn for n ≥ 3 and connecting this new vertex to each of the n vertices in Cn by new edges.
Special Types of Graphs and Computer Network Architecture
Various special graphs play an important role in the design of computer networks.
FREE: For Complete Playlist: https://www.youtube.com/c/FahadHussaintutorial/playlists
For Code, Slide and Books: https://fahadhussaincs.blogspot.com/
Special Types of Simple Graphs: �n-Cubes
An n-dimensional hypercube, or n-cube, Qn, is a graph with 2n vertices representing all bit strings of length n, where there is an edge between two vertices that differ in exactly one bit position.
FREE: For Complete Playlist: https://www.youtube.com/c/FahadHussaintutorial/playlists
For Code, Slide and Books: https://fahadhussaincs.blogspot.com/
Special Types of Graphs and Computer Network Architecture
FREE: For Complete Playlist: https://www.youtube.com/c/FahadHussaintutorial/playlists
For Code, Slide and Books: https://fahadhussaincs.blogspot.com/
Thanks
FREE: For Complete Playlist: https://www.youtube.com/c/FahadHussaintutorial/playlists
For Code, Slide and Books: https://fahadhussaincs.blogspot.com/
Bipartite Graphs
Definition: A simple graph G is bipartite if V can be partitioned into two disjoint subsets V1 and V2 such that every edge connects a vertex in V1 and a vertex in V2. In other words, there are no edges which connect two vertices in V1 or in V2.
What is disjoint Set?
FREE: For Complete Playlist: https://www.youtube.com/c/FahadHussaintutorial/playlists
For Code, Slide and Books: https://fahadhussaincs.blogspot.com/
Degree of Vertices
FREE: For Complete Playlist: https://www.youtube.com/c/FahadHussaintutorial/playlists
For Code, Slide and Books: https://fahadhussaincs.blogspot.com/
Bipartite Graphs (continued)
Example: Show that C3 is not bipartite.
Solution: If we divide the vertex set of C3 into two nonempty sets, one of the two must contain two vertices. But in C3 every vertex is connected to every other vertex. Therefore, the two vertices in the same partition are connected. Hence, C3 is not bipartite.
FREE: For Complete Playlist: https://www.youtube.com/c/FahadHussaintutorial/playlists
For Code, Slide and Books: https://fahadhussaincs.blogspot.com/
Bipartite Graphs (continued)
Example: Show that C6 is bipartite.
Solution: We can partition the vertex set into
V1 = {v1, v3, v5} and V2 = {v2, v4, v6} so that every edge of C6 connects a vertex in V1 and V2 .
FREE: For Complete Playlist: https://www.youtube.com/c/FahadHussaintutorial/playlists
For Code, Slide and Books: https://fahadhussaincs.blogspot.com/
Bipartite Graphs
G is bipartite
H is not bipartite since if we color a red, then the adjacent vertices f and b must both be blue.
FREE: For Complete Playlist: https://www.youtube.com/c/FahadHussaintutorial/playlists
For Code, Slide and Books: https://fahadhussaincs.blogspot.com/
Bipartite Graphs and Matchings
Complete Bipartite Graphs
Definition: A complete bipartite graph Km,n is a graph that has its vertex set partitioned into two subsets V1 of size m and V2 of size n such that there is an edge from every vertex in V1 to every vertex in V2.
Example: We display four complete bipartite graphs here.
New Graphs from Old
Definition: A subgraph of a graph G = (V,E) is a graph (W,F), where W ⊂ V and F ⊂ E. A subgraph H of G is a proper subgraph of G if H ≠ G.
Example: Here we show K5 and one of its subgraphs.
Definition: Let G = (V, E) be a simple graph. The subgraph induced by a subset W of the vertex set V is the graph (W,F), where the edge set F contains an edge in E if and only if both endpoints are in W.
Example: Here we show K5 and the subgraph induced by W = {a,b,c,e}.
New Graphs from Old (continued)
Definition: The union of two simple graphs G1 = (V1, E1) and G2 = (V2, E2) is the simple graph with vertex set V1 ⋃ V2 and edge set E1 ⋃ E2. The union of G1 and G2 is denoted by G1 ⋃ G2.
Example:
FREE: For Complete Playlist: https://www.youtube.com/c/FahadHussaintutorial/playlists
For Code, Slide and Books: https://fahadhussaincs.blogspot.com/
Section Summary
Representations of Graphs
Section 10.3
FREE: For Complete Playlist: https://www.youtube.com/c/FahadHussaintutorial/playlists
For Code, Slide and Books: https://fahadhussaincs.blogspot.com/
Representing Graphs: Adjacency Lists
Definition: An adjacency list can be used to represent a graph with no multiple edges by specifying the vertices that are adjacent to each vertex of the graph.
Example:
FREE: For Complete Playlist: https://www.youtube.com/c/FahadHussaintutorial/playlists
For Code, Slide and Books: https://fahadhussaincs.blogspot.com/
Representing Graphs: Adjacency Lists
Example:
FREE: For Complete Playlist: https://www.youtube.com/c/FahadHussaintutorial/playlists
For Code, Slide and Books: https://fahadhussaincs.blogspot.com/
Representation of Graphs:�Adjacency Matrices
Definition: Suppose that G = (V, E) is a simple graph where |V| = n. Arbitrarily list the vertices of G as v1, v2, … , vn. The adjacency matrix AG of G, with respect to the listing of vertices, is the n × n zero-one matrix with 1 as its (i, j)th entry when vi and vj are adjacent, and 0 as its (i, j)th entry when they are not adjacent.
FREE: For Complete Playlist: https://www.youtube.com/c/FahadHussaintutorial/playlists
For Code, Slide and Books: https://fahadhussaincs.blogspot.com/
Adjacency Matrices (continued)
Example:
The ordering
of vertices is a, b, c, d.
The ordering of vertices is a, b, c, d.
Note: The adjacency matrix of a simple graph is symmetric, i.e., aij = aji
Also, since there are no loops, each diagonal entry aij for i = 1, 2, 3, …, n, is 0.
When a graph is sparse, that is, it has few edges relatively to the total number of possible edges, it is much more efficient to represent the graph using an adjacency list than an adjacency matrix. But for a dense graph, which includes a high percentage of possible edges, an adjacency matrix is preferable.
Adjacency Matrices (continued)
FREE: For Complete Playlist: https://www.youtube.com/c/FahadHussaintutorial/playlists
For Code, Slide and Books: https://fahadhussaincs.blogspot.com/
Representation of Graphs:�Incidence Matrices
Definition: Let G = (V, E) be an undirected graph with vertices where v1, v2, … vn and edges e1, e2, … em. The incidence matrix with respect to the ordering of V and E is the n × m matrix M = [mij], where
FREE: For Complete Playlist: https://www.youtube.com/c/FahadHussaintutorial/playlists
For Code, Slide and Books: https://fahadhussaincs.blogspot.com/
Incidence Matrices (continued)
Example: Simple Graph and Incidence Matrix
The rows going from top to bottom represent v1 through v5 and the columns going from left to right represent e1 through e6.
Example: Pseudograph and Incidence Matrix
The rows going from top to bottom represent v1 through v5 and the columns going from left to right represent e1 through e8.
Connectivity
Section 10.4
Paths
Informal Definition: A path is a sequence of edges that begins at a vertex of a graph and travels from vertex to vertex along edges of the graph. As the path travels along its edges, it visits the vertices along this path, that is, the endpoints of these.
Applications: Numerous problems can be modeled with paths formed by traveling along edges of graphs such as:
Paths
Definition: Let n be a nonnegative integer and G an undirected graph. A path of length n from u to v in G is a sequence of n edges e1, … , en of G for which there exists a sequence x0 = u, x1, …, xn-1, xn = v of vertices such that ei has, for i = 1, …, n, the endpoints xi-1 and xi.
FREE: For Complete Playlist: https://www.youtube.com/c/FahadHussaintutorial/playlists
For Code, Slide and Books: https://fahadhussaincs.blogspot.com/
Paths (continued)
Example: In the simple graph here:
FREE: For Complete Playlist: https://www.youtube.com/c/FahadHussaintutorial/playlists
For Code, Slide and Books: https://fahadhussaincs.blogspot.com/
Summary of WALK TRAIL and PATH
FREE: For Complete Playlist: https://www.youtube.com/c/FahadHussaintutorial/playlists
For Code, Slide and Books: https://fahadhussaincs.blogspot.com/
Connectedness in Undirected Graphs
Definition: An undirected graph is called connected if there is a path between every pair of vertices. An undirected graph that is not connected is called disconnected. We say that we disconnect a graph when we remove vertices or edges, or both, to produce a disconnected subgraph.
Example: G1 is connected because there is a path between any pair of its vertices, as can be easily seen. However G2 is not connected because there is no path between vertices a and f, for example.
FREE: For Complete Playlist: https://www.youtube.com/c/FahadHussaintutorial/playlists
For Code, Slide and Books: https://fahadhussaincs.blogspot.com/
Connected and Strongly Connected Components� in a Graph
FREE: For Complete Playlist: https://www.youtube.com/c/FahadHussaintutorial/playlists
For Code, Slide and Books: https://fahadhussaincs.blogspot.com/
Euler and Hamiltonian Graphs
Section 10.5
Section Summary
Euler and Hamiltonian Graphs
Section 10.5
Euler Graph, Paths and Circuits
(now Kalingrad, Russia) was divided into four sections by the branches of the Pregel river. In the 18th century seven bridges connected these regions.
Euler Paths and Circuits
Definition: An Euler circuit in a graph G is a simple circuit containing every edge of G. An Euler path in G is a simple path containing every edge of G.
Example: Which of the undirected graphs G1, G2, and G3 has a Euler circuit? Of those that do not, which has an Euler path?
Solution: The graph G1 has an Euler circuit (e.g., a, e, c, d, e, b, a). But, as can easily be verified by inspection, neither G2 nor G3 has an Euler circuit. Note that G3 has an Euler path (e.g., a, c, d, e, b, d, a, b), but there is no Euler path in G2, which can be verified by inspection.
FREE: For Complete Playlist: https://www.youtube.com/c/FahadHussaintutorial/playlists
For Code, Slide and Books: https://fahadhussaincs.blogspot.com/
Euler Circuits and Paths
Example:
G1 contains exactly two vertices of odd degree (b and d). Hence it has an Euler path, e.g., d, a, b, c, d, b.
G2 has exactly two vertices of odd degree (b and d). Hence it has an Euler path, e.g., b, a, g, f, e, d, c, g, b, c, f, d.
G3 has six vertices of odd degree. Hence, it does not have an Euler path.
Necessary Conditions for Euler Circuits and Paths
FREE: For Complete Playlist: https://www.youtube.com/c/FahadHussaintutorial/playlists
For Code, Slide and Books: https://fahadhussaincs.blogspot.com/
Algorithm for Constructing an Euler Circuits
In our proof we developed this algorithms for constructing a Euler circuit in a graph with no vertices of odd degree.
Applications of Euler Paths and Circuits
FREE: For Complete Playlist: https://www.youtube.com/c/FahadHussaintutorial/playlists
For Code, Slide and Books: https://fahadhussaincs.blogspot.com/
Necessary and Sufficient Conditions for Euler Circuits and Paths (continued)
Theorem: A connected multigraph with at least two vertices has an Euler circuit if and only if each of its vertices has an even degree and it has an Euler path if and only if it has exactly two vertices of odd degree.
Example: Two of the vertices in the multigraph model of the Kӧnigsberg bridge problem have odd degree. Hence, there is no Euler circuit in this multigraph and it is impossible to start at a given point, cross each bridge exactly once, and return to the starting point.
Understanding Mohammed’s Scimitars.
Eulerian Path is a path in a graph that visits every edge exactly once. Eulerian Circuit is an Eulerian Path that starts and ends on the same vertex.
Following is Fleury’s Algorithm for printing the Eulerian trail or cycle
The idea is, “don’t burn bridges“ so that we can come back to a vertex and traverse the remaining edges. For example, let us consider the following graph.
Fleury’s Algorithm for printing Eulerian Path or Circuit
Hamilton Paths and Circuits
William Rowan Hamilton
(1805- 1865)
Euler paths and circuits contained every edge only once.
Now we look at paths and circuits that contain every vertex exactly once.
William Hamilton invented the Icosian puzzle in 1857. It consisted of a wooden dodecahedron (with 12 regular pentagons as faces), illustrated in
(a), with a peg at each vertex, labeled with the names of different cities. String was used to used to plot a circuit visiting 20 cities exactly once. The graph form of the puzzle is given in (b).
The solution (a Hamilton circuit) is given here.
Hamilton Paths and Circuits
Definition: A simple path in a graph G that passes through every vertex exactly once is called a Hamilton path, and a simple circuit in a graph G that passes through every vertex exactly once is called a Hamilton circuit.
That is, a simple path x0, x1, …, xn-1, xn in the graph G = (V, E) is called a Hamilton path if V = {x0, x1, … , xn-1, xn } and xi ≠ xj for 0≤ i < j ≤ n, and the simple circuit x0, x1, …, xn-1, xn, x0 (with n > 0) is a Hamilton circuit if x0, x1, … , xn-1, xn is a Hamilton path.
FREE: For Complete Playlist: https://www.youtube.com/c/FahadHussaintutorial/playlists
For Code, Slide and Books: https://fahadhussaincs.blogspot.com/
Hamilton Paths and Circuits
FREE: For Complete Playlist: https://www.youtube.com/c/FahadHussaintutorial/playlists
For Code, Slide and Books: https://fahadhussaincs.blogspot.com/
Hamilton Paths and Circuits
Example: Which of these simple graphs has a Hamilton circuit or, if not, a Hamilton path?
Solution:
G1 does not have a Hamilton circuit (Why?), but does have a Hamilton path : a, b ,e , c, d.
G2 has a Hamilton circuit: a, b, c, d, e, a.
G3 has a Hamilton circuit: a,b,e,d,c,a
FREE: For Complete Playlist: https://www.youtube.com/c/FahadHussaintutorial/playlists
For Code, Slide and Books: https://fahadhussaincs.blogspot.com/
Necessary Conditions for�Hamilton Circuits
Dirac’s Theorem: If G is a simple graph with n ≥ 3 vertices such that the degree of every vertex in G is ≥ n/2, then G has a Hamilton circuit.
Ore’s Theorem: If G is a simple graph with n ≥ 3 vertices such that deg(u) + deg(v) ≥ n for every pair of nonadjacent vertices, then G has a Hamilton circuit.
Gabriel Andrew Dirac
(1925-1984)
Øysten Ore
(1899-1968)
FREE: For Complete Playlist: https://www.youtube.com/c/FahadHussaintutorial/playlists
For Code, Slide and Books: https://fahadhussaincs.blogspot.com/
Applications of Hamilton Paths and Circuits
FREE: For Complete Playlist: https://www.youtube.com/c/FahadHussaintutorial/playlists
For Code, Slide and Books: https://fahadhussaincs.blogspot.com/
ISOMORPHISM OF GRAPHS
Section 10.3
Isomorphism of Graphs
Definition: The simple graphs G1 = (V1, E1) and G2 = (V2, E2) are isomorphic if there is a one-to-one and onto function f from V1 to V2 with the property that a and b are adjacent in G1 if and only if f(a) and f(b) are adjacent in G2 , for all a and b in V1 . Such a function f is called an isomorphism. Two simple graphs that are not isomorphic are called nonisomorphic.
FREE: For Complete Playlist: https://www.youtube.com/c/FahadHussaintutorial/playlists
For Code, Slide and Books: https://fahadhussaincs.blogspot.com/
Isomorphism of Graphs
FREE: For Complete Playlist: https://www.youtube.com/c/FahadHussaintutorial/playlists
For Code, Slide and Books: https://fahadhussaincs.blogspot.com/
Isomorphism of Graphs
FREE: For Complete Playlist: https://www.youtube.com/c/FahadHussaintutorial/playlists
For Code, Slide and Books: https://fahadhussaincs.blogspot.com/
Isomorphism of Graphs (cont.)
Example: Show that the graphs G =(V, E) and H = (W, F) are isomorphic.
Solution: The function f with
f(u1) = v1,f(u2) = v4, f(u3) = v3, and f(u4) = v2 is a one-to-one
correspondence between V and W.
Note that adjacent vertices in G are
u1 and u2, u1 and u3, u2 and u4,
and u3 and u4. Each of the pairs
f(u1) = v1 and f(u2) = v4, f(u1) = v1
and f(u3) = v3 , f(u2) = v4 and
f(u4) = v2 , and f(u3) = v3 and
f(u4) = v2 consists of two adjacent vertices in H.
FREE: For Complete Playlist: https://www.youtube.com/c/FahadHussaintutorial/playlists
For Code, Slide and Books: https://fahadhussaincs.blogspot.com/
Example: Show that the graphs G =(V, E) and G’ = (W, F) are isomorphic.
Solution: The function f with
f(v1) = v1,f(v2) = v3, f(v3) = v5, f(v4) = v2 and f(v5) = v4 is a one-to-one correspondence between V and W.
Note that adjacent vertices in G are v1 and v2, v2 and v3, v3 and v4, v4 and v5 and v5 and v1.
Each of the pairs f(v1) = v1 and f(v2) = v3, f(v2) = v3 and f(v3) = v5 , f(v3) = v5 and
f(v4) = v2 , f(v4) = v2 and f(v5) = v4 and f(v5) = v4 and f(v1) = v1 consists of two adjacent vertices in H.
Isomorphism of Graphs
FREE: For Complete Playlist: https://www.youtube.com/c/FahadHussaintutorial/playlists
For Code, Slide and Books: https://fahadhussaincs.blogspot.com/
EXAMPLE: Determine whether the graph G and G’ given below are isomorphic.
SOLUTION:
As both the graphs have the same number of vertices. But the graph G has 7 edges and the graph G’ has only 6 edges. Therefore the two graphs are not isomorphic.
Note: As the edges of both the graphs G and G’ are not same then how the one-one correspondence is possible ,that the reason the graphs G and G’ are not isomorphic.
Isomorphism of Graphs
FREE: For Complete Playlist: https://www.youtube.com/c/FahadHussaintutorial/playlists
For Code, Slide and Books: https://fahadhussaincs.blogspot.com/
EXAMPLE: Determine whether the graph G and G’ given below are isomorphic.
SOLUTION:
Both the 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 (so one-one correspondence is not possible). Hence, the two graphs are not isomorphic.
Isomorphism of Graphs
FREE: For Complete Playlist: https://www.youtube.com/c/FahadHussaintutorial/playlists
For Code, Slide and Books: https://fahadhussaincs.blogspot.com/
EXAMPLE: Determine whether the graph G and G’ given below are isomorphic.
SOLUTION:
Clearly the vertices of both the graphs G and G’ have the same degree (i.e “2”) and having the same number of vertices and edges but isomorphism is not possible. As the graph G’ is a connected graph but the graph G is not connected due to have two components (eca and bdf). Therefore the two graphs are non isomorphic.
Isomorphism of Graphs
FREE: For Complete Playlist: https://www.youtube.com/c/FahadHussaintutorial/playlists
For Code, Slide and Books: https://fahadhussaincs.blogspot.com/
Isomorphism of Graphs
EXAMPLE: Determine whether the graph G and G’ given below are isomorphic.
SOLUTION:
Clearly G has six vertices, G’ also has six vertices. And the graph G has two simple circuits of length 3; one is abca and the other is defd. But G’ does not have any simple circuit of length 3(as one simple circuit in G’ is uxwvu 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.
Isomorphism of Graphs
EXAMPLE: Determine whether the graph G and G’ given below are isomorphic.
SOLUTION:
Both the graph G and G’ have 8 vertices and 12 edges and both are also called regular graph(as each vertex has degree 3).The graph G has two simple circuits of length 5; abcfea(i.e starts and ends at a) and cdhgfc(i.e starts and ends at c). But G’ does not have any simple circuit of length 5 (it has simple circuit tyxut,vwxuv of length 4 etc). Therefore the two graphs are non-isomorphic.
FREE: For Complete Playlist: https://www.youtube.com/c/FahadHussaintutorial/playlists
For Code, Slide and Books: https://fahadhussaincs.blogspot.com/
Isomorphism of Graphs
EXAMPLE: Determine whether the given graph G and H are isomorphic.
Solution:
Solution: The function f with
f(a) = u, f(b) = v, f(c) = y, f(d) = x, f(e) = w and f(f) = z is a one-to-one correspondence between G and H.
Note that adjacent vertices in G are a and b, b and c, c and d, c and f, d and e, e and f and f and a.
Each of the pairs f(a) = u and f(b) = v, f(b) = v and f(c) = y , f(c) = y and f(d) = x , f(c) = y and f(f) = z , f(d) = x and f(e) = w, f(e) = w and f(f) = z and f(f) = z and f(a) = u consists of two adjacent vertices in H.
Algorithms for Graph Isomorphism
FREE: For Complete Playlist: https://www.youtube.com/c/FahadHussaintutorial/playlists
For Code, Slide and Books: https://fahadhussaincs.blogspot.com/
Applications of Graph Isomorphism
10.6
Shortest-Path Problems
Weighted Graphs
Graphs that have a number assigned to each edge are called weighted graphs.
SF
LA
DEN
CHI
ATL
MIA
BOS
NY
FREE: For Complete Playlist: https://www.youtube.com/c/FahadHussaintutorial/playlists
For Code, Slide and Books: https://fahadhussaincs.blogspot.com/
Weighted Graphs
SF
LA
DEN
CHI
ATL
MIA
BOS
NY
MILES
2534
1855
957
834
349
2451
908
722
860
606
760
191
1090
595
FREE: For Complete Playlist: https://www.youtube.com/c/FahadHussaintutorial/playlists
For Code, Slide and Books: https://fahadhussaincs.blogspot.com/
Weighted Graphs
SF
LA
DEN
CHI
ATL
MIA
BOS
NY
FARES
$129
$99
$79
$59
$89
$69
$129
$89
$39
$99
$79
$69
$39
FREE: For Complete Playlist: https://www.youtube.com/c/FahadHussaintutorial/playlists
For Code, Slide and Books: https://fahadhussaincs.blogspot.com/
Weighted Graphs
SF
LA
DEN
CHI
ATL
MIA
BOS
NY
FLIGHT TIMES
4:05
2:55
2:20
2:10
3:50
2:00
1:15
2:10
1:40
1:30
1:55
2:45
0:50
1:50
FREE: For Complete Playlist: https://www.youtube.com/c/FahadHussaintutorial/playlists
For Code, Slide and Books: https://fahadhussaincs.blogspot.com/
Weighted Graphs
FREE: For Complete Playlist: https://www.youtube.com/c/FahadHussaintutorial/playlists
For Code, Slide and Books: https://fahadhussaincs.blogspot.com/
Dijkstra’s Algorithm
FREE: For Complete Playlist: https://www.youtube.com/c/FahadHussaintutorial/playlists
For Code, Slide and Books: https://fahadhussaincs.blogspot.com/
w
3
4
v
x
u
5
3
7
4
y
8
z
2
7
9
Dijkstra’s algorithm: example
Step
N'
D(v)
0
1
2
3
4
5
D(w)
D(x)
D(y)
D(z)
u
∞
∞
7,u
3,u
5,u
uw
∞
11,w
6,w
5,u
14,x
11,w
6,w
uwx
uwxv
14,x
10,v
uwxvy
12,y
notes:
uwxvyz
Dijkstra’s algorithm: another example
Step
0
1
2
3
4
5
N'
u
ux
uxy
uxyv
uxyvw
uxyvwz
D(v)
2,u
2,u
2,u
D(w)
5,u
4,x
3,y
3,y
D(x)
1,u
D(y)
∞
2,x
D(z)
∞
∞
4,y
4,y
4,y
u
y
x
w
v
z
2
2
1
3
1
1
2
5
3
5
FREE: For Complete Playlist: https://www.youtube.com/c/FahadHussaintutorial/playlists
For Code, Slide and Books: https://fahadhussaincs.blogspot.com/
FREE: For Complete Playlist: https://www.youtube.com/c/FahadHussaintutorial/playlists
For Code, Slide and Books: https://fahadhussaincs.blogspot.com/
Problem: shortest path from a to z
a
b
d
f
z
c
e
g
4
5
5
7
4
2
1
5
5
3
3
4
FREE: For Complete Playlist: https://www.youtube.com/c/FahadHussaintutorial/playlists
For Code, Slide and Books: https://fahadhussaincs.blogspot.com/
The Traveling Salesman Problem
The Traveling Salesman Problem
FREE: For Complete Playlist: https://www.youtube.com/c/FahadHussaintutorial/playlists
For Code, Slide and Books: https://fahadhussaincs.blogspot.com/
Travelling Salesman problem
FREE: For Complete Playlist: https://www.youtube.com/c/FahadHussaintutorial/playlists
For Code, Slide and Books: https://fahadhussaincs.blogspot.com/
Travelling Salesman problem
FREE: For Complete Playlist: https://www.youtube.com/c/FahadHussaintutorial/playlists
For Code, Slide and Books: https://fahadhussaincs.blogspot.com/
10.7 �Planar Graphs
The House-and-Utilities Problem
Planar Graphs
FREE: For Complete Playlist: https://www.youtube.com/c/FahadHussaintutorial/playlists
For Code, Slide and Books: https://fahadhussaincs.blogspot.com/
Example
A graph may be planar even if it is usually drawn with crossings, since it may be possible to draw it in another way without crossings.
FREE: For Complete Playlist: https://www.youtube.com/c/FahadHussaintutorial/playlists
For Code, Slide and Books: https://fahadhussaincs.blogspot.com/
Example
A graph may be planar even if it represents a 3-dimensional object.
FREE: For Complete Playlist: https://www.youtube.com/c/FahadHussaintutorial/playlists
For Code, Slide and Books: https://fahadhussaincs.blogspot.com/
Planar Graphs
FREE: For Complete Playlist: https://www.youtube.com/c/FahadHussaintutorial/playlists
For Code, Slide and Books: https://fahadhussaincs.blogspot.com/
Regions
Euler’s Formula
# of edges, e = 6
# of vertices, v = 4
# of regions, r = e - v + 2 = 4
R4 R3 R2
R1
Euler’s Formula (Cont.)
K5
Euler’s Formula (Cont.)
K5
Euler’s Formula (Cont.)
If G has one or two vertices, it is true;
thus, we assume that G has at least three vertices.
If the degree of each vertex were at least 6, then by Handshaking Theorem,
2e ≥ 6v, i.e., e ≥ 3v,
but this contradicts the inequality from
Corollary 1: 1 e ≤ 3v – 6.
Euler’s Formula (Cont.)
Euler’s Formula (Cont.)
K3,3
Kuratowski’s Theorem
We have seen that K3,3 and K5 are not planar. Clearly, a graph is not planar if it contains either of these two graphs as a subgraph. Surprisingly, all nonplanar graphs must contain a subgraph that can be obtained from K3,3 or K5 using certain permitted operations. If a graph is planar, so will be any graph obtained by removing an edge {u, v} and adding a new vertex w together with edges {u,w} and {w, v}. Such an operation is called an elementary subdivision. The graphs G1 = (V1, E1) and G2 = (V2, E2) are called homeomorphic if they can be obtained from the same graph by a sequence of elementary subdivisions
10.8 Graph Coloring
10.8 Graph Coloring
10.8 Graph Coloring
A coloring of a simple graph is the assignment of a color to each vertex of the graph so that no two adjacent vertices are assigned the same color.
The chromatic number of a graph is the least number of colors needed for a coloring of this graph. The chromatic number of a graph G is denoted by χ (G).
(Here χ is the Greek letter chi.)
THEOREM 1
THE FOUR COLOR THEOREM The chromatic number of a planar graph is no greater than four.
10.8 Graph Coloring
10.8 Graph Coloring
10.8 Graph Coloring
Applications of Graph Colorings
Scheduling Final Exams How can the final exams at a university be scheduled so that no student has two exams at the same time?
Solution: This scheduling problem can be solved using a graph model, with vertices representing courses and with an edge between two vertices if there is a common student in the courses they represent. Each time slot for a final exam is represented by a different color. A scheduling of the exams corresponds to a coloring of the associated graph. For instance, suppose there are seven finals to be scheduled. Suppose the courses are numbered 1 through 7. Suppose that the following pairs of courses have common students: 1 and 2, 1 and 3, 1 and 4, 1 and 7, 2 and 3, 2 and 4, 2 and 5, 2 and 7, 3 and 4, 3 and 6, 3 and 7, 4 and 5, 4 and 6, 5 and 6, 5 and 7, and 6 and 7. In Figure 8 the graph associated with this set of classes is shown. A scheduling consists of a coloring of this graph. Because the chromatic number of this graph is 4 (the reader should verify this), four time slots are needed. A coloring of the graph using four colors and the associated schedule are shown in Figure 9.
Applications of Graph Colorings
Applications of Graph Colorings