SlideShare a Scribd company logo
GraphRepresentations
RAMKRISHNA
BHAGAT
Contents
●
●
●
Introduction
Applications
Representations
➢ Sequential
➢ Linked
● TraversalAlgorithms
Introduction
A graph can be defined as group of vertices and edges that are used to connect these vertices. A graph can be seen as a cyclic
tree, where the vertices (Nodes) maintain any complex relationship among them instead of having parent child relationship.
Applications of Graph
Representations of graph
❖ Sequential Representation
❖ Linked Representation
Sequential Representation
In sequential representation, we use adjacency matrix to store the mapping represented by vertices and edges. In adjacency
matrix, the rows and columns are represented by the graph vertices. A graph having n vertices, will have a dimension n x n.
Linked Representation
In the linked representation, an adjacency list is used to store the Graph into the computer's memory.
Graph Traversal Algorithm
● Breadth First Search
● Depth First Search
Breadth First Search (BFS) Algorithm
Breadth first search is a graph traversal algorithm that starts traversing the graph from root node and explores all the
neighbouring nodes. Then, it selects the nearest node and explore all the unexplored nodes. The algorithm follows the same
process for each of the nearest node until it finds the goal.
Steps :
1. AddAtoQUEUE1andNULLtoQUEUE2.
QUEUE1 = {A}
QUEUE2 = {NULL}
2.DeletetheNodeAfromQUEUE1andinsert all its neighbours.
InsertNodeAinto QUEUE2
QUEUE1 = {A}
QUEUE2 = {NULL}
3.DeletethenodeBfromQUEUE1andinsertall its neighbours.
InsertnodeBinto QUEUE2.
QUEUE1 = {A}
QUEUE2 = {NULL}
:4.DeletethenodeDfromQUEUE1andinsertall its neighbours.
SinceFis theonlyneighbourofit whichhasbeen inserted,
wewill notinsertit again.InsertnodeDintoQUEUE2.
QUEUE1 = {A}
QUEUE2 = {NULL}
5.DeletethenodeCfromQUEUE1andinsertall its neighbours.
AddnodeCtoQUEUE2.
QUEUE1 = {A}
QUEUE2 = {NULL}
6.RemoveFfromQUEUE1andaddall its neighbours.Sinceall ofits neighbours
hasalready beenadded,wewill notaddthemagain.AddnodeFtoQUEUE2.
QUEUE1 = {A}
QUEUE2 = {NULL}
7. RemoveEfromQUEUE1,all ofE'sneighbourshasalready beenadded to
QUEUE1thereforewewill notaddthemagain.Allthenodesarevisited
andthetarget nodei.e.Eis encounteredintoQUEUE2.
QUEUE1 = {A}
QUEUE2 = {NULL}
Now, backtrack from E to A, using the nodes available in QUEUE2.
The minimum path will be A → B → C → E.
Depth First Search (BFS) Algorithm
Depth first search (DFS) algorithm starts with the initial node of the graph G, and then goes to deeper and deeper until we find
the goal node or the node which has no children. The algorithm, then backtracks from the dead end towards the most recent node
that is yet to be completely unexplored.
Steps :
1. PushHontothe Stack.
QUEUE1 = {A}
QUEUE2 = {NULL}
2.POPthetopelementofthestack i.e. H,printit andpushall the
neighboursofHontothestack that areis ready state.
QUEUE1 = {A}
QUEUE2 = {NULL}
3.Popthetopelementofthestack i.e.A,printit andpushall the
neighboursofAontothestack thatareinready state
QUEUE1 = {A}
QUEUE2 = {NULL}
:4.Popthetopelementofthestack i.e.D,printit andpushall theneighbours
ofDontothestack that areinready state.
QUEUE1 = {A}
QUEUE2 = {NULL}
5.Popthetopelementofthestack i.e.F,printit andpushall theneighbours
ofFontothestack that areinready state.
QUEUE1 = {A}
QUEUE2 = {NULL}
6.Pop the top of the stack i.e.Band pushall the neighbours
QUEUE1 = {A}
QUEUE2 = {NULL}
:
7. Popthetopofthestack i.e.Candpushall theneighbours.
QUEUE1 = {A}
QUEUE2 = {NULL}
8.Popthetopofthestack i.e.Gandpushall its neighbours.
QUEUE1 = {A}
QUEUE2 = {NULL}
9.Pop the top of the stack i.e.Eand pushall its neighbours.
QUEUE1 = {A}
QUEUE2 = {NULL}
Hence, the stack now becomes empty and all the nodes of the graph have been traversed.
The printing sequence of the graph will be :
H → A → D → F → B → C → G → E
Thank You….

More Related Content

What's hot

Ch 1 review stations (Classwork)
Ch 1 review stations (Classwork)Ch 1 review stations (Classwork)
Ch 1 review stations (Classwork)leblance
 
Reading2018 kikuta
Reading2018 kikutaReading2018 kikuta
Reading2018 kikuta
ShumpeiKikuta
 
Dijkstra & flooding ppt(Routing algorithm)
Dijkstra & flooding ppt(Routing algorithm)Dijkstra & flooding ppt(Routing algorithm)
Dijkstra & flooding ppt(Routing algorithm)
Anshul gour
 
13 unsupervised learning clustering
13 unsupervised learning   clustering13 unsupervised learning   clustering
13 unsupervised learning clustering
TanmayVijay1
 
Dijkstra's algorithm
Dijkstra's algorithmDijkstra's algorithm
Dijkstra's algorithmgsp1294
 
Parameters of t SNE
Parameters of t SNEParameters of t SNE
Parameters of t SNE
Ali Madani
 
U6 Cn2 Definite Integrals Intro
U6 Cn2 Definite Integrals IntroU6 Cn2 Definite Integrals Intro
U6 Cn2 Definite Integrals IntroAlexander Burt
 
Transformations
TransformationsTransformations
Transformationsestelav
 
14 dimentionality reduction
14 dimentionality reduction14 dimentionality reduction
14 dimentionality reduction
TanmayVijay1
 
Spanning trees
Spanning treesSpanning trees
Spanning trees
Shareb Ismaeel
 
Boolean Algebra by SUKHDEEP SINGH
Boolean Algebra by SUKHDEEP SINGHBoolean Algebra by SUKHDEEP SINGH
Boolean Algebra by SUKHDEEP SINGHSukhdeep Bisht
 
Module#8 notes
Module#8 notesModule#8 notes
Module#8 notes
REYEMMANUELILUMBA
 
QMC: Operator Splitting Workshop, Behavior of BFGS on Nonsmooth Convex Functi...
QMC: Operator Splitting Workshop, Behavior of BFGS on Nonsmooth Convex Functi...QMC: Operator Splitting Workshop, Behavior of BFGS on Nonsmooth Convex Functi...
QMC: Operator Splitting Workshop, Behavior of BFGS on Nonsmooth Convex Functi...
The Statistical and Applied Mathematical Sciences Institute
 
Dijkstra’s algorithm
Dijkstra’s algorithmDijkstra’s algorithm
Dijkstra’s algorithmfaisal2204
 
KRUSKAL'S algorithm from chaitra
KRUSKAL'S algorithm from chaitraKRUSKAL'S algorithm from chaitra
KRUSKAL'S algorithm from chaitraguest1f4fb3
 
12 support vector machines
12 support vector machines12 support vector machines
12 support vector machines
TanmayVijay1
 
My presentation minimum spanning tree
My presentation minimum spanning treeMy presentation minimum spanning tree
My presentation minimum spanning tree
Alona Salva
 
Minimum spanning tree
Minimum spanning treeMinimum spanning tree
Minimum spanning tree
Hinal Lunagariya
 
Data structure and algorithm
Data structure and algorithmData structure and algorithm
Data structure and algorithm
sakthibalabalamuruga
 
Implementation
ImplementationImplementation
Implementation
Syed Zaid Irshad
 

What's hot (20)

Ch 1 review stations (Classwork)
Ch 1 review stations (Classwork)Ch 1 review stations (Classwork)
Ch 1 review stations (Classwork)
 
Reading2018 kikuta
Reading2018 kikutaReading2018 kikuta
Reading2018 kikuta
 
Dijkstra & flooding ppt(Routing algorithm)
Dijkstra & flooding ppt(Routing algorithm)Dijkstra & flooding ppt(Routing algorithm)
Dijkstra & flooding ppt(Routing algorithm)
 
13 unsupervised learning clustering
13 unsupervised learning   clustering13 unsupervised learning   clustering
13 unsupervised learning clustering
 
Dijkstra's algorithm
Dijkstra's algorithmDijkstra's algorithm
Dijkstra's algorithm
 
Parameters of t SNE
Parameters of t SNEParameters of t SNE
Parameters of t SNE
 
U6 Cn2 Definite Integrals Intro
U6 Cn2 Definite Integrals IntroU6 Cn2 Definite Integrals Intro
U6 Cn2 Definite Integrals Intro
 
Transformations
TransformationsTransformations
Transformations
 
14 dimentionality reduction
14 dimentionality reduction14 dimentionality reduction
14 dimentionality reduction
 
Spanning trees
Spanning treesSpanning trees
Spanning trees
 
Boolean Algebra by SUKHDEEP SINGH
Boolean Algebra by SUKHDEEP SINGHBoolean Algebra by SUKHDEEP SINGH
Boolean Algebra by SUKHDEEP SINGH
 
Module#8 notes
Module#8 notesModule#8 notes
Module#8 notes
 
QMC: Operator Splitting Workshop, Behavior of BFGS on Nonsmooth Convex Functi...
QMC: Operator Splitting Workshop, Behavior of BFGS on Nonsmooth Convex Functi...QMC: Operator Splitting Workshop, Behavior of BFGS on Nonsmooth Convex Functi...
QMC: Operator Splitting Workshop, Behavior of BFGS on Nonsmooth Convex Functi...
 
Dijkstra’s algorithm
Dijkstra’s algorithmDijkstra’s algorithm
Dijkstra’s algorithm
 
KRUSKAL'S algorithm from chaitra
KRUSKAL'S algorithm from chaitraKRUSKAL'S algorithm from chaitra
KRUSKAL'S algorithm from chaitra
 
12 support vector machines
12 support vector machines12 support vector machines
12 support vector machines
 
My presentation minimum spanning tree
My presentation minimum spanning treeMy presentation minimum spanning tree
My presentation minimum spanning tree
 
Minimum spanning tree
Minimum spanning treeMinimum spanning tree
Minimum spanning tree
 
Data structure and algorithm
Data structure and algorithmData structure and algorithm
Data structure and algorithm
 
Implementation
ImplementationImplementation
Implementation
 

Similar to Graph Representation

Graphs
GraphsGraphs
Graph Data Structure
Graph Data StructureGraph Data Structure
Graph Data Structure
Afaq Mansoor Khan
 
Analysis of Pathfinding Algorithms
Analysis of Pathfinding AlgorithmsAnalysis of Pathfinding Algorithms
Analysis of Pathfinding Algorithms
SigSegVSquad
 
Unit-6 Graph.ppsx ppt
Unit-6 Graph.ppsx                                       pptUnit-6 Graph.ppsx                                       ppt
Unit-6 Graph.ppsx ppt
DhruvilSTATUS
 
Lecture 2.3.1 Graph.pptx
Lecture 2.3.1 Graph.pptxLecture 2.3.1 Graph.pptx
Lecture 2.3.1 Graph.pptx
king779879
 
DATA STRUCTURES.pptx
DATA STRUCTURES.pptxDATA STRUCTURES.pptx
DATA STRUCTURES.pptx
KENNEDY GITHAIGA
 
LEC 12-DSALGO-GRAPHS(final12).pdf
LEC 12-DSALGO-GRAPHS(final12).pdfLEC 12-DSALGO-GRAPHS(final12).pdf
LEC 12-DSALGO-GRAPHS(final12).pdf
MuhammadUmerIhtisham
 
Spanningtreesppt
SpanningtreespptSpanningtreesppt
Spanningtreesppt
Jyoshna Cec Cse Staf bejjam
 
Graphs
GraphsGraphs
Graphs
GraphsGraphs
Graphs
PRINCE KUMAR
 
Data structure computer graphs
Data structure computer graphsData structure computer graphs
Data structure computer graphsKumar
 
Data Structures and Agorithm: DS 21 Graph Theory.pptx
Data Structures and Agorithm: DS 21 Graph Theory.pptxData Structures and Agorithm: DS 21 Graph Theory.pptx
Data Structures and Agorithm: DS 21 Graph Theory.pptx
RashidFaridChishti
 
NON-LINEAR DATA STRUCTURE-Graphs.pptx
NON-LINEAR DATA STRUCTURE-Graphs.pptxNON-LINEAR DATA STRUCTURE-Graphs.pptx
NON-LINEAR DATA STRUCTURE-Graphs.pptx
Rajitha Reddy Alugati
 
breadth first search
breadth first searchbreadth first search
breadth first search
DeepikaT13
 
Unit V - ppt.pptx
Unit V - ppt.pptxUnit V - ppt.pptx
Data structure note
Data structure noteData structure note
Data structure note
Muhammad Nawaz
 
Graph in data structures
Graph in data structuresGraph in data structures
Graph in data structures
AhsanRazaKolachi
 

Similar to Graph Representation (20)

Graphs
GraphsGraphs
Graphs
 
Graph Data Structure
Graph Data StructureGraph Data Structure
Graph Data Structure
 
Analysis of Pathfinding Algorithms
Analysis of Pathfinding AlgorithmsAnalysis of Pathfinding Algorithms
Analysis of Pathfinding Algorithms
 
logic.pptx
logic.pptxlogic.pptx
logic.pptx
 
Unit-6 Graph.ppsx ppt
Unit-6 Graph.ppsx                                       pptUnit-6 Graph.ppsx                                       ppt
Unit-6 Graph.ppsx ppt
 
Lecture 2.3.1 Graph.pptx
Lecture 2.3.1 Graph.pptxLecture 2.3.1 Graph.pptx
Lecture 2.3.1 Graph.pptx
 
DATA STRUCTURES.pptx
DATA STRUCTURES.pptxDATA STRUCTURES.pptx
DATA STRUCTURES.pptx
 
LEC 12-DSALGO-GRAPHS(final12).pdf
LEC 12-DSALGO-GRAPHS(final12).pdfLEC 12-DSALGO-GRAPHS(final12).pdf
LEC 12-DSALGO-GRAPHS(final12).pdf
 
Spanningtreesppt
SpanningtreespptSpanningtreesppt
Spanningtreesppt
 
Graphs
GraphsGraphs
Graphs
 
Graphs
GraphsGraphs
Graphs
 
Data structure computer graphs
Data structure computer graphsData structure computer graphs
Data structure computer graphs
 
Data Structures and Agorithm: DS 21 Graph Theory.pptx
Data Structures and Agorithm: DS 21 Graph Theory.pptxData Structures and Agorithm: DS 21 Graph Theory.pptx
Data Structures and Agorithm: DS 21 Graph Theory.pptx
 
NON-LINEAR DATA STRUCTURE-Graphs.pptx
NON-LINEAR DATA STRUCTURE-Graphs.pptxNON-LINEAR DATA STRUCTURE-Graphs.pptx
NON-LINEAR DATA STRUCTURE-Graphs.pptx
 
Spectral graph theory
Spectral graph theorySpectral graph theory
Spectral graph theory
 
breadth first search
breadth first searchbreadth first search
breadth first search
 
26 spanning
26 spanning26 spanning
26 spanning
 
Unit V - ppt.pptx
Unit V - ppt.pptxUnit V - ppt.pptx
Unit V - ppt.pptx
 
Data structure note
Data structure noteData structure note
Data structure note
 
Graph in data structures
Graph in data structuresGraph in data structures
Graph in data structures
 

More from Ramkrishna bhagat

JAVA APPLETS
JAVA APPLETSJAVA APPLETS
JAVA APPLETS
Ramkrishna bhagat
 
Binary search
Binary search Binary search
Binary search
Ramkrishna bhagat
 
DBTG MODEL
DBTG MODELDBTG MODEL
DBTG MODEL
Ramkrishna bhagat
 
IPV6 , ipv6 ,TCP/IP, TCP ,IP
IPV6 , ipv6 ,TCP/IP, TCP ,IPIPV6 , ipv6 ,TCP/IP, TCP ,IP
IPV6 , ipv6 ,TCP/IP, TCP ,IP
Ramkrishna bhagat
 
Data warehouse
Data warehouseData warehouse
Data warehouse
Ramkrishna bhagat
 
22 ramkrishna
22 ramkrishna22 ramkrishna
22 ramkrishna
Ramkrishna bhagat
 
E-Ball Technology
E-Ball TechnologyE-Ball Technology
E-Ball Technology
Ramkrishna bhagat
 

More from Ramkrishna bhagat (7)

JAVA APPLETS
JAVA APPLETSJAVA APPLETS
JAVA APPLETS
 
Binary search
Binary search Binary search
Binary search
 
DBTG MODEL
DBTG MODELDBTG MODEL
DBTG MODEL
 
IPV6 , ipv6 ,TCP/IP, TCP ,IP
IPV6 , ipv6 ,TCP/IP, TCP ,IPIPV6 , ipv6 ,TCP/IP, TCP ,IP
IPV6 , ipv6 ,TCP/IP, TCP ,IP
 
Data warehouse
Data warehouseData warehouse
Data warehouse
 
22 ramkrishna
22 ramkrishna22 ramkrishna
22 ramkrishna
 
E-Ball Technology
E-Ball TechnologyE-Ball Technology
E-Ball Technology
 

Recently uploaded

Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
Welocme to ViralQR, your best QR code generator.
Welocme to ViralQR, your best QR code generator.Welocme to ViralQR, your best QR code generator.
Welocme to ViralQR, your best QR code generator.
ViralQR
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
Vlad Stirbu
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Nexer Digital
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
Peter Spielvogel
 

Recently uploaded (20)

Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Welocme to ViralQR, your best QR code generator.
Welocme to ViralQR, your best QR code generator.Welocme to ViralQR, your best QR code generator.
Welocme to ViralQR, your best QR code generator.
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
 

Graph Representation

  • 3. Introduction A graph can be defined as group of vertices and edges that are used to connect these vertices. A graph can be seen as a cyclic tree, where the vertices (Nodes) maintain any complex relationship among them instead of having parent child relationship.
  • 5. Representations of graph ❖ Sequential Representation ❖ Linked Representation
  • 6. Sequential Representation In sequential representation, we use adjacency matrix to store the mapping represented by vertices and edges. In adjacency matrix, the rows and columns are represented by the graph vertices. A graph having n vertices, will have a dimension n x n.
  • 7.
  • 8. Linked Representation In the linked representation, an adjacency list is used to store the Graph into the computer's memory.
  • 9.
  • 10. Graph Traversal Algorithm ● Breadth First Search ● Depth First Search
  • 11. Breadth First Search (BFS) Algorithm Breadth first search is a graph traversal algorithm that starts traversing the graph from root node and explores all the neighbouring nodes. Then, it selects the nearest node and explore all the unexplored nodes. The algorithm follows the same process for each of the nearest node until it finds the goal.
  • 12. Steps : 1. AddAtoQUEUE1andNULLtoQUEUE2. QUEUE1 = {A} QUEUE2 = {NULL} 2.DeletetheNodeAfromQUEUE1andinsert all its neighbours. InsertNodeAinto QUEUE2 QUEUE1 = {A} QUEUE2 = {NULL} 3.DeletethenodeBfromQUEUE1andinsertall its neighbours. InsertnodeBinto QUEUE2. QUEUE1 = {A} QUEUE2 = {NULL}
  • 13. :4.DeletethenodeDfromQUEUE1andinsertall its neighbours. SinceFis theonlyneighbourofit whichhasbeen inserted, wewill notinsertit again.InsertnodeDintoQUEUE2. QUEUE1 = {A} QUEUE2 = {NULL} 5.DeletethenodeCfromQUEUE1andinsertall its neighbours. AddnodeCtoQUEUE2. QUEUE1 = {A} QUEUE2 = {NULL} 6.RemoveFfromQUEUE1andaddall its neighbours.Sinceall ofits neighbours hasalready beenadded,wewill notaddthemagain.AddnodeFtoQUEUE2. QUEUE1 = {A} QUEUE2 = {NULL}
  • 14. 7. RemoveEfromQUEUE1,all ofE'sneighbourshasalready beenadded to QUEUE1thereforewewill notaddthemagain.Allthenodesarevisited andthetarget nodei.e.Eis encounteredintoQUEUE2. QUEUE1 = {A} QUEUE2 = {NULL} Now, backtrack from E to A, using the nodes available in QUEUE2. The minimum path will be A → B → C → E.
  • 15. Depth First Search (BFS) Algorithm Depth first search (DFS) algorithm starts with the initial node of the graph G, and then goes to deeper and deeper until we find the goal node or the node which has no children. The algorithm, then backtracks from the dead end towards the most recent node that is yet to be completely unexplored.
  • 16. Steps : 1. PushHontothe Stack. QUEUE1 = {A} QUEUE2 = {NULL} 2.POPthetopelementofthestack i.e. H,printit andpushall the neighboursofHontothestack that areis ready state. QUEUE1 = {A} QUEUE2 = {NULL} 3.Popthetopelementofthestack i.e.A,printit andpushall the neighboursofAontothestack thatareinready state QUEUE1 = {A} QUEUE2 = {NULL}
  • 17. :4.Popthetopelementofthestack i.e.D,printit andpushall theneighbours ofDontothestack that areinready state. QUEUE1 = {A} QUEUE2 = {NULL} 5.Popthetopelementofthestack i.e.F,printit andpushall theneighbours ofFontothestack that areinready state. QUEUE1 = {A} QUEUE2 = {NULL} 6.Pop the top of the stack i.e.Band pushall the neighbours QUEUE1 = {A} QUEUE2 = {NULL}
  • 18. : 7. Popthetopofthestack i.e.Candpushall theneighbours. QUEUE1 = {A} QUEUE2 = {NULL} 8.Popthetopofthestack i.e.Gandpushall its neighbours. QUEUE1 = {A} QUEUE2 = {NULL} 9.Pop the top of the stack i.e.Eand pushall its neighbours. QUEUE1 = {A} QUEUE2 = {NULL}
  • 19. Hence, the stack now becomes empty and all the nodes of the graph have been traversed. The printing sequence of the graph will be : H → A → D → F → B → C → G → E