SlideShare a Scribd company logo
1 of 35
BY
B.SAKTHIBALA
I .MSC(cs)
 The single-source shortest path problem, in
which we have to find shortest paths from
a source vertex v to all other vertices in the
graph. The single-destination shortest
path problem, in which we have to
find shortest paths from all vertices in the
directed graph to a single destination vertex v.
 With this mapping, we can print the nodes on
the shortest path as follows:
 Depth-First Search (DFS) This is probably the
simplest algorithm to get the shortest path. ...
 Breadth-First Search (BFS) ...
 Bidirectional Search. ...
 Dijkstra's Algorithm. ...
 Bellman-Ford Algorithm.
 Algorithm to find the shortest path between
two vertices in an undirected graph
 Input the graph.
 Input the source and destination nodes.
 Find the paths between the source and the
destination nodes.
 Find the number of edges in all the paths and
return the path having the minimum number
of edges.
 DFS does not necessarily yield shortest
paths in an undirected graph. ... If you try to
find the shortest path from one node to
another using DFS, then you will get the
wrong answer unless you follow the edge
directly connecting the start and destination
nodes.ss
 DFS algorithm
 A standard DFS implementation puts each vertex of the graph into one of
two categories:
 Visited
 Not Visited
 The purpose of the algorithm is to mark each vertex as visited while
avoiding cycles.
 The DFS algorithm works as follows:
 Start by putting any one of the graph's vertices on top of a
stack.
 Take the top item of the stack and add it to the visited list.
 Create a list of that vertex's adjacent nodes. Add the ones
which aren't in the visited list to the top of the stack.
 Keep repeating steps 2 and 3 until the stack is empty.
 DFS(G, u)
 u.visited = true
 for each v ∈ G.Adj[u]
 if v.visited == false
 DFS(G,v) init()
 {
 For each u ∈ G
 u.visited = false
 For each u ∈ G
 DFS(G, u)
 }
 Given a unweighted graph, a source and
a destination, we need to find shortest
path from source to destination in the
graph in most optimal way.
 The algorithm we are going to use to
determine the shortest path is called
“Dijkstra's algorithm.” Dijkstra's
algorithm is an iterative algorithm that
provides us with the shortest path from
one particular starting node to all other
nodes in the graph. ... When a vertex is
first created dist is set to a very large
number.
 Dijkstra's algorithm keeps two sets of
vertices:
 S the set of vertices whose shortest paths from
the source have already been determined and
 V-S the remaining vertices.The other data
structures needed are:
 D array of best estimates of shortest path to
each vertex
 Pi an array of predecessors for each vertex
 initialise_single_source( Graph g, Node s )
 for each vertex v in Vertices( g )
 g.d[v] := infinity
 g.pi[v] := nil
 g.d[s] := 0;
 A negative cycle is one in which the overall
sum of the cycle comes negative.
 Negative weights are found in various
applications of graphs. For example, instead of
paying cost for a path, we may get some
advantage if we follow the path
 Input : 4 4
 0 1 1
 1 2 -1
 2 3 -1
 3 0 -1
 Output : Yes
 A cyclic graph is a directed graph which
contains a path from at least one node back to
itself. In simple terms cyclic graphs contain a
cycle. An acyclic graph is a
directed graph which contains absolutely no
cycle, that is no node can be traversed back to
itself.
 To test a graph for being acyclic:
 If the graph has no nodes, stop. The graph is
acyclic.
 If the graph has no leaf, stop. The graph is cyclic.
 Choose a leaf of the graph. ...
 Go to 1.
 If the Graph has no nodes, stop. ...
 If the graph has no leaf, stop. ...
 Choose a leaf of Graph. ...
 Go to 1.
 The all pair shortest path algorithm is also
known as Floyd-Warshall algorithm is used to
find all pair shortest path problem from a
given weighted graph. As a result of
this algorithm, it will generate a matrix, which
will represent the minimum distance from any
node to all other nodes in the graph.
 Input − The cost matrix of the graph.
 0 3 6 ∞ ∞ ∞
 ∞ 3 0 2 1 ∞
 ∞ ∞ 6 2 0 1
 4 2 ∞ ∞ 1 1
 0 2 ∞ 4 ∞ ∞
 4 2 0 2 1 ∞
 ∞ 2 ∞ 2 0 1
 s ∞ ∞ ∞ 4 1 1 0
 Output − Matrix of all pair shortest path.
 0 3 4 5 6 7 7
 3 0 2 1 3 4 4
 4 2 0 1 3 2 3
 5 1 1 0 2 3 3
 6 3 3 2 0 2 1
 7 4 2 3 2 0 1
 s7 4 3 3 1 1 0
 In graph theory, the shortest path problem is
the problem of finding a path between two
vertices (or nodes) in a graph such that the sum
of the weights of its constituent edges is
minimized.
 single-Pair Shortest Path Problem-

 It is a shortest path problem where the shortest
path between a given pair of vertices is
computed.
 A* Search Algorithm is a famous algorithm
used for solving single-pair shortest path
problem.

 Minimum Spanning Tree (MST)
 In a weighted graph, a minimum spanning tree
is a spanning tree that has minimum weight
than all other spanning trees of the same graph.
In real-world situations, this weight can be
measured as distance, congestion, traffic load
or any arbitrary value denoted to the edges.
 Minimum Spanning-Tree Algorithm
 We shall learn about two most important
spanning tree algorithms here −
 Kruskal's Algorithm
 Prim's Algorithm
 General Properties of Spanning
Tree
 We now understand that one graph can have more than one
spanning tree. Following are a few properties of the
spanning tree connected to graph G −
 A connected graph G can have more than one spanning tree.
 All possible spanning trees of graph G, have the same
number of edges and vertices.
 The spanning tree does not have any cycle (loops).
 Removing one edge from the spanning tree will make the
graph disconnected, i.e. the spanning tree is minimally
connected.
 Adding one edge to the spanning tree will create a circuit or
loop, i.e. the spanning tree is maximally acyclic.
 Mathematical Properties of
Spanning Tree
 Spanning tree has n-1 edges, where n is the
number of nodes (vertices).
 From a complete graph, by removing maximum e -
n + 1 edges, we can construct a spanning tree.
 A complete graph can have maximum nn-2 number
of spanning trees.
 Thus, we can conclude that spanning trees are a
subset of connected Graph G and disconnected
graphs do not have spanning tree.
 Application of Spanning Tree
 Spanning tree is basically used to find a
minimum path to connect all nodes in a graph.
Common application of spanning trees are −
 Civil Network Planning
 Computer Network Routing Protocol
 Cluster Analysis
 THANKING YOU

More Related Content

What's hot

All pairs shortest path algorithm
All pairs shortest path algorithmAll pairs shortest path algorithm
All pairs shortest path algorithmSrikrishnan Suresh
 
Dijkstra's algorithm
Dijkstra's algorithmDijkstra's algorithm
Dijkstra's algorithmgsp1294
 
Prim's Algorithm on minimum spanning tree
Prim's Algorithm on minimum spanning treePrim's Algorithm on minimum spanning tree
Prim's Algorithm on minimum spanning treeoneous
 
Dijkstra's Algorithm
Dijkstra's AlgorithmDijkstra's Algorithm
Dijkstra's AlgorithmArijitDhali
 
Discrete Mathematics Presentation
Discrete Mathematics PresentationDiscrete Mathematics Presentation
Discrete Mathematics PresentationSalman Elahi
 
Dijkstra's algorithm presentation
Dijkstra's algorithm presentationDijkstra's algorithm presentation
Dijkstra's algorithm presentationSubid Biswas
 
Biconnected components (13024116056)
Biconnected components (13024116056)Biconnected components (13024116056)
Biconnected components (13024116056)Akshay soni
 
Shortest path algorithm
Shortest path algorithmShortest path algorithm
Shortest path algorithmsana younas
 
Shortest path search for real road networks and dynamic costs with pgRouting
Shortest path search for real road networks and dynamic costs with pgRoutingShortest path search for real road networks and dynamic costs with pgRouting
Shortest path search for real road networks and dynamic costs with pgRoutingantonpa
 
KRUSKAL'S algorithm from chaitra
KRUSKAL'S algorithm from chaitraKRUSKAL'S algorithm from chaitra
KRUSKAL'S algorithm from chaitraguest1f4fb3
 
Graph Algorithms
Graph AlgorithmsGraph Algorithms
Graph AlgorithmsAshwin Shiv
 
Dijkstra s algorithm
Dijkstra s algorithmDijkstra s algorithm
Dijkstra s algorithmmansab MIRZA
 
Minimal spanning tree class 15
Minimal spanning tree class 15Minimal spanning tree class 15
Minimal spanning tree class 15Kumar
 
Minimum spanning tree
Minimum spanning treeMinimum spanning tree
Minimum spanning treeSTEFFY D
 

What's hot (19)

All pairs shortest path algorithm
All pairs shortest path algorithmAll pairs shortest path algorithm
All pairs shortest path algorithm
 
Dijkstra's algorithm
Dijkstra's algorithmDijkstra's algorithm
Dijkstra's algorithm
 
Prim's Algorithm on minimum spanning tree
Prim's Algorithm on minimum spanning treePrim's Algorithm on minimum spanning tree
Prim's Algorithm on minimum spanning tree
 
Dijkstra's Algorithm
Dijkstra's AlgorithmDijkstra's Algorithm
Dijkstra's Algorithm
 
(floyd's algm)
(floyd's algm)(floyd's algm)
(floyd's algm)
 
Discrete Mathematics Presentation
Discrete Mathematics PresentationDiscrete Mathematics Presentation
Discrete Mathematics Presentation
 
Dijkstra's algorithm presentation
Dijkstra's algorithm presentationDijkstra's algorithm presentation
Dijkstra's algorithm presentation
 
Dijkstra's Algorithm
Dijkstra's Algorithm Dijkstra's Algorithm
Dijkstra's Algorithm
 
Biconnected components (13024116056)
Biconnected components (13024116056)Biconnected components (13024116056)
Biconnected components (13024116056)
 
Shortest path algorithm
Shortest path algorithmShortest path algorithm
Shortest path algorithm
 
Shortest path search for real road networks and dynamic costs with pgRouting
Shortest path search for real road networks and dynamic costs with pgRoutingShortest path search for real road networks and dynamic costs with pgRouting
Shortest path search for real road networks and dynamic costs with pgRouting
 
KRUSKAL'S algorithm from chaitra
KRUSKAL'S algorithm from chaitraKRUSKAL'S algorithm from chaitra
KRUSKAL'S algorithm from chaitra
 
Graph Algorithms
Graph AlgorithmsGraph Algorithms
Graph Algorithms
 
Dijkstra s algorithm
Dijkstra s algorithmDijkstra s algorithm
Dijkstra s algorithm
 
Shortest Path in Graph
Shortest Path in GraphShortest Path in Graph
Shortest Path in Graph
 
Minimal spanning tree class 15
Minimal spanning tree class 15Minimal spanning tree class 15
Minimal spanning tree class 15
 
Shortest path
Shortest pathShortest path
Shortest path
 
Shortest Path Problem
Shortest Path ProblemShortest Path Problem
Shortest Path Problem
 
Minimum spanning tree
Minimum spanning treeMinimum spanning tree
Minimum spanning tree
 

Similar to Data structure and algorithm

Shortest path by using suitable algorithm.pdf
Shortest path by using suitable algorithm.pdfShortest path by using suitable algorithm.pdf
Shortest path by using suitable algorithm.pdfzefergaming
 
Graph_data_structure_information_engineering.pptx
Graph_data_structure_information_engineering.pptxGraph_data_structure_information_engineering.pptx
Graph_data_structure_information_engineering.pptxsahilpawar2426
 
APznzaZLM_MVouyxM4cxHPJR5BC-TAxTWqhQJ2EywQQuXStxJTDoGkHdsKEQGd4Vo7BS3Q1npCOMV...
APznzaZLM_MVouyxM4cxHPJR5BC-TAxTWqhQJ2EywQQuXStxJTDoGkHdsKEQGd4Vo7BS3Q1npCOMV...APznzaZLM_MVouyxM4cxHPJR5BC-TAxTWqhQJ2EywQQuXStxJTDoGkHdsKEQGd4Vo7BS3Q1npCOMV...
APznzaZLM_MVouyxM4cxHPJR5BC-TAxTWqhQJ2EywQQuXStxJTDoGkHdsKEQGd4Vo7BS3Q1npCOMV...KUSHDHIRRA2111026030
 
A study on_contrast_and_comparison_between_bellman-ford_algorithm_and_dijkstr...
A study on_contrast_and_comparison_between_bellman-ford_algorithm_and_dijkstr...A study on_contrast_and_comparison_between_bellman-ford_algorithm_and_dijkstr...
A study on_contrast_and_comparison_between_bellman-ford_algorithm_and_dijkstr...Khoa Mac Tu
 
shortestpathalgorithm-180109112405 (1).pdf
shortestpathalgorithm-180109112405 (1).pdfshortestpathalgorithm-180109112405 (1).pdf
shortestpathalgorithm-180109112405 (1).pdfzefergaming
 
Graph terminology and algorithm and tree.pptx
Graph terminology and algorithm and tree.pptxGraph terminology and algorithm and tree.pptx
Graph terminology and algorithm and tree.pptxasimshahzad8611
 
Chap10 slides
Chap10 slidesChap10 slides
Chap10 slidesHJ DS
 
prim's and kruskal's algorithm
prim's and kruskal's algorithmprim's and kruskal's algorithm
prim's and kruskal's algorithmshreeuva
 
GRAPH - DISCRETE STRUCTURE AND ALGORITHM
GRAPH - DISCRETE STRUCTURE AND ALGORITHMGRAPH - DISCRETE STRUCTURE AND ALGORITHM
GRAPH - DISCRETE STRUCTURE AND ALGORITHMhimanshumishra19dec
 

Similar to Data structure and algorithm (20)

DAA_Presentation - Copy.pptx
DAA_Presentation - Copy.pptxDAA_Presentation - Copy.pptx
DAA_Presentation - Copy.pptx
 
logic.pptx
logic.pptxlogic.pptx
logic.pptx
 
DATA STRUCTURES.pptx
DATA STRUCTURES.pptxDATA STRUCTURES.pptx
DATA STRUCTURES.pptx
 
Graphs
GraphsGraphs
Graphs
 
Shortest path by using suitable algorithm.pdf
Shortest path by using suitable algorithm.pdfShortest path by using suitable algorithm.pdf
Shortest path by using suitable algorithm.pdf
 
Graph_data_structure_information_engineering.pptx
Graph_data_structure_information_engineering.pptxGraph_data_structure_information_engineering.pptx
Graph_data_structure_information_engineering.pptx
 
APznzaZLM_MVouyxM4cxHPJR5BC-TAxTWqhQJ2EywQQuXStxJTDoGkHdsKEQGd4Vo7BS3Q1npCOMV...
APznzaZLM_MVouyxM4cxHPJR5BC-TAxTWqhQJ2EywQQuXStxJTDoGkHdsKEQGd4Vo7BS3Q1npCOMV...APznzaZLM_MVouyxM4cxHPJR5BC-TAxTWqhQJ2EywQQuXStxJTDoGkHdsKEQGd4Vo7BS3Q1npCOMV...
APznzaZLM_MVouyxM4cxHPJR5BC-TAxTWqhQJ2EywQQuXStxJTDoGkHdsKEQGd4Vo7BS3Q1npCOMV...
 
A study on_contrast_and_comparison_between_bellman-ford_algorithm_and_dijkstr...
A study on_contrast_and_comparison_between_bellman-ford_algorithm_and_dijkstr...A study on_contrast_and_comparison_between_bellman-ford_algorithm_and_dijkstr...
A study on_contrast_and_comparison_between_bellman-ford_algorithm_and_dijkstr...
 
Unit ix graph
Unit   ix    graph Unit   ix    graph
Unit ix graph
 
Unit V - ppt.pptx
Unit V - ppt.pptxUnit V - ppt.pptx
Unit V - ppt.pptx
 
Unit 9 graph
Unit   9 graphUnit   9 graph
Unit 9 graph
 
shortestpathalgorithm-180109112405 (1).pdf
shortestpathalgorithm-180109112405 (1).pdfshortestpathalgorithm-180109112405 (1).pdf
shortestpathalgorithm-180109112405 (1).pdf
 
1 sollins algorithm
1 sollins algorithm1 sollins algorithm
1 sollins algorithm
 
Weighted graphs
Weighted graphsWeighted graphs
Weighted graphs
 
UNIT III.pptx
UNIT III.pptxUNIT III.pptx
UNIT III.pptx
 
Graph terminology and algorithm and tree.pptx
Graph terminology and algorithm and tree.pptxGraph terminology and algorithm and tree.pptx
Graph terminology and algorithm and tree.pptx
 
Chap10 slides
Chap10 slidesChap10 slides
Chap10 slides
 
prim's and kruskal's algorithm
prim's and kruskal's algorithmprim's and kruskal's algorithm
prim's and kruskal's algorithm
 
GRAPH - DISCRETE STRUCTURE AND ALGORITHM
GRAPH - DISCRETE STRUCTURE AND ALGORITHMGRAPH - DISCRETE STRUCTURE AND ALGORITHM
GRAPH - DISCRETE STRUCTURE AND ALGORITHM
 
Data structure note
Data structure noteData structure note
Data structure note
 

More from sakthibalabalamuruga (14)

Software engineering
Software engineeringSoftware engineering
Software engineering
 
Software engineering
Software  engineeringSoftware  engineering
Software engineering
 
web programming
web programmingweb programming
web programming
 
compiler design
compiler designcompiler design
compiler design
 
Bigdata
BigdataBigdata
Bigdata
 
Os
OsOs
Os
 
Apache mahout and R-mining complex dataobject
Apache mahout and R-mining complex dataobjectApache mahout and R-mining complex dataobject
Apache mahout and R-mining complex dataobject
 
Computer network
Computer networkComputer network
Computer network
 
Operating system
Operating systemOperating system
Operating system
 
Rdbms
RdbmsRdbms
Rdbms
 
Rdbms
RdbmsRdbms
Rdbms
 
Rdbms
RdbmsRdbms
Rdbms
 
Encoding
EncodingEncoding
Encoding
 
Remote method invocatiom
Remote method invocatiomRemote method invocatiom
Remote method invocatiom
 

Recently uploaded

Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYKayeClaireEstoconing
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptxmary850239
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxChelloAnnAsuncion2
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 

Recently uploaded (20)

Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
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
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
 
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptxYOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 

Data structure and algorithm

  • 2.  The single-source shortest path problem, in which we have to find shortest paths from a source vertex v to all other vertices in the graph. The single-destination shortest path problem, in which we have to find shortest paths from all vertices in the directed graph to a single destination vertex v.
  • 3.
  • 4.  With this mapping, we can print the nodes on the shortest path as follows:  Depth-First Search (DFS) This is probably the simplest algorithm to get the shortest path. ...  Breadth-First Search (BFS) ...  Bidirectional Search. ...  Dijkstra's Algorithm. ...  Bellman-Ford Algorithm.
  • 5.  Algorithm to find the shortest path between two vertices in an undirected graph  Input the graph.  Input the source and destination nodes.  Find the paths between the source and the destination nodes.  Find the number of edges in all the paths and return the path having the minimum number of edges.
  • 6.  DFS does not necessarily yield shortest paths in an undirected graph. ... If you try to find the shortest path from one node to another using DFS, then you will get the wrong answer unless you follow the edge directly connecting the start and destination nodes.ss
  • 7.  DFS algorithm  A standard DFS implementation puts each vertex of the graph into one of two categories:  Visited  Not Visited  The purpose of the algorithm is to mark each vertex as visited while avoiding cycles.  The DFS algorithm works as follows:  Start by putting any one of the graph's vertices on top of a stack.  Take the top item of the stack and add it to the visited list.  Create a list of that vertex's adjacent nodes. Add the ones which aren't in the visited list to the top of the stack.  Keep repeating steps 2 and 3 until the stack is empty.
  • 8.  DFS(G, u)  u.visited = true  for each v ∈ G.Adj[u]  if v.visited == false  DFS(G,v) init()  {  For each u ∈ G  u.visited = false  For each u ∈ G  DFS(G, u)  }
  • 9.  Given a unweighted graph, a source and a destination, we need to find shortest path from source to destination in the graph in most optimal way.
  • 10.
  • 11.  The algorithm we are going to use to determine the shortest path is called “Dijkstra's algorithm.” Dijkstra's algorithm is an iterative algorithm that provides us with the shortest path from one particular starting node to all other nodes in the graph. ... When a vertex is first created dist is set to a very large number.
  • 12.  Dijkstra's algorithm keeps two sets of vertices:  S the set of vertices whose shortest paths from the source have already been determined and  V-S the remaining vertices.The other data structures needed are:  D array of best estimates of shortest path to each vertex  Pi an array of predecessors for each vertex
  • 13.  initialise_single_source( Graph g, Node s )  for each vertex v in Vertices( g )  g.d[v] := infinity  g.pi[v] := nil  g.d[s] := 0;
  • 14.
  • 15.  A negative cycle is one in which the overall sum of the cycle comes negative.  Negative weights are found in various applications of graphs. For example, instead of paying cost for a path, we may get some advantage if we follow the path
  • 16.
  • 17.  Input : 4 4  0 1 1  1 2 -1  2 3 -1  3 0 -1  Output : Yes
  • 18.
  • 19.  A cyclic graph is a directed graph which contains a path from at least one node back to itself. In simple terms cyclic graphs contain a cycle. An acyclic graph is a directed graph which contains absolutely no cycle, that is no node can be traversed back to itself.
  • 20.
  • 21.  To test a graph for being acyclic:  If the graph has no nodes, stop. The graph is acyclic.  If the graph has no leaf, stop. The graph is cyclic.  Choose a leaf of the graph. ...  Go to 1.  If the Graph has no nodes, stop. ...  If the graph has no leaf, stop. ...  Choose a leaf of Graph. ...  Go to 1.
  • 22.  The all pair shortest path algorithm is also known as Floyd-Warshall algorithm is used to find all pair shortest path problem from a given weighted graph. As a result of this algorithm, it will generate a matrix, which will represent the minimum distance from any node to all other nodes in the graph.
  • 23.
  • 24.  Input − The cost matrix of the graph.  0 3 6 ∞ ∞ ∞  ∞ 3 0 2 1 ∞  ∞ ∞ 6 2 0 1  4 2 ∞ ∞ 1 1  0 2 ∞ 4 ∞ ∞  4 2 0 2 1 ∞  ∞ 2 ∞ 2 0 1  s ∞ ∞ ∞ 4 1 1 0
  • 25.  Output − Matrix of all pair shortest path.  0 3 4 5 6 7 7  3 0 2 1 3 4 4  4 2 0 1 3 2 3  5 1 1 0 2 3 3  6 3 3 2 0 2 1  7 4 2 3 2 0 1  s7 4 3 3 1 1 0
  • 26.  In graph theory, the shortest path problem is the problem of finding a path between two vertices (or nodes) in a graph such that the sum of the weights of its constituent edges is minimized.
  • 27.
  • 28.  single-Pair Shortest Path Problem-   It is a shortest path problem where the shortest path between a given pair of vertices is computed.  A* Search Algorithm is a famous algorithm used for solving single-pair shortest path problem. 
  • 29.  Minimum Spanning Tree (MST)  In a weighted graph, a minimum spanning tree is a spanning tree that has minimum weight than all other spanning trees of the same graph. In real-world situations, this weight can be measured as distance, congestion, traffic load or any arbitrary value denoted to the edges.
  • 30.  Minimum Spanning-Tree Algorithm  We shall learn about two most important spanning tree algorithms here −  Kruskal's Algorithm  Prim's Algorithm
  • 31.
  • 32.  General Properties of Spanning Tree  We now understand that one graph can have more than one spanning tree. Following are a few properties of the spanning tree connected to graph G −  A connected graph G can have more than one spanning tree.  All possible spanning trees of graph G, have the same number of edges and vertices.  The spanning tree does not have any cycle (loops).  Removing one edge from the spanning tree will make the graph disconnected, i.e. the spanning tree is minimally connected.  Adding one edge to the spanning tree will create a circuit or loop, i.e. the spanning tree is maximally acyclic.
  • 33.  Mathematical Properties of Spanning Tree  Spanning tree has n-1 edges, where n is the number of nodes (vertices).  From a complete graph, by removing maximum e - n + 1 edges, we can construct a spanning tree.  A complete graph can have maximum nn-2 number of spanning trees.  Thus, we can conclude that spanning trees are a subset of connected Graph G and disconnected graphs do not have spanning tree.
  • 34.  Application of Spanning Tree  Spanning tree is basically used to find a minimum path to connect all nodes in a graph. Common application of spanning trees are −  Civil Network Planning  Computer Network Routing Protocol  Cluster Analysis