0% found this document useful (0 votes)
20 views17 pages

Unit 3 Lecture 1

Uploaded by

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

Unit 3 Lecture 1

Uploaded by

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

APEX INSTITUTE OF TECHNOLOGY

Bachelor of Engineering (Computer Science &


Engineering)

Subject: Data Structure


Subject Code: 23CSH-241
Chapter: Graph
Subject Coordinator:
Ms. Upasana Tiwari
(E15791)

Graph
Lecture No.-3.1 DISCOVER . LEARN .
EMPOWER
Index

• Concept of graph

• Graph Terminology

• Sequential representation of graph

• Adjacency Matrix

• Path matrix

2 2
Graph definition
Graph:-Graph is an ordered set G (V, E), where V is
the nonempty set of vertices and E is the set of
edges, connecting the pairs of vertices. A Graph is
a non-linear data structure. A Graph G(V, E) with 7
vertices (A, B, C, D, E,F,G) and six edges ((A,B), (B,E),
(E,G), (A,C), (D,F), (A,D)) is shown in the following
figure.
Directed and Undirected
Graph
• In a directed graph, edges form an ordered pair.
Edges represent a specific path from some vertex A
to another vertex B. C

A B
• In an undirected graph, edges are not associated
with the directions with them. An undirected graph
is shown in the above figure since its edges are not
attached with any of the directions. If an edge
exists between vertex A and B then the vertices can
be traversed from B to A as well as A to B.
C
A
B
Graph Terminology
• Adjacency − Two node or vertices are adjacent if
they are directly connected to each other through
an edge. In the following example, B is adjacent to
A, E is adjacent to B, and so on. C is not adjacent to
B.
• Path − Path represents a sequence of edges
between the two vertices. In the following example,
ABEG represents a path from A to G.
Continue..
• Closed Path: A path will be called as closed path if
the initial node is same as terminal node. A path
will be closed path if V0=VN.
• Cycle: A cycle can be defined as the path which has
no repeated edges or vertices except the first and
last vertices.
• Connected Graph:A connected graph is the one in
which some path exists between every two vertices
(u, v) in V. There are no isolated nodes in connected
graph.
Continue..
• Complete Graph: In complete graph every node is
A
connected with all other nodes.
B C
• Weighted Graph:In a weighted graph, each edge is
assigned with some data such as length or weight.
The weight of an edge e can be given as w(e) which
must be a positive (+) value indicating the cost of
traversing the edge. A
3 2
B C
2
Continue..
• Loop: In graph theory, a loop (also called a self-
loop or a buckle) is an edge that connects a vertex
to itself. A simple graph contains no loops.

A B

• Degree of the Node: Number of edges connected


with a node is called degree of a node. A node with
degree 1 is called pendant node. A node with
degree 0 is called isolated node.
Continue..

• Degree of the Node: Number of edges connected


with a node is called degree of a node. A node with
degree 1 is called pendant node. A node with
degree 0 is called isolated node.
• Indegree: In a directed graph number of edges
comes into the node is called indegree of that node.
• Outdegree: In a directed graph number of edges
comes out of the node is called outdegree of that
node.
Graph representation
There are two ways to store Graphs into the
computer's memory:
• Sequential representation (or, Adjacency matrix
representation)
• Linked list representation (or, Adjacency list
representation)
We focus our attention on sequential representation.
Sequential representation
In sequential representation, there is a use of an
adjacency matrix to represent the mapping between
vertices and edges of the graph.
If there is an edge between Vi and Vj, then an entry
Aij in the adjacency matrix representation of an
undirected graph G will be 1 otherwise it would be 0.
In another words
• aij = 1 {if edge exists from Vi to Vj}
• aij = 0 {Otherwise}
Adjacency Matrix
• Adjacency Matrix of an undirected graph
Continue..
• Adjacency Matrix of an directed graph
Continue..
• Adjacency matrix for a weighted directed graph
Path Matrix
• Path matrix for a directed graph
References
WEB LINKS
• https://www.geeksforgeeks.org/data-structures/
• https://www.javatpoint.com/data-structure-tutorial
• https://www.tutorialspoint.com/data_structures_al
gorithms/index.htm
VIDEO LINK
• https://www.youtube.com/watch?v=_OtCiotowG8
THANK YOU

17

You might also like