SlideShare ist ein Scribd-Unternehmen logo
1 von 14
Graph & it’s
Algorithms
What is Graph?
• Graph is a non-linear data structure used to
represent the connection between entities.
• consists of vertices and edges.
Types of graph
1) Directed Graph
In a directed graph, edges
have a specific direction.
They represent relationship
where one node points to
another i.e., edges go from
one vertex to another.
2) Undirected Graph
Undirected graphs have
bidirectional edges. They
represent symmetric
relationships, like friendships
on a social networks
Weighted graph
A weight graph is a graph whose edges have
a “weight” or “cost”. The weight of an edge
can represent distance, time, or anything
that models the “connection” between the
pair of nodes it connects.
For example, in the weighted graph below you
can see a blue number next to each edge.
This number is used to represent the weight
of the corresponding edge.
Depth-first Search
Depth-first search is an algorithm for traversing or
searching tree or graph data structures. The algorithm
starts at the root node (selecting some arbitrary node
as the root node in the case of a graph) and explores
as far as possible along each branch before
backtracking.
• Stack data structure is used in DFS.
• Null Stack(after popping values while backtracking) is
the indication to stop traversing.
Breadth-first Search
Also known as level-order traversal.
Starting from the root, all the nodes at a particular level
are visited first and then the nodes of the next level are
traversed till all the nodes are visited.
To do this a queue is used. All the adjacent unvisited
nodes of the current level are pushed into the queue and
the nodes of the current level are marked visited and
popped from the queue.
Dijkstra’s Algorithm:
( Single source shortest path )
● Usage : telephone networks , Google
maps etc
● heart of algorithm : ( Relaxation)
if d(u) + c( u,v) < d(u)
set d(u) = d(u) + c (u,v)
Problem? Loop creation
Solution? Spanning tree
Spanning tree :
A collected sub graph (‘S’) of graph G( v,e) is said to be
spanning if
1. ‘S’ contains all vertices of G
2. ‘S’ contains v -1 number of edges
Kruskal’s algorithm:
To find minimal cost spanning tree.
MST :
it is used to design efficient network with minimal cost.
Procedure :
1. Take one by one edge with lowest cost.
2. Add in spanning tree.
3. Cycle shouldn’t be created.
note : output is connected tree but in between processing
vertices could be isolated.
Prims algorithm:
● To construct MST.
● Number of edges= number of vertices -1.
Procedure
1. Start from a vertex.
2. Check how many vertices are connected to it.
3. Select the one with minimal cost.
NOTE :
Output will be a connected spanning tree at any point of
procedure.
Real life applications of graph

Weitere ähnliche Inhalte

Ähnlich wie Graph in data structures

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
 
Minimum spanning tree (mst)
Minimum spanning tree (mst)Minimum spanning tree (mst)
Minimum spanning tree (mst)Pradeep Behera
 
Unit II_Graph.pptxkgjrekjgiojtoiejhgnltegjte
Unit II_Graph.pptxkgjrekjgiojtoiejhgnltegjteUnit II_Graph.pptxkgjrekjgiojtoiejhgnltegjte
Unit II_Graph.pptxkgjrekjgiojtoiejhgnltegjtepournima055
 
Graph Analyses with Python and NetworkX
Graph Analyses with Python and NetworkXGraph Analyses with Python and NetworkX
Graph Analyses with Python and NetworkXBenjamin Bengfort
 
Graph Data Structure
Graph Data StructureGraph Data Structure
Graph Data StructureKeno benti
 
Lecture 2.3.1 Graph.pptx
Lecture 2.3.1 Graph.pptxLecture 2.3.1 Graph.pptx
Lecture 2.3.1 Graph.pptxking779879
 
Node Path Visualizer Using Shortest Path Algorithms
Node Path Visualizer Using Shortest Path AlgorithmsNode Path Visualizer Using Shortest Path Algorithms
Node Path Visualizer Using Shortest Path AlgorithmsIRJET Journal
 
Lecture 5b graphs and hashing
Lecture 5b graphs and hashingLecture 5b graphs and hashing
Lecture 5b graphs and hashingVictor Palmar
 
Shortest path (Dijkistra's Algorithm) & Spanning Tree (Prim's Algorithm)
Shortest path (Dijkistra's Algorithm) & Spanning Tree (Prim's Algorithm)Shortest path (Dijkistra's Algorithm) & Spanning Tree (Prim's Algorithm)
Shortest path (Dijkistra's Algorithm) & Spanning Tree (Prim's Algorithm)Mohanlal Sukhadia University (MLSU)
 
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
 
VANU no sql ppt.pptx
VANU no sql ppt.pptxVANU no sql ppt.pptx
VANU no sql ppt.pptxMJeyavarthini
 
Graph and Density Based Clustering
Graph and Density Based ClusteringGraph and Density Based Clustering
Graph and Density Based ClusteringAyushAnand105
 
Lecture 14 data structures and algorithms
Lecture 14 data structures and algorithmsLecture 14 data structures and algorithms
Lecture 14 data structures and algorithmsAakash deep Singhal
 

Ähnlich wie Graph in data structures (20)

NON-LINEAR DATA STRUCTURE-Graphs.pptx
NON-LINEAR DATA STRUCTURE-Graphs.pptxNON-LINEAR DATA STRUCTURE-Graphs.pptx
NON-LINEAR DATA STRUCTURE-Graphs.pptx
 
Minimum spanning tree (mst)
Minimum spanning tree (mst)Minimum spanning tree (mst)
Minimum spanning tree (mst)
 
Unit II_Graph.pptxkgjrekjgiojtoiejhgnltegjte
Unit II_Graph.pptxkgjrekjgiojtoiejhgnltegjteUnit II_Graph.pptxkgjrekjgiojtoiejhgnltegjte
Unit II_Graph.pptxkgjrekjgiojtoiejhgnltegjte
 
1 sollins algorithm
1 sollins algorithm1 sollins algorithm
1 sollins algorithm
 
Spanningtreesppt
SpanningtreespptSpanningtreesppt
Spanningtreesppt
 
Graph Analyses with Python and NetworkX
Graph Analyses with Python and NetworkXGraph Analyses with Python and NetworkX
Graph Analyses with Python and NetworkX
 
Graph Data Structure
Graph Data StructureGraph Data Structure
Graph Data Structure
 
Lecture 2.3.1 Graph.pptx
Lecture 2.3.1 Graph.pptxLecture 2.3.1 Graph.pptx
Lecture 2.3.1 Graph.pptx
 
Node Path Visualizer Using Shortest Path Algorithms
Node Path Visualizer Using Shortest Path AlgorithmsNode Path Visualizer Using Shortest Path Algorithms
Node Path Visualizer Using Shortest Path Algorithms
 
Lecture 5b graphs and hashing
Lecture 5b graphs and hashingLecture 5b graphs and hashing
Lecture 5b graphs and hashing
 
Shortest path (Dijkistra's Algorithm) & Spanning Tree (Prim's Algorithm)
Shortest path (Dijkistra's Algorithm) & Spanning Tree (Prim's Algorithm)Shortest path (Dijkistra's Algorithm) & Spanning Tree (Prim's Algorithm)
Shortest path (Dijkistra's Algorithm) & Spanning Tree (Prim's Algorithm)
 
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
 
logic.pptx
logic.pptxlogic.pptx
logic.pptx
 
Data structure note
Data structure noteData structure note
Data structure note
 
Data structure
Data structureData structure
Data structure
 
26 spanning
26 spanning26 spanning
26 spanning
 
Vanmathy no sql
Vanmathy no sql Vanmathy no sql
Vanmathy no sql
 
VANU no sql ppt.pptx
VANU no sql ppt.pptxVANU no sql ppt.pptx
VANU no sql ppt.pptx
 
Graph and Density Based Clustering
Graph and Density Based ClusteringGraph and Density Based Clustering
Graph and Density Based Clustering
 
Lecture 14 data structures and algorithms
Lecture 14 data structures and algorithmsLecture 14 data structures and algorithms
Lecture 14 data structures and algorithms
 

Mehr von AhsanRazaKolachi

Evolution in military technology by ahsan raza
Evolution in military technology by ahsan razaEvolution in military technology by ahsan raza
Evolution in military technology by ahsan razaAhsanRazaKolachi
 
Flags register in central processing unit
Flags register in central processing unitFlags register in central processing unit
Flags register in central processing unitAhsanRazaKolachi
 
what is System Analyst in Software Development
what is System Analyst in Software Developmentwhat is System Analyst in Software Development
what is System Analyst in Software DevelopmentAhsanRazaKolachi
 
Process , Process states , Process Control Block in Operating Systems
Process , Process states , Process Control Block in Operating SystemsProcess , Process states , Process Control Block in Operating Systems
Process , Process states , Process Control Block in Operating SystemsAhsanRazaKolachi
 
Rapid Application Development in Software Engineering
Rapid Application Development in Software EngineeringRapid Application Development in Software Engineering
Rapid Application Development in Software EngineeringAhsanRazaKolachi
 
Index registers in Central Processing Unit
Index registers in Central Processing UnitIndex registers in Central Processing Unit
Index registers in Central Processing UnitAhsanRazaKolachi
 
Data transmission Services in Data Warehouse
Data transmission Services in Data WarehouseData transmission Services in Data Warehouse
Data transmission Services in Data WarehouseAhsanRazaKolachi
 
What is Palindrome in Compiler Design and Tafl
What is Palindrome in Compiler Design and TaflWhat is Palindrome in Compiler Design and Tafl
What is Palindrome in Compiler Design and TaflAhsanRazaKolachi
 
Dynamic Programming Intro in Algorithm Design
Dynamic Programming Intro in Algorithm DesignDynamic Programming Intro in Algorithm Design
Dynamic Programming Intro in Algorithm DesignAhsanRazaKolachi
 
Statistics and Role of statistics in Computer Science
Statistics and Role of statistics in Computer Science Statistics and Role of statistics in Computer Science
Statistics and Role of statistics in Computer Science AhsanRazaKolachi
 
Radio Waves In Computer Communication
Radio Waves In Computer Communication Radio Waves In Computer Communication
Radio Waves In Computer Communication AhsanRazaKolachi
 

Mehr von AhsanRazaKolachi (15)

Evolution in military technology by ahsan raza
Evolution in military technology by ahsan razaEvolution in military technology by ahsan raza
Evolution in military technology by ahsan raza
 
Flags register in central processing unit
Flags register in central processing unitFlags register in central processing unit
Flags register in central processing unit
 
what is System Analyst in Software Development
what is System Analyst in Software Developmentwhat is System Analyst in Software Development
what is System Analyst in Software Development
 
Process , Process states , Process Control Block in Operating Systems
Process , Process states , Process Control Block in Operating SystemsProcess , Process states , Process Control Block in Operating Systems
Process , Process states , Process Control Block in Operating Systems
 
Rapid Application Development in Software Engineering
Rapid Application Development in Software EngineeringRapid Application Development in Software Engineering
Rapid Application Development in Software Engineering
 
Index registers in Central Processing Unit
Index registers in Central Processing UnitIndex registers in Central Processing Unit
Index registers in Central Processing Unit
 
Data transmission Services in Data Warehouse
Data transmission Services in Data WarehouseData transmission Services in Data Warehouse
Data transmission Services in Data Warehouse
 
What is Palindrome in Compiler Design and Tafl
What is Palindrome in Compiler Design and TaflWhat is Palindrome in Compiler Design and Tafl
What is Palindrome in Compiler Design and Tafl
 
Information Technology
Information Technology Information Technology
Information Technology
 
MongoDB
MongoDB MongoDB
MongoDB
 
Nelsen ten Heuristics
Nelsen ten HeuristicsNelsen ten Heuristics
Nelsen ten Heuristics
 
two wordpress plugins
two wordpress pluginstwo wordpress plugins
two wordpress plugins
 
Dynamic Programming Intro in Algorithm Design
Dynamic Programming Intro in Algorithm DesignDynamic Programming Intro in Algorithm Design
Dynamic Programming Intro in Algorithm Design
 
Statistics and Role of statistics in Computer Science
Statistics and Role of statistics in Computer Science Statistics and Role of statistics in Computer Science
Statistics and Role of statistics in Computer Science
 
Radio Waves In Computer Communication
Radio Waves In Computer Communication Radio Waves In Computer Communication
Radio Waves In Computer Communication
 

Kürzlich hochgeladen

Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 

Kürzlich hochgeladen (20)

Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 

Graph in data structures

  • 2. What is Graph? • Graph is a non-linear data structure used to represent the connection between entities. • consists of vertices and edges.
  • 3. Types of graph 1) Directed Graph In a directed graph, edges have a specific direction. They represent relationship where one node points to another i.e., edges go from one vertex to another. 2) Undirected Graph Undirected graphs have bidirectional edges. They represent symmetric relationships, like friendships on a social networks
  • 4.
  • 5. Weighted graph A weight graph is a graph whose edges have a “weight” or “cost”. The weight of an edge can represent distance, time, or anything that models the “connection” between the pair of nodes it connects. For example, in the weighted graph below you can see a blue number next to each edge. This number is used to represent the weight of the corresponding edge.
  • 6. Depth-first Search Depth-first search is an algorithm for traversing or searching tree or graph data structures. The algorithm starts at the root node (selecting some arbitrary node as the root node in the case of a graph) and explores as far as possible along each branch before backtracking. • Stack data structure is used in DFS. • Null Stack(after popping values while backtracking) is the indication to stop traversing.
  • 7.
  • 8. Breadth-first Search Also known as level-order traversal. Starting from the root, all the nodes at a particular level are visited first and then the nodes of the next level are traversed till all the nodes are visited. To do this a queue is used. All the adjacent unvisited nodes of the current level are pushed into the queue and the nodes of the current level are marked visited and popped from the queue.
  • 9.
  • 10. Dijkstra’s Algorithm: ( Single source shortest path ) ● Usage : telephone networks , Google maps etc ● heart of algorithm : ( Relaxation) if d(u) + c( u,v) < d(u) set d(u) = d(u) + c (u,v)
  • 11. Problem? Loop creation Solution? Spanning tree Spanning tree : A collected sub graph (‘S’) of graph G( v,e) is said to be spanning if 1. ‘S’ contains all vertices of G 2. ‘S’ contains v -1 number of edges
  • 12. Kruskal’s algorithm: To find minimal cost spanning tree. MST : it is used to design efficient network with minimal cost. Procedure : 1. Take one by one edge with lowest cost. 2. Add in spanning tree. 3. Cycle shouldn’t be created. note : output is connected tree but in between processing vertices could be isolated.
  • 13. Prims algorithm: ● To construct MST. ● Number of edges= number of vertices -1. Procedure 1. Start from a vertex. 2. Check how many vertices are connected to it. 3. Select the one with minimal cost. NOTE : Output will be a connected spanning tree at any point of procedure.