SlideShare a Scribd company logo
Graph theory
1
CONTENTS
 Graph: Basic Terminology and Special Types of
Graphs, Paths and Circuits, Hamiltonian and
Euler Paths and Circuits, Isomorphic Graphs,
Planer Graph, Dijkstra's Shortest Path
Algorithm. Trees: Trees, Rooted Trees, Prefix
Codes, Spanning Trees, Minimum Spanning
Trees, Kruskal’s and Prim’s Algorithm for
Minimum Spanning Tree.
2
Basic Terminology
Types of Graphs,
Paths
Circuits,
Hamiltonian and Euler Paths and
Circuits,
Isomorphic Graphs
Planer Graph
Dijkstra's Shortest Path Algorithm. 3
CMSC
203
-
Discrete
Structures
INTRODUCTION TO GRAPHS
Definition: A graph is collection of points called
vertices & collection of lines called edges.
Mathematically graph G is an ordered pair of (V, E)
Each edge eij is associated with an ordered pair of
vertices (Vi,Vj).
4
TYPES OF GRAPH:
 There are basically two types of graphs, i.e., Undirected
graph and Directed graph.
Directed graph:
 The directed graph can be made with the help of a set
of vertices, which are connected with the directed
edges. In the directed graph, the edges have a direction
which is associated with the vertices.
5
UNDIRECTED GRAPH
 The undirected graph can also be made of a set of
vertices which are connected together by the
undirected edges. All the edges of this graph are
bidirectional..
6
 Null Graph: A graph will be known as the null
graph if it contains no edges. With the help of
symbol Nn, we can denote the null graph of n
vertices. The diagram of a null graph is described
as follows:
7
CMSC
203
-
Discrete
Structures
SIMPLE & MULTIPLE GRAPHS
Definition: A graph that has neither self loops or
parallel edge is called as Simple Graph otherwise
it is called as Multiple Graph.
For Example,
G1 (Simple Graph ) G2 (Multiple Graph)
8
WEIGHTED GRAPH
Definition: If each edge or each vertex or both are
associated with some weight(+ve no.) then the
graph is called as Weighted Graph
9
SELF LOOPS & PARALLEL EDGES
Definition: If the end vertices Vi & Vj of any edge eij are same,
then edge eij called as Self Loop.
For Example, In graph G, the edge e7 is self loop.
10
DEGREE OF A VERTEX(UNDIRECTED GRAPH)
 Definition: degree of a vertex is the number of edges
connecting to that vertex.
 The degree of a vertex is indicated with the help of deg(v).
 If there is a simple graph, which contains n number of
vertices,
11
Hence Deg(a) = 2
Hence Deg(a) = 2
Deg(b) = 3
Deg(c) = 1
Deg(d) = 2.
Deg(a) = 0
DEGREE OF VERTEX IN DIRECTED GRAPH
 number of edges coming to the vertex. With the help
of syntax deg-(v),
 number of edges coming out from the vertex. With
the help of syntax deg+(v)
 The degree of a vertex is equal to the addition of in-
degree of a vertex and out-degree of a vertex.
 Deg(v) = deg-(v) + deg+(v)
12
13
In-degree:
In-degree of a vertex a = deg(a) = 1
In-degree of a vertex b = deg(b) = 2
In-degree of a vertex c = deg(c) = 2
In-degree of a vertex d = deg(d) = 1
In-degree of a vertex e = deg(e) = 1
In-degree of a vertex f = deg(f) = 1
In-degree of a vertex g = deg(g) = 0
Out-degree:
Out-degree of a vertex a = deg(a) = 2
Out-degree of a vertex b = deg(b) = 0
Out-degree of a vertex c = deg(c) = 1
Out-degree of a vertex d = deg(d) = 1
Out-degree of a vertex e = deg(e) = 1
Out-degree of a vertex f = deg(f) = 1
Out-degree of a vertex g = deg(g) = 2
14
In-degree
vertex a = deg(a) = 1
vertex b = deg(b) = 0
vertex c = deg(c) = 2
vertex d = deg(d) = 1
vertex e = deg(e) = 1
Out-degree:
vertex a = deg(a) = 1
vertex b = deg(b) = 2
vertex c = deg(c) = 0
vertex d = deg(d) = 1
vertex e = deg(e) = 1
Degree of a vertex a =
deg(a) = 1+1 = 2
Degree of a vertex b =
deg(b) = 0+2 = 2
Degree of a vertex c =
deg(c) = 2+0 = 2
Degree of a vertex d =
deg(d) = 1+1 = 2
Degree of a vertex e =
deg(e) = 1+1 = 2
MATRIX REPRESENTATION OF GRAPHS
A graph can also be represented by matrix.
Two ways are used for matrix representation of graph are given as
follows,
1. Adjacent Matrix
2. Incident Matrix
Lets see one by one…
15
1. ADJACENT MATRIX
aij=1, if there is as edge between vi &vj.
aij=0, if vi & vj are not adjacent.
A self loop at vertex vi corresponds to aij=1.
For Example,
A(G)=
16
2. INCIDENT MATRIX
Given a graph G with n vertices , e edges & no self loops. The
incidence matrix x(G)=[Xij] of the other graph G is an n*e matrix
where,
Xij=1, if jth edge ej is incident on ith vertex vi,
Xij=0, otherwise.
Here n vertices are rows & e edges are columns.
X(G)=
17
1. ADJACENT MATRIX
The A.M. of multigraph G with n vertices is an
n*n matrix A(G)=[aij] where,
aij=N, if there one or more edge are there between
vi &vj & N is no. of edges between vi & vj.
aij=0, otherwise.
For Example,
A(G)=
18
ADJACENCY MATRIX OF A DIAGRAPH
It is defined in similar fashion as it defined for undirected graph.
For Example,
A(D)=
19
INCIDENT MATRIX OF DIAGRAPH
Given a graph G with n, e & no self loops is matrix x(G)=[Xij] or
order n*e where n vertices are rows & e edges are columns such
that,Xij=1, if jth edge ej is incident out ith vertex vi
Xij=-1, if jth edge ej is incident into ith vertex vi
Xij=0, if jth edge ej not incident on ith vertex vi.
20
NULL GRAPH
Definition: If the edge set of any graph with n vertices is an empty
set, then the graph is known as null graph.
It is denoted by Nn For Example,
N3 N4
21
 Planer Graph: A graph will be known as
the planer graph if it is drawn in a single
plane and the two edges of this graph do not
cross each other. In this graph, all the nodes
and edges can be drawn in a plane. The
diagram of a planer graph is described as
follows:

22
 Non-planer graph: A given graph will be
known as the non-planer graph if it is not
drawn in a single plane, and two edges of
this graph must be crossed each other. The
diagram of a non-planer graph is described
as follows:
23
COMPLETE GRAPH
Definition: Let G be simple graph on n vertices. If the degree of
each vertex is (n-1) then the graph is called as complete graph.
Complete graph on n vertices, it is denoted by Kn.
In complete graph Kn, the number of edges are n(n-1)/2,
For example,
24
K1 K2 K3 K4 K5
REGULAR GRAPH
Definition: If the degree of each vertex is same say ‘r’ in any graph
G then the graph is said to be a regular graph of degree r.
For example,
25
K3 K4 K5
ISOMORPHISM
Definition: Two graphs are thought of as equivalent (called
isomorphic) if they have identical behavior in terms of graph
theoretic properties.
Two graphs G(V, E) & G’(V’,E’) are said to be isomorphic to each
other if there is one-one correspondence between their vertices &
between their edges such that incidence relationship in preserved.
It is denoted by G1=G2
26
ISOMORPHISM
For Example,
1 2 a b
4 3 d c
It is immediately apparent by definition of isomorphism that two
isomorphic graphs must have,
 the same number of vertices,
 the same number of edges, and
 the same degrees of vertices.
27
b
2
d
3
c
4
a
1
SUB GRAPH
Definition: A sub graph of a graph G = (V, E) is a graph G’ = (V’,
E’) where V’V and E’E.
For Example:
G G1 G2
28
SPANNING GRAPH
Definition: Let G=(V, E) be any graph. Then G’ is said to be the
spanning subgraph of the graph G if its vertex set V’ is equal to
vertex set V of G.
For Example:
G G1 G2
29
COMPLEMENT OF A GRAPH
Definition: Let G is a simple graph. Then complement of G
denoted by ~G is graph whose vertex set is same as vertex set of G
& in which two vertices are adjacent if & only if they are not
adjacent in G.For Example:
G ~G H ~H
30
BIPARTITE GRAPH
Definition: A graph G=(V, E) is called a bipartite graph if its
vertices V can be partitioned into two subsets V1 and
V2 such that each edge of G connects a vertex of V1 to a
vertex V2. It is denoted by Kmn, where m and n are the
numbers of vertices in V1 and V2 respectively.
A graph can not have self loop.
31
 Example: Draw the bipartite graphs K2, 4and
K3 ,4.Assuming any number of edges.
 Solution: First draw the appropriate number of vertices on
two parallel columns or rows and connect the vertices in one
column or row with the vertices in other column or row. The
bipartite graphs K2,4 and K3,4 are shown in fig respectively.

32
COMPLETE BIPARTITE GRAPH:
 A graph G = (V, E) is called a complete bipartite
graph if its vertices V can be partitioned into two
subsets V1 and V2 such that each vertex of V1 is
connected to each vertex of V2. The number of edges
in a complete bipartite graph is m.n as each of the m
vertices is connected to each of the n vertices.
33
WALK:
34
A walk can be defined as a sequence of edges and vertices of a
graph. When we have a graph and traverse it, then that traverse
will be known as a walk. In a walk, there can be repeated edges
and vertices. The number of edges which is covered in a walk
will be known as the Length of the walk. In a graph, there can be
more than one walk.
1. A, B, C, E, D (Number of length = 4)
2. D, B, A, C, E, D, C (Number of length
= 7)
3. E, C, B, A, C, E, D (Number of length
= 6)
TYPES OF WALKS
35
There are two types of the walk, which are described as
follows:
Open walk
Closed walk
Closed walk =
A, B, C, D, E, C,
A
Open walk = A,
B, C, D, E, C
In case of the open walk and closed walk, the edges and vertices
can be repeated.
TRAILS
A TRAIL CAN BE DESCRIBED AS AN OPEN WALK
WHERE NO EDGE IS ALLOWED TO REPEAT. IN
THE TRAILS, THE VERTEX CAN BE REPEATED.
36
Trail = A, C, H, F, C, B
Closed trail = A, C, H,
F, C, B, A
CIRCUIT
37
A circuit can be described as a closed walk where no edge is
allowed to repeat. In the circuit, the vertex can be repeated. A
closed trail in the graph theory is also known as a circuit.
Two points are important,
Edges cannot be repeated
Vertex can be repeated
Circuit: A, B, D, C, F, H, C, A
PATH:
38
A path is a type of open walk where neither edges nor vertices are
allowed to repeat. There is a possibility that only the starting vertex
and ending vertex are the same in a path.
So for a path, the following two points are important, which are
described as follows:
Edges cannot be repeated
Vertex cannot be repeated
Path: F, H, C, A, B, D
CYCLE:
39
A closed path in the graph theory is also known as a Cycle. A
cycle is a type of closed walk where neither edges nor vertices
are allowed to repeat. There is a possibility that only the starting
vertex and ending vertex are the same in a cycle.
So for a cycle, the following two points are important, which are
described as follows:
Edges cannot be repeated
Vertex cannot be repeated
Cycle: A, B, D, C, A
40
CMSC
203
-
Discrete
Structures
41
A, B, G, F, C, D Trail because there is no repeated edge in the sequence
B, G, F, C, B, G, A Walk because the sequence contains the repeated edges and
vertices.
C, E, F, C Cycle because the sequence does not contain any repeated vertex or
edge except the starting vertex C.
C, E, F, C, E Walk because the sequence contains the repeated edges and
vertices.
A, B, F, A Not a Walk because there is no direct path to go from B to F. That's
why we can say that the sequence ABFA is not a Walk.
F, D, E, C, B Path because the sequence does not contain any repeated edges
and vertices.
HAMILTONIAN PATH
42
CMSC
203
-
Discrete
Structures
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.
Example
Hamiltonian Path − e-d-b-a-c.
43
Euler Path:
A Euler Path through a graph is a path whose edge list contains each
edge of the graph exactly once.
Euler Circuit: An Euler Circuit is a path through a graph, in which the
initial vertex appears a second time as the terminal vertex.
Euler Graph: An Euler Graph is a graph that possesses a Euler Circuit.
A Euler Circuit uses every edge exactly once, but vertices may be
repeated.
44
• Graphs are used to define the flow of computation.
• Graphs are used to represent networks of
communication.
• Graphs are used to represent data organization.
• Graph transformation systems work on rule-based in-
memory manipulation of graphs. Graph databases
ensure transaction-safe, persistent storing and
querying of graph structured data.
• Graph theory is used to find shortest path in road or a
network.
• In Google Maps, various locations are represented as
vertices or nodes and the roads are represented as edges
and graph theory is used to find the shortest path
between two nodes.
45
A tree is an acyclic graph or graph having no
cycles. A tree or general trees is defined as a
non-empty finite set of elements called
vertices or nodes having the property that
each node can have minimum degree 1 and
maximum degree n
PROPERTIES OF TREES:
46
• There is only one path between each pair
of vertices of a tree.
• If a graph G there is one and only one
path between each pair of vertices G is a
tree.
• A tree T with n vertices has n-1 edges.
• A graph is a tree if and only if it a
minimal connected.
47
Rooted Trees:
If a directed tree has exactly one node or vertex called root
whose incoming degrees is 0 and all other vertices have
incoming degree one, then the tree is called rooted tree.
48
CMSC
203
-
Discrete
Structures
49
For example, a code with code words {9,
55} has the prefix property; a code
consisting of {9, 5, 59, 55} does not,
because "5" is a prefix of "59" and also of
"55".
50
CMSC
203
-
Discrete
Structures
51
A minimum spanning tree of G is a tree whose total weight is
as small as possible.
Kruskal's Algorithm to find a minimum spanning tree: This
algorithm finds the minimum spanning tree T of the given
connected weighted graph G.
• Input the given connected weighted graph G with n vertices
whose minimum spanning tree T, we want to find.
• Order all the edges of the graph G according to increasing
weights.
• Initialize T with all vertices but do include an edge.
• Add each of the graphs G in T which does not form a cycle
until n-1 edges are added.
52
53
CMSC
203
-
Discrete
Structures
54
The Edges of the
Graph
Edge Weight
Source Vertex Destination Vertex
E F 2
F D 2
B C 3
C F 3
C D 4
B F 5
B D 6
A B 7
A C 8
he next step that you will proceed with is arranging all edges in a sorted list by their
edge weights.
55
56
57
choose an arbitrary
starting vertex A as
starting vertex. This
means it will be
included first in
your tree structure
58
CMSC
203
-
Discrete
Structures
connected edges going outward from node A and you will pick
the one with a minimum edge weight to include
59
CMSC
203
-
Discrete
Structures
60
CMSC
203
-
Discrete
Structures
61
62
CMSC
203
-
Discrete
Structures
63
The summation of all the edge weights in MST
T(V’, E’) is equal to 30, which is the least possible
edge weight for any possible spanning tree
structure for this particular graph.
64
Edges Weights Added or Not
(E, F) 1 Added
(A, B) 2 Added
(C, D) 2 Added
(B, C) 3 Added
(D, E) 3 Added
(B, D) 6 Not Added
65
CMSC
203
-
Discrete
Structures
66
67
68
69
70
71
72
73

More Related Content

PPT
Graph-theory (1).ppt BBA 1st Semester Graph
PDF
Graphs.pdf
PPT
Graph-theory.ppt
PPT
Graph.ppt
PPTX
Module-5 (Part 1), VTU, MCA Mathematical Foundations for Computer Application
PPTX
Chapter 1
PPTX
1. Graph and Graph Terminologiesimp.pptx
PPTX
graph theory
Graph-theory (1).ppt BBA 1st Semester Graph
Graphs.pdf
Graph-theory.ppt
Graph.ppt
Module-5 (Part 1), VTU, MCA Mathematical Foundations for Computer Application
Chapter 1
1. Graph and Graph Terminologiesimp.pptx
graph theory

Similar to UNIT III discrete mathematice notes availiable (20)

PPTX
Graph Theory,Graph Terminologies,Planar Graph & Graph Colouring
PPT
graph ASS (1).ppt
PPTX
Graph ASS DBATU.pptx
PPT
graphass1-23022111180722548-1ba6b00a.ppt
PPTX
Elements of Graph Theory for IS.pptx
PDF
Cs6702 graph theory and applications 2 marks questions and answers
PPTX
GRAPH THEORY - Basic definition with examples
PPTX
Graphs Basics.pptx
PPTX
graph.pptx
PPTX
Ppt of graph theory
PPTX
Graph terminology and algorithm and tree.pptx
PPTX
GRAPH THEORY AND ITS APPLICATIONS.......
PPTX
FCS (graphs).pptx
PPT
Graph theory presentation
PDF
Network Theory
PPTX
Graph terminologies & special type graphs
PPT
Graphs
PDF
Cs6702 2marks rejinpaul
PDF
Cs6702 GCC
DOCX
Ass. (3)graph d.m
Graph Theory,Graph Terminologies,Planar Graph & Graph Colouring
graph ASS (1).ppt
Graph ASS DBATU.pptx
graphass1-23022111180722548-1ba6b00a.ppt
Elements of Graph Theory for IS.pptx
Cs6702 graph theory and applications 2 marks questions and answers
GRAPH THEORY - Basic definition with examples
Graphs Basics.pptx
graph.pptx
Ppt of graph theory
Graph terminology and algorithm and tree.pptx
GRAPH THEORY AND ITS APPLICATIONS.......
FCS (graphs).pptx
Graph theory presentation
Network Theory
Graph terminologies & special type graphs
Graphs
Cs6702 2marks rejinpaul
Cs6702 GCC
Ass. (3)graph d.m
Ad

Recently uploaded (20)

PDF
ChatGPT for Dummies - Pam Baker Ccesa007.pdf
PPTX
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
PDF
Weekly quiz Compilation Jan -July 25.pdf
PPTX
Introduction to Building Materials
PDF
Classroom Observation Tools for Teachers
PDF
IGGE1 Understanding the Self1234567891011
PDF
Hazard Identification & Risk Assessment .pdf
PDF
Empowerment Technology for Senior High School Guide
PPTX
Onco Emergencies - Spinal cord compression Superior vena cava syndrome Febr...
PPTX
Chinmaya Tiranga Azadi Quiz (Class 7-8 )
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
LDMMIA Reiki Yoga Finals Review Spring Summer
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
A powerpoint presentation on the Revised K-10 Science Shaping Paper
PDF
A systematic review of self-coping strategies used by university students to ...
PDF
Trump Administration's workforce development strategy
PDF
Complications of Minimal Access Surgery at WLH
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
ChatGPT for Dummies - Pam Baker Ccesa007.pdf
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
Weekly quiz Compilation Jan -July 25.pdf
Introduction to Building Materials
Classroom Observation Tools for Teachers
IGGE1 Understanding the Self1234567891011
Hazard Identification & Risk Assessment .pdf
Empowerment Technology for Senior High School Guide
Onco Emergencies - Spinal cord compression Superior vena cava syndrome Febr...
Chinmaya Tiranga Azadi Quiz (Class 7-8 )
Supply Chain Operations Speaking Notes -ICLT Program
LDMMIA Reiki Yoga Finals Review Spring Summer
Final Presentation General Medicine 03-08-2024.pptx
A powerpoint presentation on the Revised K-10 Science Shaping Paper
A systematic review of self-coping strategies used by university students to ...
Trump Administration's workforce development strategy
Complications of Minimal Access Surgery at WLH
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
Ad

UNIT III discrete mathematice notes availiable

  • 2. CONTENTS  Graph: Basic Terminology and Special Types of Graphs, Paths and Circuits, Hamiltonian and Euler Paths and Circuits, Isomorphic Graphs, Planer Graph, Dijkstra's Shortest Path Algorithm. Trees: Trees, Rooted Trees, Prefix Codes, Spanning Trees, Minimum Spanning Trees, Kruskal’s and Prim’s Algorithm for Minimum Spanning Tree. 2
  • 3. Basic Terminology Types of Graphs, Paths Circuits, Hamiltonian and Euler Paths and Circuits, Isomorphic Graphs Planer Graph Dijkstra's Shortest Path Algorithm. 3 CMSC 203 - Discrete Structures
  • 4. INTRODUCTION TO GRAPHS Definition: A graph is collection of points called vertices & collection of lines called edges. Mathematically graph G is an ordered pair of (V, E) Each edge eij is associated with an ordered pair of vertices (Vi,Vj). 4
  • 5. TYPES OF GRAPH:  There are basically two types of graphs, i.e., Undirected graph and Directed graph. Directed graph:  The directed graph can be made with the help of a set of vertices, which are connected with the directed edges. In the directed graph, the edges have a direction which is associated with the vertices. 5
  • 6. UNDIRECTED GRAPH  The undirected graph can also be made of a set of vertices which are connected together by the undirected edges. All the edges of this graph are bidirectional.. 6
  • 7.  Null Graph: A graph will be known as the null graph if it contains no edges. With the help of symbol Nn, we can denote the null graph of n vertices. The diagram of a null graph is described as follows: 7 CMSC 203 - Discrete Structures
  • 8. SIMPLE & MULTIPLE GRAPHS Definition: A graph that has neither self loops or parallel edge is called as Simple Graph otherwise it is called as Multiple Graph. For Example, G1 (Simple Graph ) G2 (Multiple Graph) 8
  • 9. WEIGHTED GRAPH Definition: If each edge or each vertex or both are associated with some weight(+ve no.) then the graph is called as Weighted Graph 9
  • 10. SELF LOOPS & PARALLEL EDGES Definition: If the end vertices Vi & Vj of any edge eij are same, then edge eij called as Self Loop. For Example, In graph G, the edge e7 is self loop. 10
  • 11. DEGREE OF A VERTEX(UNDIRECTED GRAPH)  Definition: degree of a vertex is the number of edges connecting to that vertex.  The degree of a vertex is indicated with the help of deg(v).  If there is a simple graph, which contains n number of vertices, 11 Hence Deg(a) = 2 Hence Deg(a) = 2 Deg(b) = 3 Deg(c) = 1 Deg(d) = 2. Deg(a) = 0
  • 12. DEGREE OF VERTEX IN DIRECTED GRAPH  number of edges coming to the vertex. With the help of syntax deg-(v),  number of edges coming out from the vertex. With the help of syntax deg+(v)  The degree of a vertex is equal to the addition of in- degree of a vertex and out-degree of a vertex.  Deg(v) = deg-(v) + deg+(v) 12
  • 13. 13 In-degree: In-degree of a vertex a = deg(a) = 1 In-degree of a vertex b = deg(b) = 2 In-degree of a vertex c = deg(c) = 2 In-degree of a vertex d = deg(d) = 1 In-degree of a vertex e = deg(e) = 1 In-degree of a vertex f = deg(f) = 1 In-degree of a vertex g = deg(g) = 0 Out-degree: Out-degree of a vertex a = deg(a) = 2 Out-degree of a vertex b = deg(b) = 0 Out-degree of a vertex c = deg(c) = 1 Out-degree of a vertex d = deg(d) = 1 Out-degree of a vertex e = deg(e) = 1 Out-degree of a vertex f = deg(f) = 1 Out-degree of a vertex g = deg(g) = 2
  • 14. 14 In-degree vertex a = deg(a) = 1 vertex b = deg(b) = 0 vertex c = deg(c) = 2 vertex d = deg(d) = 1 vertex e = deg(e) = 1 Out-degree: vertex a = deg(a) = 1 vertex b = deg(b) = 2 vertex c = deg(c) = 0 vertex d = deg(d) = 1 vertex e = deg(e) = 1 Degree of a vertex a = deg(a) = 1+1 = 2 Degree of a vertex b = deg(b) = 0+2 = 2 Degree of a vertex c = deg(c) = 2+0 = 2 Degree of a vertex d = deg(d) = 1+1 = 2 Degree of a vertex e = deg(e) = 1+1 = 2
  • 15. MATRIX REPRESENTATION OF GRAPHS A graph can also be represented by matrix. Two ways are used for matrix representation of graph are given as follows, 1. Adjacent Matrix 2. Incident Matrix Lets see one by one… 15
  • 16. 1. ADJACENT MATRIX aij=1, if there is as edge between vi &vj. aij=0, if vi & vj are not adjacent. A self loop at vertex vi corresponds to aij=1. For Example, A(G)= 16
  • 17. 2. INCIDENT MATRIX Given a graph G with n vertices , e edges & no self loops. The incidence matrix x(G)=[Xij] of the other graph G is an n*e matrix where, Xij=1, if jth edge ej is incident on ith vertex vi, Xij=0, otherwise. Here n vertices are rows & e edges are columns. X(G)= 17
  • 18. 1. ADJACENT MATRIX The A.M. of multigraph G with n vertices is an n*n matrix A(G)=[aij] where, aij=N, if there one or more edge are there between vi &vj & N is no. of edges between vi & vj. aij=0, otherwise. For Example, A(G)= 18
  • 19. ADJACENCY MATRIX OF A DIAGRAPH It is defined in similar fashion as it defined for undirected graph. For Example, A(D)= 19
  • 20. INCIDENT MATRIX OF DIAGRAPH Given a graph G with n, e & no self loops is matrix x(G)=[Xij] or order n*e where n vertices are rows & e edges are columns such that,Xij=1, if jth edge ej is incident out ith vertex vi Xij=-1, if jth edge ej is incident into ith vertex vi Xij=0, if jth edge ej not incident on ith vertex vi. 20
  • 21. NULL GRAPH Definition: If the edge set of any graph with n vertices is an empty set, then the graph is known as null graph. It is denoted by Nn For Example, N3 N4 21
  • 22.  Planer Graph: A graph will be known as the planer graph if it is drawn in a single plane and the two edges of this graph do not cross each other. In this graph, all the nodes and edges can be drawn in a plane. The diagram of a planer graph is described as follows:  22
  • 23.  Non-planer graph: A given graph will be known as the non-planer graph if it is not drawn in a single plane, and two edges of this graph must be crossed each other. The diagram of a non-planer graph is described as follows: 23
  • 24. COMPLETE GRAPH Definition: Let G be simple graph on n vertices. If the degree of each vertex is (n-1) then the graph is called as complete graph. Complete graph on n vertices, it is denoted by Kn. In complete graph Kn, the number of edges are n(n-1)/2, For example, 24 K1 K2 K3 K4 K5
  • 25. REGULAR GRAPH Definition: If the degree of each vertex is same say ‘r’ in any graph G then the graph is said to be a regular graph of degree r. For example, 25 K3 K4 K5
  • 26. ISOMORPHISM Definition: Two graphs are thought of as equivalent (called isomorphic) if they have identical behavior in terms of graph theoretic properties. Two graphs G(V, E) & G’(V’,E’) are said to be isomorphic to each other if there is one-one correspondence between their vertices & between their edges such that incidence relationship in preserved. It is denoted by G1=G2 26
  • 27. ISOMORPHISM For Example, 1 2 a b 4 3 d c It is immediately apparent by definition of isomorphism that two isomorphic graphs must have,  the same number of vertices,  the same number of edges, and  the same degrees of vertices. 27 b 2 d 3 c 4 a 1
  • 28. SUB GRAPH Definition: A sub graph of a graph G = (V, E) is a graph G’ = (V’, E’) where V’V and E’E. For Example: G G1 G2 28
  • 29. SPANNING GRAPH Definition: Let G=(V, E) be any graph. Then G’ is said to be the spanning subgraph of the graph G if its vertex set V’ is equal to vertex set V of G. For Example: G G1 G2 29
  • 30. COMPLEMENT OF A GRAPH Definition: Let G is a simple graph. Then complement of G denoted by ~G is graph whose vertex set is same as vertex set of G & in which two vertices are adjacent if & only if they are not adjacent in G.For Example: G ~G H ~H 30
  • 31. BIPARTITE GRAPH Definition: A graph G=(V, E) is called a bipartite graph if its vertices V can be partitioned into two subsets V1 and V2 such that each edge of G connects a vertex of V1 to a vertex V2. It is denoted by Kmn, where m and n are the numbers of vertices in V1 and V2 respectively. A graph can not have self loop. 31
  • 32.  Example: Draw the bipartite graphs K2, 4and K3 ,4.Assuming any number of edges.  Solution: First draw the appropriate number of vertices on two parallel columns or rows and connect the vertices in one column or row with the vertices in other column or row. The bipartite graphs K2,4 and K3,4 are shown in fig respectively.  32
  • 33. COMPLETE BIPARTITE GRAPH:  A graph G = (V, E) is called a complete bipartite graph if its vertices V can be partitioned into two subsets V1 and V2 such that each vertex of V1 is connected to each vertex of V2. The number of edges in a complete bipartite graph is m.n as each of the m vertices is connected to each of the n vertices. 33
  • 34. WALK: 34 A walk can be defined as a sequence of edges and vertices of a graph. When we have a graph and traverse it, then that traverse will be known as a walk. In a walk, there can be repeated edges and vertices. The number of edges which is covered in a walk will be known as the Length of the walk. In a graph, there can be more than one walk. 1. A, B, C, E, D (Number of length = 4) 2. D, B, A, C, E, D, C (Number of length = 7) 3. E, C, B, A, C, E, D (Number of length = 6)
  • 35. TYPES OF WALKS 35 There are two types of the walk, which are described as follows: Open walk Closed walk Closed walk = A, B, C, D, E, C, A Open walk = A, B, C, D, E, C In case of the open walk and closed walk, the edges and vertices can be repeated.
  • 36. TRAILS A TRAIL CAN BE DESCRIBED AS AN OPEN WALK WHERE NO EDGE IS ALLOWED TO REPEAT. IN THE TRAILS, THE VERTEX CAN BE REPEATED. 36 Trail = A, C, H, F, C, B Closed trail = A, C, H, F, C, B, A
  • 37. CIRCUIT 37 A circuit can be described as a closed walk where no edge is allowed to repeat. In the circuit, the vertex can be repeated. A closed trail in the graph theory is also known as a circuit. Two points are important, Edges cannot be repeated Vertex can be repeated Circuit: A, B, D, C, F, H, C, A
  • 38. PATH: 38 A path is a type of open walk where neither edges nor vertices are allowed to repeat. There is a possibility that only the starting vertex and ending vertex are the same in a path. So for a path, the following two points are important, which are described as follows: Edges cannot be repeated Vertex cannot be repeated Path: F, H, C, A, B, D
  • 39. CYCLE: 39 A closed path in the graph theory is also known as a Cycle. A cycle is a type of closed walk where neither edges nor vertices are allowed to repeat. There is a possibility that only the starting vertex and ending vertex are the same in a cycle. So for a cycle, the following two points are important, which are described as follows: Edges cannot be repeated Vertex cannot be repeated Cycle: A, B, D, C, A
  • 41. 41 A, B, G, F, C, D Trail because there is no repeated edge in the sequence B, G, F, C, B, G, A Walk because the sequence contains the repeated edges and vertices. C, E, F, C Cycle because the sequence does not contain any repeated vertex or edge except the starting vertex C. C, E, F, C, E Walk because the sequence contains the repeated edges and vertices. A, B, F, A Not a Walk because there is no direct path to go from B to F. That's why we can say that the sequence ABFA is not a Walk. F, D, E, C, B Path because the sequence does not contain any repeated edges and vertices.
  • 42. HAMILTONIAN PATH 42 CMSC 203 - Discrete Structures 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. Example Hamiltonian Path − e-d-b-a-c.
  • 43. 43 Euler Path: A Euler Path through a graph is a path whose edge list contains each edge of the graph exactly once. Euler Circuit: An Euler Circuit is a path through a graph, in which the initial vertex appears a second time as the terminal vertex. Euler Graph: An Euler Graph is a graph that possesses a Euler Circuit. A Euler Circuit uses every edge exactly once, but vertices may be repeated.
  • 44. 44 • Graphs are used to define the flow of computation. • Graphs are used to represent networks of communication. • Graphs are used to represent data organization. • Graph transformation systems work on rule-based in- memory manipulation of graphs. Graph databases ensure transaction-safe, persistent storing and querying of graph structured data. • Graph theory is used to find shortest path in road or a network. • In Google Maps, various locations are represented as vertices or nodes and the roads are represented as edges and graph theory is used to find the shortest path between two nodes.
  • 45. 45 A tree is an acyclic graph or graph having no cycles. A tree or general trees is defined as a non-empty finite set of elements called vertices or nodes having the property that each node can have minimum degree 1 and maximum degree n
  • 46. PROPERTIES OF TREES: 46 • There is only one path between each pair of vertices of a tree. • If a graph G there is one and only one path between each pair of vertices G is a tree. • A tree T with n vertices has n-1 edges. • A graph is a tree if and only if it a minimal connected.
  • 47. 47 Rooted Trees: If a directed tree has exactly one node or vertex called root whose incoming degrees is 0 and all other vertices have incoming degree one, then the tree is called rooted tree.
  • 49. 49 For example, a code with code words {9, 55} has the prefix property; a code consisting of {9, 5, 59, 55} does not, because "5" is a prefix of "59" and also of "55".
  • 51. 51 A minimum spanning tree of G is a tree whose total weight is as small as possible. Kruskal's Algorithm to find a minimum spanning tree: This algorithm finds the minimum spanning tree T of the given connected weighted graph G. • Input the given connected weighted graph G with n vertices whose minimum spanning tree T, we want to find. • Order all the edges of the graph G according to increasing weights. • Initialize T with all vertices but do include an edge. • Add each of the graphs G in T which does not form a cycle until n-1 edges are added.
  • 52. 52
  • 54. 54 The Edges of the Graph Edge Weight Source Vertex Destination Vertex E F 2 F D 2 B C 3 C F 3 C D 4 B F 5 B D 6 A B 7 A C 8 he next step that you will proceed with is arranging all edges in a sorted list by their edge weights.
  • 55. 55
  • 56. 56
  • 57. 57 choose an arbitrary starting vertex A as starting vertex. This means it will be included first in your tree structure
  • 58. 58 CMSC 203 - Discrete Structures connected edges going outward from node A and you will pick the one with a minimum edge weight to include
  • 61. 61
  • 63. 63 The summation of all the edge weights in MST T(V’, E’) is equal to 30, which is the least possible edge weight for any possible spanning tree structure for this particular graph.
  • 64. 64 Edges Weights Added or Not (E, F) 1 Added (A, B) 2 Added (C, D) 2 Added (B, C) 3 Added (D, E) 3 Added (B, D) 6 Not Added
  • 66. 66
  • 67. 67
  • 68. 68
  • 69. 69
  • 70. 70
  • 71. 71
  • 72. 72
  • 73. 73