SlideShare a Scribd company logo
1 of 10
Graph Data Structure and
Algorithms
Presented by
D.Anandhasilambarasan
KIT - CBE
Graph Data Structure and Algorithms
A Graph is a non-linear data structure consisting of nodes and
edges.
The nodes are sometimes also referred to as vertices and the
edges are lines or arcs that connect any two nodes in the graph.
A Graph consists of a finite set of vertices (or nodes) and set of
Edges which connect a pair of nodes.
 Nodes: These are the most important components in any graph. Nodes are
entities whose relationships are expressed using edges. If a graph comprises
2 nodes A and B and an undirected edge between them, then it expresses a
bi-directional relationship between the nodes and edge.
 Edges: Edges are the components that are used to represent the relationships
between various nodes in a graph. An edge between two nodes expresses a
one-way or two-way relationship between the nodes.
- In the above Graph, the set of vertices V = {0,1,2,3,4}
and the set of edges E = {01, 12, 23, 34, 04, 14, 13}.
Types of graphs
Undirected: An undirected graph is a graph in which all the edges are bi-
directional
i.e. the edges do not point in any specific direction.
Directed: A directed graph is a graph in which all the edges are uni-directional
i.e. the edges point in a single direction.
Weighted: In a weighted graph, each edge is assigned a weight or cost.
Cyclic: A graph is cyclic if the graph comprises a path that starts from a vertex
and ends at the same vertex. That path is called a cycle. An acyclic graph is a
graph that has no cycle.
Graph Representation
You can represent a graph in many ways. The two most common ways of
representing a graph is as follows:
Adjacency matrix
Adjacency list
Adjacency matrix
An adjacency matrix is a VxV binary matrix A. Element Ai,j is 1 if there is an
edge from vertex i to vertex j else Ai,jis 0.
Note: A binary matrix is a matrix in which the cells can have only one of two
possible values - either a 0 or 1.
The adjacency matrix of the following graph is:
i/j: 1 2 3 4
1: 0 1 0 1
2: 1 0 1 0
3: 0 1 0 1
4: 1 0 1 0
Adjacency list
The other way to represent a graph is by using an adjacency list. An adjacency
list is an array A of separate lists. Each element of the array Ai is a list, which
contains all the vertices that are adjacent to vertex i.
1 2
34
Applications of Graphs
 Graphs are used to solve many real-life problems. Graphs are used to
represent networks.
 The networks may include paths in a city or telephone network or circuit
network.
 Graphs are also used in social networks like LinkedIn, Facebook.
 It is used to Document link graphs.
 Scene graphs: Such graphs are very important in the computer games
industry.
 Robot planning: Such graph plans are used in planning paths for
Autonomous vehicles.
 Neural networks
 For example, in Facebook, each person is represented with a vertex (or
node).
 Each node is a structure and contains information like person id, name,
gender, locale etc.

More Related Content

What's hot

Graph representation
Graph representationGraph representation
Graph representationTech_MX
 
Adjacency list
Adjacency listAdjacency list
Adjacency listStefi Yu
 
A presentation on prim's and kruskal's algorithm
A presentation on prim's and kruskal's algorithmA presentation on prim's and kruskal's algorithm
A presentation on prim's and kruskal's algorithmGaurav Kolekar
 
Dijkstra's Algorithm
Dijkstra's AlgorithmDijkstra's Algorithm
Dijkstra's AlgorithmArijitDhali
 
Graphs in data structure
Graphs in data structureGraphs in data structure
Graphs in data structurehamza javed
 
Terminology of tree
Terminology of treeTerminology of tree
Terminology of treeRacksaviR
 
Types of Tree in Data Structure in C++
Types of Tree in Data Structure in C++Types of Tree in Data Structure in C++
Types of Tree in Data Structure in C++Himanshu Choudhary
 
Connectivity of graphs
Connectivity of graphsConnectivity of graphs
Connectivity of graphssana younas
 
Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search Treesagar yadav
 
Introduction to data structure ppt
Introduction to data structure pptIntroduction to data structure ppt
Introduction to data structure pptNalinNishant3
 

What's hot (20)

Minimum spanning tree
Minimum spanning treeMinimum spanning tree
Minimum spanning tree
 
Graph representation
Graph representationGraph representation
Graph representation
 
Adjacency list
Adjacency listAdjacency list
Adjacency list
 
Graph theory
Graph  theoryGraph  theory
Graph theory
 
A presentation on prim's and kruskal's algorithm
A presentation on prim's and kruskal's algorithmA presentation on prim's and kruskal's algorithm
A presentation on prim's and kruskal's algorithm
 
Tree - Data Structure
Tree - Data StructureTree - Data Structure
Tree - Data Structure
 
Dijkstra's Algorithm
Dijkstra's AlgorithmDijkstra's Algorithm
Dijkstra's Algorithm
 
Graphs in data structure
Graphs in data structureGraphs in data structure
Graphs in data structure
 
Expression trees
Expression treesExpression trees
Expression trees
 
Introduction to Graph Theory
Introduction to Graph TheoryIntroduction to Graph Theory
Introduction to Graph Theory
 
Terminology of tree
Terminology of treeTerminology of tree
Terminology of tree
 
Graph Data Structure
Graph Data StructureGraph Data Structure
Graph Data Structure
 
Hamilton path and euler path
Hamilton path and euler pathHamilton path and euler path
Hamilton path and euler path
 
Types of Tree in Data Structure in C++
Types of Tree in Data Structure in C++Types of Tree in Data Structure in C++
Types of Tree in Data Structure in C++
 
Graph theory
Graph theory Graph theory
Graph theory
 
Connectivity of graphs
Connectivity of graphsConnectivity of graphs
Connectivity of graphs
 
Single linked list
Single linked listSingle linked list
Single linked list
 
Minimum spanning tree
Minimum spanning treeMinimum spanning tree
Minimum spanning tree
 
Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search Tree
 
Introduction to data structure ppt
Introduction to data structure pptIntroduction to data structure ppt
Introduction to data structure ppt
 

Similar to Graph data structure and algorithms

Graphs in datastructures
Graphs in datastructuresGraphs in datastructures
Graphs in datastructuresLikhithaGunturi
 
Lecture 5b graphs and hashing
Lecture 5b graphs and hashingLecture 5b graphs and hashing
Lecture 5b graphs and hashingVictor Palmar
 
Network Topology
Network TopologyNetwork Topology
Network TopologyHarsh Soni
 
graphs presentation .pptx
graphs presentation .pptxgraphs presentation .pptx
graphs presentation .pptxssuser800a48
 
PPT on Graph Theory ( Tree, Cotree, nodes, branches, incidence , tie set and ...
PPT on Graph Theory ( Tree, Cotree, nodes, branches, incidence , tie set and ...PPT on Graph Theory ( Tree, Cotree, nodes, branches, incidence , tie set and ...
PPT on Graph Theory ( Tree, Cotree, nodes, branches, incidence , tie set and ...SUTAPAMUKHERJEE12
 
Representation of graph.pptx
Representation of graph.pptxRepresentation of graph.pptx
Representation of graph.pptxDileepKumar386873
 
Graph Introduction.ppt
Graph Introduction.pptGraph Introduction.ppt
Graph Introduction.pptFaruk Hossen
 
NAS-Ch2-Network Equations
NAS-Ch2-Network EquationsNAS-Ch2-Network Equations
NAS-Ch2-Network EquationsHussain K
 
graph_theory_1-11.pdf___________________
graph_theory_1-11.pdf___________________graph_theory_1-11.pdf___________________
graph_theory_1-11.pdf___________________ssuser1989da
 
NON-LINEAR DATA STRUCTURE-Graphs.pptx
NON-LINEAR DATA STRUCTURE-Graphs.pptxNON-LINEAR DATA STRUCTURE-Graphs.pptx
NON-LINEAR DATA STRUCTURE-Graphs.pptxRajitha Reddy Alugati
 
BRIEF RELETIONSHIP BETWEEN ADJACENCY MATRIX AND LIST.pptx
BRIEF RELETIONSHIP BETWEEN ADJACENCY MATRIX AND LIST.pptxBRIEF RELETIONSHIP BETWEEN ADJACENCY MATRIX AND LIST.pptx
BRIEF RELETIONSHIP BETWEEN ADJACENCY MATRIX AND LIST.pptxCHIRANTANMONDAL2
 
Graph theory concepts complex networks presents-rouhollah nabati
Graph theory concepts   complex networks presents-rouhollah nabatiGraph theory concepts   complex networks presents-rouhollah nabati
Graph theory concepts complex networks presents-rouhollah nabatinabati
 

Similar to Graph data structure and algorithms (20)

Graph theory
Graph theoryGraph theory
Graph theory
 
Graphs in datastructures
Graphs in datastructuresGraphs in datastructures
Graphs in datastructures
 
Electrical Network Topology
Electrical Network TopologyElectrical Network Topology
Electrical Network Topology
 
Lecture 5b graphs and hashing
Lecture 5b graphs and hashingLecture 5b graphs and hashing
Lecture 5b graphs and hashing
 
Graph.pptx
Graph.pptxGraph.pptx
Graph.pptx
 
Network Topology
Network TopologyNetwork Topology
Network Topology
 
graphs presentation .pptx
graphs presentation .pptxgraphs presentation .pptx
graphs presentation .pptx
 
Types of graphs
Types of graphsTypes of graphs
Types of graphs
 
PPT on Graph Theory ( Tree, Cotree, nodes, branches, incidence , tie set and ...
PPT on Graph Theory ( Tree, Cotree, nodes, branches, incidence , tie set and ...PPT on Graph Theory ( Tree, Cotree, nodes, branches, incidence , tie set and ...
PPT on Graph Theory ( Tree, Cotree, nodes, branches, incidence , tie set and ...
 
Representation of graph.pptx
Representation of graph.pptxRepresentation of graph.pptx
Representation of graph.pptx
 
Graph Introduction.ppt
Graph Introduction.pptGraph Introduction.ppt
Graph Introduction.ppt
 
Basics of graph
Basics of graphBasics of graph
Basics of graph
 
Graphs.pptx
Graphs.pptxGraphs.pptx
Graphs.pptx
 
NAS-Ch2-Network Equations
NAS-Ch2-Network EquationsNAS-Ch2-Network Equations
NAS-Ch2-Network Equations
 
graph_theory_1-11.pdf___________________
graph_theory_1-11.pdf___________________graph_theory_1-11.pdf___________________
graph_theory_1-11.pdf___________________
 
Graph
GraphGraph
Graph
 
NON-LINEAR DATA STRUCTURE-Graphs.pptx
NON-LINEAR DATA STRUCTURE-Graphs.pptxNON-LINEAR DATA STRUCTURE-Graphs.pptx
NON-LINEAR DATA STRUCTURE-Graphs.pptx
 
Graphs data structures
Graphs data structuresGraphs data structures
Graphs data structures
 
BRIEF RELETIONSHIP BETWEEN ADJACENCY MATRIX AND LIST.pptx
BRIEF RELETIONSHIP BETWEEN ADJACENCY MATRIX AND LIST.pptxBRIEF RELETIONSHIP BETWEEN ADJACENCY MATRIX AND LIST.pptx
BRIEF RELETIONSHIP BETWEEN ADJACENCY MATRIX AND LIST.pptx
 
Graph theory concepts complex networks presents-rouhollah nabati
Graph theory concepts   complex networks presents-rouhollah nabatiGraph theory concepts   complex networks presents-rouhollah nabati
Graph theory concepts complex networks presents-rouhollah nabati
 

Recently uploaded

call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 

Recently uploaded (20)

call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 

Graph data structure and algorithms

  • 1. Graph Data Structure and Algorithms Presented by D.Anandhasilambarasan KIT - CBE
  • 2. Graph Data Structure and Algorithms A Graph is a non-linear data structure consisting of nodes and edges. The nodes are sometimes also referred to as vertices and the edges are lines or arcs that connect any two nodes in the graph. A Graph consists of a finite set of vertices (or nodes) and set of Edges which connect a pair of nodes.
  • 3.  Nodes: These are the most important components in any graph. Nodes are entities whose relationships are expressed using edges. If a graph comprises 2 nodes A and B and an undirected edge between them, then it expresses a bi-directional relationship between the nodes and edge.  Edges: Edges are the components that are used to represent the relationships between various nodes in a graph. An edge between two nodes expresses a one-way or two-way relationship between the nodes.
  • 4. - In the above Graph, the set of vertices V = {0,1,2,3,4} and the set of edges E = {01, 12, 23, 34, 04, 14, 13}.
  • 5. Types of graphs Undirected: An undirected graph is a graph in which all the edges are bi- directional i.e. the edges do not point in any specific direction. Directed: A directed graph is a graph in which all the edges are uni-directional i.e. the edges point in a single direction. Weighted: In a weighted graph, each edge is assigned a weight or cost. Cyclic: A graph is cyclic if the graph comprises a path that starts from a vertex and ends at the same vertex. That path is called a cycle. An acyclic graph is a graph that has no cycle.
  • 6. Graph Representation You can represent a graph in many ways. The two most common ways of representing a graph is as follows: Adjacency matrix Adjacency list Adjacency matrix An adjacency matrix is a VxV binary matrix A. Element Ai,j is 1 if there is an edge from vertex i to vertex j else Ai,jis 0. Note: A binary matrix is a matrix in which the cells can have only one of two possible values - either a 0 or 1.
  • 7. The adjacency matrix of the following graph is: i/j: 1 2 3 4 1: 0 1 0 1 2: 1 0 1 0 3: 0 1 0 1 4: 1 0 1 0 Adjacency list The other way to represent a graph is by using an adjacency list. An adjacency list is an array A of separate lists. Each element of the array Ai is a list, which contains all the vertices that are adjacent to vertex i. 1 2 34
  • 8.
  • 9. Applications of Graphs  Graphs are used to solve many real-life problems. Graphs are used to represent networks.  The networks may include paths in a city or telephone network or circuit network.  Graphs are also used in social networks like LinkedIn, Facebook.  It is used to Document link graphs.  Scene graphs: Such graphs are very important in the computer games industry.
  • 10.  Robot planning: Such graph plans are used in planning paths for Autonomous vehicles.  Neural networks  For example, in Facebook, each person is represented with a vertex (or node).  Each node is a structure and contains information like person id, name, gender, locale etc.