0% found this document useful (0 votes)
32 views13 pages

DMS Unit-6

This document provides an overview of graphs, including their definitions, types, and terminology. It covers graph models, special types of graphs, graph isomorphism, Euler and Hamilton paths, shortest-path problems, planar graphs, and graph coloring. Key concepts such as adjacency, degree, and the Handshaking Theorem are also discussed, along with algorithms like Dijkstra’s for finding shortest paths.

Uploaded by

sandhyag
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views13 pages

DMS Unit-6

This document provides an overview of graphs, including their definitions, types, and terminology. It covers graph models, special types of graphs, graph isomorphism, Euler and Hamilton paths, shortest-path problems, planar graphs, and graph coloring. Key concepts such as adjacency, degree, and the Handshaking Theorem are also discussed, along with algorithms like Dijkstra’s for finding shortest paths.

Uploaded by

sandhyag
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 13

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.

Different types of graphs:

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.

Some Special Simple Graphs:


1. Complete Graphs: A simple graph of n n vertices having exactly one
edge between each pair of vertices is called a complete graph. A
complete graph of n n vertices is denoted by Kn Kn . Total number of
edges are n*(n-1)/2 with n vertices in complete graph.

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.

4. Hypercube: The Hypercube or n-cube is a graph with 2n 2n vertices


each represented by a n-bit string. The vertices which differ by at most 1-
bit are connected by edges. A hypercube of 2n 2n vertices is denoted
by Qn Qn . Total number of edges are n*2n−1 2n−1 with 2n 2n vertices in
cube graph.

5. Bipartite Graphs: A simple graph G G is said to be bipartite if its vertex


set V V can be divided into two disjoint sets such that every edge
in G G has its initial vertex in the first set and the terminal vertex in the
second set. Total number of edges are (n*m) with (n+m) vertices in
bipartite 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:

o In graph 1, there is a total 4 number of vertices, i.e., G1 = 4.


o In graph 2, there is a total 4 number of vertices, i.e., G2 = 4.
Condition 2:

o In graph 1, there is a total 5 number of edges, i.e., G1 = 5.


o In graph 2, there is a total 6 number of edges, i.e., G2 = 6.
Since, these graphs violate condition 2. So these graphs are not an isomorphism. Graph G1 and
graph G2 are not isomorphism graphs.

Example 2:

Solution: For this, we will check all the four conditions of graph isomorphism, which are described as
follows:

Condition 1:

o In graph 1, there is a total 4 number of vertices, i.e., G1 = 4.


o In graph 2, there is a total 4 number of vertices, i.e., G2 = 4.
Condition 2:

o In graph 1, there is a total 5 number of edges, i.e., G1 = 5.


o In graph 2, there is a total 5 number of edges, i.e., G2 = 5.
Condition 3:

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.

Euler’s Path = d-c-a-b-d-e.

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.

Euler’s Path = a-b-c-d-a-g-f-e-c-a.

Euler’s Circuit Theorem: A connected graph ‘G’ is traversable if and only if


the number of vertices with odd degree in G is exactly 2 or 0. A connected graph G
can contain an Euler’s path, but not an Euler’s circuit, if it has exactly two vertices
with an odd degree.

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.

Hamiltonian Path − e-d-b-a-c.

Note −

 Euler’s circuit contains each edge of the graph exactly once.


 In a Hamiltonian cycle, some edges of the graph can be skipped.

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.

Example: Consider the below graph.


The algorithm will generate the shortest path from node 0 to all the other nodes in the graph.
For this graph, we will assume that the weight of the edges represents the distance
between two nodes.
As, we can see we have the shortest path from,
Node 0 to Node 1, from
Node 0 to Node 2, from
Node 0 to Node 3, from
Node 0 to Node 4, from
Node 0 to Node 6.
Initially we have a set of resources given below:
 The Distance from the source node to itself is 0. In this example the source node is 0.
 The distance from the source node to all other node is unknown so we mark all of them as
infinity.
Example: 0 -> 0, 1-> ∞,2-> ∞,3-> ∞,4-> ∞,5-> ∞,6-> ∞.
 we’ll also have an array of unvisited elements that will keep track of unvisited or unmarked
Nodes.
 Algorithm will complete when all the nodes marked as visited and the distance between
them added to the path. Unvisited Nodes:- 0 1 2 3 4 5 6.

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.

You might also like