DMS Unit-6
DMS Unit-6
Graphs: Graphs and Graph Models, Graph Terminology and Special Types of Graphs,
Representing Graphs and Graph Isomorphism, Connectivity, Euler and Hamilton Paths,
Shortest-Path Problems, Planar Graphs, Graph Colouring.
Graph:
1. A graph G = (V, E) consists of V=a non-empty set of vertices (or nodes) and E=a set of edges.
2. A graph with an infinite vertex set or an infinite number of edges is called an infinite graph.
3. a graph with a finite vertex set and a finite edge set is called a finite graph.
Graph Terminology.
Type Edges Multiple Edges Allowed? Loops Allowed?
Simple graph Undirected No Yes No
Multigraph Undirected Yes No No
Pseudograph Undirected Yes Yes
Simple directed graph Directed Yes No
Directed multigraph Directed Yes
Mixed graph Directed and undirected Yes
Graph models:
1. SOCIAL NETWORKS
2. COMMUNICATION NETWORKS
3. INFORMATION NETWORKS
4. SOFTWARE DESIGN APPLICATIONS
5. TRANSPORTATION NETWORKS
6. BIOLOGICAL NETWORKS
7. TOURNAMENTS
Graph Terminology and Special Types of Graphs:
1. Adjacency: In a graph G two vertices u and v are said to
be adjacent if they are the endpoints of an edge. The edge {u,v}–e is
said to be incident with the vertices.
In case the edge is directed, u is said to be adjacent to v and v is said
to be adjacent from u . Here, u is said to be the initial vertex and v is
said to the terminal vertex.
2. Degree: The degree of a vertex is the number of edges incident with it,
except the self-loop which contributes twice to the degree of the
vertex. Degree of a vertex u is denoted as deg(u) .
In case of directed graphs, the degree is further classified as in-
degree and out-degree. The in-degree of a vertex is the number of
edges with the given vertex as the terminal vertex. The out-degree of
a vertex is the number of edges with the given vertex as the initial
vertex. In-degree is denoted as deg−(u) and out-degree is denoted
as deg+(u) .
3. Handshaking Theorem: What would one get if the degrees of all the
vertices of a graph are added. In case of an undirected graph, each
edge contributes twice, once for its initial vertex and second for its
terminal vertex. So the sum of degrees is equal to twice the number of
edges. This fact is stated in the Handshaking Theorem.
2. Cycles: Cycles are simple graphs with vertices n≥3 n≥3 and
edges {1,2},{2,3}…{n−1,n}and{n,1} {1,2},{2,3}…{n−1,n}and{n,1} .C
ycle with n n vertices is denoted as Cn. Total number of edges are n with
n vertices in cycle graph.
3. Wheels: A wheel is just like a cycle, with one additional vertex which is
connected to every other vertex. Wheels of n n vertices with 1 addition
vertex are denoted by Wn Wn . Total number of edges are 2*(n-1) with n
vertices in wheel graph.
Representing Graphs:
1. Adjacency list:
2. Adjacency matrix:
3. Incident matrix:
Graph Isomorphism:
Two graphs G1 and G2 are said to be isomorphic if :
1. Their number of components (vertices and edges) are same.
2. Their edge connectivity is retained.
Example 1:
In this example, we have shown whether the following graphs are isomorphism.
Solution: For this, we will check all the four conditions of graph isomorphism, which are
described as follows:
Condition 1:
Example 2:
Solution: For this, we will check all the four conditions of graph isomorphism, which are described as
follows:
Condition 1:
o In the graph 1, the degree of sequence s is {2, 2, 3, 3}, i.e., G1 = {2, 2, 3, 3}.
o In the graph 2, the degree of sequence s is {2, 2, 3, 3}, i.e., G2 = {2, 2, 3, 3}.
Here., There are an equal number of degree sequences in both graphs G1 and G2. So these graphs satisfy
condition 3. Now we will check the fourth condition.
Condition 4:
Graph G1 forms a cycle of length 3 with the help of vertices {2, 3, 3}.
Graph G2 also forms a cycle of length 3 with the help of vertices {2, 3, 3}.
Here, It shows that both the graphs contain the same cycle because both graphs G1 and G2 are forming a
cycle of length 3 with the help of vertices {2, 3, 3}. So these graphs satisfy condition 4.
Thus,
o The graphs G1 and G2 satisfy all the above four necessary conditions.
o So G1 and G2 may be an isomorphism.
Euler and Hamilton Paths:
Euler’s Path : An Euler’s path contains each edge of ‘G’ exactly once and each vertex of ‘G’ at
least once. A connected graph G is said to be traversable if it contains an Euler’s path.
Explore our latest online courses and learn new skills at your own pace. Enroll
and become a certified expert to boost your career.
Euler’s Circuit: In an Euler’s path, if the starting vertex is same as its ending vertex, then it is
called an Euler’s circuit.
Note − This Euler path begins with a vertex of odd degree and ends with
the other vertex of odd degree.
Hamilton Paths: A connected graph is said to be Hamiltonian if it contains each vertex of G
exactly once. Such a path is called a Hamiltonian path.
Note −
Shortest-Path Problems:
Algorithm for Dijkstra’s Algorithm:
1. Mark the source node with a current distance of 0 and the rest with infinity.
2. Set the non-visited node with the smallest current distance as the current node.
3. For each neighbor, N of the current node adds the current distance of the adjacent node
with the weight of the edge connecting 0->1. If it is smaller than the current distance of
Node, set it as the new current distance of N.
4. Mark the current node 1 as visited.
5. Go to step 2 if there are any nodes are unvisited.
Step 1: Start from Node 0 and mark Node as visited as you can check in below image visited
Node is marked red.
Step 2: Check for adjacent Nodes, Now we have to choices (Either choose Node1 with
distance 2 or either choose Node 2 with distance 6 ) and choose Node with minimum
distance. In this step Node 1 is Minimum distance adjacent Node, so marked it as visited and
add up the distance.
Distance: Node 0 -> Node 1 = 2
Step 3: Then Move Forward and check for adjacent Node which is Node 3, so marked it as
visited and add up the distance, Now the distance will be:
Distance: Node 0 -> Node 1 -> Node 3 = 2 + 5 = 7
Step 4: Again we have two choices for adjacent Nodes (Either we can choose Node 4 with
distance 10 or either we can choose Node 5 with distance 15) so choose Node with minimum
distance. In this step Node 4 is Minimum distance adjacent Node, so marked it as visited and
add up the distance.
Distance: Node 0 -> Node 1 -> Node 3 -> Node 4 = 2 + 5 + 10 = 17
Step 5: Again, Move Forward and check for adjacent Node which is Node 6, so marked it as
visited and add up the distance, Now the distance will be:
Distance: Node 0 -> Node 1 -> Node 3 -> Node 4 -> Node 6 = 2 + 5 + 10 + 2 = 19
So, the Shortest Distance from the Source Vertex is 19 which is optimal one
Planar Graphs:
A planar graph is a graph that can be embedded in the plane such that no edges
intersect except at their endpoints. In other words, it can be drawn on a flat surface
without any edges crossing.
Graph Colouring:
Graph coloring is the assignment of colors to vertices of a graph such that no two
adjacent vertices share the same color. The minimum number of colors required to
color a graph is called its chromatic number(Chi Symbol (χ).
Chromatic Number of Cyclic Graph:
A graph is known as a cycle graph if it contains ‘n’ edges and ‘n’ vertices (n >= 3),
which form a cycle of length ‘n’. The chromatic number in a cycle graph depends upon
the parity of cycle length:
Case 1 (Odd length cycle): χ(G) = 3.
Case 2(Even length cycle): χ(G) = 2.