Submit Search
Upload
8. Graph - Data Structures using C++ by Varsha Patil
•
Download as PPTX, PDF
•
11 likes
•
3,290 views
W
widespreadpromotion
Follow
8. Graph - Data Structures using C++ by Varsha Patil
Read less
Read more
Data & Analytics
Report
Share
Report
Share
1 of 34
Download now
Recommended
UNIT I LINEAR DATA STRUCTURES – LIST
UNIT I LINEAR DATA STRUCTURES – LIST
Kathirvel Ayyaswamy
Data structure - Graph
Data structure - Graph
Madhu Bala
Regular expression to NFA (Nondeterministic Finite Automata)
Regular expression to NFA (Nondeterministic Finite Automata)
Niloy Biswas
Graphs data structures
Graphs data structures
Jasleen Kaur (Chandigarh University)
Tree and graph
Tree and graph
Muhaiminul Islam
14. Files - Data Structures using C++ by Varsha Patil
14. Files - Data Structures using C++ by Varsha Patil
widespreadpromotion
Algorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to Algorithms
Mohamed Loey
Lec 17 heap data structure
Lec 17 heap data structure
Sajid Marwat
Recommended
UNIT I LINEAR DATA STRUCTURES – LIST
UNIT I LINEAR DATA STRUCTURES – LIST
Kathirvel Ayyaswamy
Data structure - Graph
Data structure - Graph
Madhu Bala
Regular expression to NFA (Nondeterministic Finite Automata)
Regular expression to NFA (Nondeterministic Finite Automata)
Niloy Biswas
Graphs data structures
Graphs data structures
Jasleen Kaur (Chandigarh University)
Tree and graph
Tree and graph
Muhaiminul Islam
14. Files - Data Structures using C++ by Varsha Patil
14. Files - Data Structures using C++ by Varsha Patil
widespreadpromotion
Algorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to Algorithms
Mohamed Loey
Lec 17 heap data structure
Lec 17 heap data structure
Sajid Marwat
B+ tree intro,uses,insertion and deletion
B+ tree intro,uses,insertion and deletion
HAMID-50
Analysis of algorithm
Analysis of algorithm
Rajendra Dangwal
UNIT II LINEAR DATA STRUCTURES – STACKS, QUEUES
UNIT II LINEAR DATA STRUCTURES – STACKS, QUEUES
Kathirvel Ayyaswamy
Algorithms Lecture 2: Analysis of Algorithms I
Algorithms Lecture 2: Analysis of Algorithms I
Mohamed Loey
Dinive conquer algorithm
Dinive conquer algorithm
Mohd Arif
Data Structures
Data Structures
Prof. Dr. K. Adisesha
Graph in data structure
Graph in data structure
Abrish06
Graph data structure and algorithms
Graph data structure and algorithms
Anandhasilambarasan D
Sparse matrix and its representation data structure
Sparse matrix and its representation data structure
Vardhil Patel
Design and Analysis of Algorithms
Design and Analysis of Algorithms
Arvind Krishnaa
Graph coloring using backtracking
Graph coloring using backtracking
shashidharPapishetty
Adjacency And Incidence Matrix
Adjacency And Incidence Matrix
Abir Junayed
Abstract Data Types
Abstract Data Types
karthikeyanC40
DFS & BFS Graph
DFS & BFS Graph
Mahfuzul Yamin
Lexical Analysis
Lexical Analysis
Munni28
Unit 1 polynomial manipulation
Unit 1 polynomial manipulation
LavanyaJ28
Elementary data organisation
Elementary data organisation
Muzamil Hussain
Trees data structure
Trees data structure
Sumit Gupta
linked list in data structure
linked list in data structure
shameen khan
Data Structures with C Linked List
Data Structures with C Linked List
Reazul Islam
7. Tree - Data Structures using C++ by Varsha Patil
7. Tree - Data Structures using C++ by Varsha Patil
widespreadpromotion
5. Queue - Data Structures using C++ by Varsha Patil
5. Queue - Data Structures using C++ by Varsha Patil
widespreadpromotion
More Related Content
What's hot
B+ tree intro,uses,insertion and deletion
B+ tree intro,uses,insertion and deletion
HAMID-50
Analysis of algorithm
Analysis of algorithm
Rajendra Dangwal
UNIT II LINEAR DATA STRUCTURES – STACKS, QUEUES
UNIT II LINEAR DATA STRUCTURES – STACKS, QUEUES
Kathirvel Ayyaswamy
Algorithms Lecture 2: Analysis of Algorithms I
Algorithms Lecture 2: Analysis of Algorithms I
Mohamed Loey
Dinive conquer algorithm
Dinive conquer algorithm
Mohd Arif
Data Structures
Data Structures
Prof. Dr. K. Adisesha
Graph in data structure
Graph in data structure
Abrish06
Graph data structure and algorithms
Graph data structure and algorithms
Anandhasilambarasan D
Sparse matrix and its representation data structure
Sparse matrix and its representation data structure
Vardhil Patel
Design and Analysis of Algorithms
Design and Analysis of Algorithms
Arvind Krishnaa
Graph coloring using backtracking
Graph coloring using backtracking
shashidharPapishetty
Adjacency And Incidence Matrix
Adjacency And Incidence Matrix
Abir Junayed
Abstract Data Types
Abstract Data Types
karthikeyanC40
DFS & BFS Graph
DFS & BFS Graph
Mahfuzul Yamin
Lexical Analysis
Lexical Analysis
Munni28
Unit 1 polynomial manipulation
Unit 1 polynomial manipulation
LavanyaJ28
Elementary data organisation
Elementary data organisation
Muzamil Hussain
Trees data structure
Trees data structure
Sumit Gupta
linked list in data structure
linked list in data structure
shameen khan
Data Structures with C Linked List
Data Structures with C Linked List
Reazul Islam
What's hot
(20)
B+ tree intro,uses,insertion and deletion
B+ tree intro,uses,insertion and deletion
Analysis of algorithm
Analysis of algorithm
UNIT II LINEAR DATA STRUCTURES – STACKS, QUEUES
UNIT II LINEAR DATA STRUCTURES – STACKS, QUEUES
Algorithms Lecture 2: Analysis of Algorithms I
Algorithms Lecture 2: Analysis of Algorithms I
Dinive conquer algorithm
Dinive conquer algorithm
Data Structures
Data Structures
Graph in data structure
Graph in data structure
Graph data structure and algorithms
Graph data structure and algorithms
Sparse matrix and its representation data structure
Sparse matrix and its representation data structure
Design and Analysis of Algorithms
Design and Analysis of Algorithms
Graph coloring using backtracking
Graph coloring using backtracking
Adjacency And Incidence Matrix
Adjacency And Incidence Matrix
Abstract Data Types
Abstract Data Types
DFS & BFS Graph
DFS & BFS Graph
Lexical Analysis
Lexical Analysis
Unit 1 polynomial manipulation
Unit 1 polynomial manipulation
Elementary data organisation
Elementary data organisation
Trees data structure
Trees data structure
linked list in data structure
linked list in data structure
Data Structures with C Linked List
Data Structures with C Linked List
Viewers also liked
7. Tree - Data Structures using C++ by Varsha Patil
7. Tree - Data Structures using C++ by Varsha Patil
widespreadpromotion
5. Queue - Data Structures using C++ by Varsha Patil
5. Queue - Data Structures using C++ by Varsha Patil
widespreadpromotion
6. Linked list - Data Structures using C++ by Varsha Patil
6. Linked list - Data Structures using C++ by Varsha Patil
widespreadpromotion
9. Searching & Sorting - Data Structures using C++ by Varsha Patil
9. Searching & Sorting - Data Structures using C++ by Varsha Patil
widespreadpromotion
3. Stack - Data Structures using C++ by Varsha Patil
3. Stack - Data Structures using C++ by Varsha Patil
widespreadpromotion
10. Search Tree - Data Structures using C++ by Varsha Patil
10. Search Tree - Data Structures using C++ by Varsha Patil
widespreadpromotion
4. Recursion - Data Structures using C++ by Varsha Patil
4. Recursion - Data Structures using C++ by Varsha Patil
widespreadpromotion
2. Linear Data Structure Using Arrays - Data Structures using C++ by Varsha P...
2. Linear Data Structure Using Arrays - Data Structures using C++ by Varsha P...
widespreadpromotion
11. Hashing - Data Structures using C++ by Varsha Patil
11. Hashing - Data Structures using C++ by Varsha Patil
widespreadpromotion
1. Fundamental Concept - Data Structures using C++ by Varsha Patil
1. Fundamental Concept - Data Structures using C++ by Varsha Patil
widespreadpromotion
មេរៀនៈ Data Structure and Algorithm in C/C++
មេរៀនៈ Data Structure and Algorithm in C/C++
Ngeam Soly
Ds 111011055724-phpapp01
Ds 111011055724-phpapp01
Getachew Ganfur
Stack & Queue
Stack & Queue
Joyjit Choudhury
Question answering in linked data
Question answering in linked data
Reza Ramezani
C++ Constructor destructor
C++ Constructor destructor
Da Mystic Sadi
Mca ii dfs u-3 linklist,stack,queue
Mca ii dfs u-3 linklist,stack,queue
Rai University
The State of Twitter: STL 2011
The State of Twitter: STL 2011
Infuz
Classes and objects1
Classes and objects1
Vineeta Garg
Constructors and destructors
Constructors and destructors
Vineeta Garg
Advanced data structures using c++ 3
Advanced data structures using c++ 3
Shaili Choudhary
Viewers also liked
(20)
7. Tree - Data Structures using C++ by Varsha Patil
7. Tree - Data Structures using C++ by Varsha Patil
5. Queue - Data Structures using C++ by Varsha Patil
5. Queue - Data Structures using C++ by Varsha Patil
6. Linked list - Data Structures using C++ by Varsha Patil
6. Linked list - Data Structures using C++ by Varsha Patil
9. Searching & Sorting - Data Structures using C++ by Varsha Patil
9. Searching & Sorting - Data Structures using C++ by Varsha Patil
3. Stack - Data Structures using C++ by Varsha Patil
3. Stack - Data Structures using C++ by Varsha Patil
10. Search Tree - Data Structures using C++ by Varsha Patil
10. Search Tree - Data Structures using C++ by Varsha Patil
4. Recursion - Data Structures using C++ by Varsha Patil
4. Recursion - Data Structures using C++ by Varsha Patil
2. Linear Data Structure Using Arrays - Data Structures using C++ by Varsha P...
2. Linear Data Structure Using Arrays - Data Structures using C++ by Varsha P...
11. Hashing - Data Structures using C++ by Varsha Patil
11. Hashing - Data Structures using C++ by Varsha Patil
1. Fundamental Concept - Data Structures using C++ by Varsha Patil
1. Fundamental Concept - Data Structures using C++ by Varsha Patil
មេរៀនៈ Data Structure and Algorithm in C/C++
មេរៀនៈ Data Structure and Algorithm in C/C++
Ds 111011055724-phpapp01
Ds 111011055724-phpapp01
Stack & Queue
Stack & Queue
Question answering in linked data
Question answering in linked data
C++ Constructor destructor
C++ Constructor destructor
Mca ii dfs u-3 linklist,stack,queue
Mca ii dfs u-3 linklist,stack,queue
The State of Twitter: STL 2011
The State of Twitter: STL 2011
Classes and objects1
Classes and objects1
Constructors and destructors
Constructors and destructors
Advanced data structures using c++ 3
Advanced data structures using c++ 3
Similar to 8. Graph - Data Structures using C++ by Varsha Patil
Spanningtreesppt
Spanningtreesppt
Jyoshna Cec Cse Staf bejjam
NON-LINEAR DATA STRUCTURE-Graphs.pptx
NON-LINEAR DATA STRUCTURE-Graphs.pptx
Rajitha Reddy Alugati
Ch18
Ch18
leminhvuong
Slides Chapter10.1 10.2
Slides Chapter10.1 10.2
showslidedump
Graph terminology and algorithm and tree.pptx
Graph terminology and algorithm and tree.pptx
asimshahzad8611
Lecture 2.3.1 Graph.pptx
Lecture 2.3.1 Graph.pptx
king779879
Lecture 5b graphs and hashing
Lecture 5b graphs and hashing
Victor Palmar
Graph_data_structure_information_engineering.pptx
Graph_data_structure_information_engineering.pptx
sahilpawar2426
Graph.pptx
Graph.pptx
Nasir Hussain
09_DS_MCA_Graphs.pdf
09_DS_MCA_Graphs.pdf
Prasanna David
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
H0431038048
H0431038048
ijceronline
Graphs.pptx
Graphs.pptx
satvikkushwaha1
Semantic Data Management in Graph Databases
Semantic Data Management in Graph Databases
Maribel Acosta Deibe
Chapter9 graph data structure
Chapter9 graph data structure
Mahmoud Alfarra
graph_theory_1-11.pdf___________________
graph_theory_1-11.pdf___________________
ssuser1989da
Basics of graph
Basics of graph
Khaled Sany
Graph Introduction.ppt
Graph Introduction.ppt
Faruk Hossen
Graph theory concepts complex networks presents-rouhollah nabati
Graph theory concepts complex networks presents-rouhollah nabati
nabati
Dijkstra
Dijkstra
jagdeeparora86
Similar to 8. Graph - Data Structures using C++ by Varsha Patil
(20)
Spanningtreesppt
Spanningtreesppt
NON-LINEAR DATA STRUCTURE-Graphs.pptx
NON-LINEAR DATA STRUCTURE-Graphs.pptx
Ch18
Ch18
Slides Chapter10.1 10.2
Slides Chapter10.1 10.2
Graph terminology and algorithm and tree.pptx
Graph terminology and algorithm and tree.pptx
Lecture 2.3.1 Graph.pptx
Lecture 2.3.1 Graph.pptx
Lecture 5b graphs and hashing
Lecture 5b graphs and hashing
Graph_data_structure_information_engineering.pptx
Graph_data_structure_information_engineering.pptx
Graph.pptx
Graph.pptx
09_DS_MCA_Graphs.pdf
09_DS_MCA_Graphs.pdf
PPT on Graph Theory ( Tree, Cotree, nodes, branches, incidence , tie set and ...
PPT on Graph Theory ( Tree, Cotree, nodes, branches, incidence , tie set and ...
H0431038048
H0431038048
Graphs.pptx
Graphs.pptx
Semantic Data Management in Graph Databases
Semantic Data Management in Graph Databases
Chapter9 graph data structure
Chapter9 graph data structure
graph_theory_1-11.pdf___________________
graph_theory_1-11.pdf___________________
Basics of graph
Basics of graph
Graph Introduction.ppt
Graph Introduction.ppt
Graph theory concepts complex networks presents-rouhollah nabati
Graph theory concepts complex networks presents-rouhollah nabati
Dijkstra
Dijkstra
Recently uploaded
The-boAt-Story-Navigating-the-Waves-of-Innovation.pptx
The-boAt-Story-Navigating-the-Waves-of-Innovation.pptx
Vivek487417
Top profile Call Girls In dimapur [ 7014168258 ] Call Me For Genuine Models W...
Top profile Call Girls In dimapur [ 7014168258 ] Call Me For Genuine Models W...
gajnagarg
Abortion pills in Jeddah | +966572737505 | Get Cytotec
Abortion pills in Jeddah | +966572737505 | Get Cytotec
Abortion pills in Riyadh +966572737505 get cytotec
DATA SUMMIT 24 Building Real-Time Pipelines With FLaNK
DATA SUMMIT 24 Building Real-Time Pipelines With FLaNK
Timothy Spann
Top profile Call Girls In Tumkur [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Tumkur [ 7014168258 ] Call Me For Genuine Models We...
nirzagarg
一比一原版(UCD毕业证书)加州大学戴维斯分校毕业证成绩单原件一模一样
一比一原版(UCD毕业证书)加州大学戴维斯分校毕业证成绩单原件一模一样
wsppdmt
Top profile Call Girls In Vadodara [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Vadodara [ 7014168258 ] Call Me For Genuine Models ...
gajnagarg
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Valters Lauzums
Sequential and reinforcement learning for demand side management by Margaux B...
Sequential and reinforcement learning for demand side management by Margaux B...
Paris Women in Machine Learning and Data Science
Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...
Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...
Klinik kandungan
Top profile Call Girls In Satna [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Satna [ 7014168258 ] Call Me For Genuine Models We ...
nirzagarg
Switzerland Constitution 2002.pdf.........
Switzerland Constitution 2002.pdf.........
EfruzAsilolu
Gartner's Data Analytics Maturity Model.pptx
Gartner's Data Analytics Maturity Model.pptx
chadhar227
Harnessing the Power of GenAI for BI and Reporting.pptx
Harnessing the Power of GenAI for BI and Reporting.pptx
Paras Gupta
Ranking and Scoring Exercises for Research
Ranking and Scoring Exercises for Research
Rajesh Mondal
7. Epi of Chronic respiratory diseases.ppt
7. Epi of Chronic respiratory diseases.ppt
ibrahimabdi22
Top profile Call Girls In Chandrapur [ 7014168258 ] Call Me For Genuine Model...
Top profile Call Girls In Chandrapur [ 7014168258 ] Call Me For Genuine Model...
gajnagarg
Capstone in Interprofessional Informatic // IMPACT OF COVID 19 ON EDUCATION
Capstone in Interprofessional Informatic // IMPACT OF COVID 19 ON EDUCATION
LakpaYanziSherpa
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
amy56318795
SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...
SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...
Elaine Werffeli
Recently uploaded
(20)
The-boAt-Story-Navigating-the-Waves-of-Innovation.pptx
The-boAt-Story-Navigating-the-Waves-of-Innovation.pptx
Top profile Call Girls In dimapur [ 7014168258 ] Call Me For Genuine Models W...
Top profile Call Girls In dimapur [ 7014168258 ] Call Me For Genuine Models W...
Abortion pills in Jeddah | +966572737505 | Get Cytotec
Abortion pills in Jeddah | +966572737505 | Get Cytotec
DATA SUMMIT 24 Building Real-Time Pipelines With FLaNK
DATA SUMMIT 24 Building Real-Time Pipelines With FLaNK
Top profile Call Girls In Tumkur [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Tumkur [ 7014168258 ] Call Me For Genuine Models We...
一比一原版(UCD毕业证书)加州大学戴维斯分校毕业证成绩单原件一模一样
一比一原版(UCD毕业证书)加州大学戴维斯分校毕业证成绩单原件一模一样
Top profile Call Girls In Vadodara [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Vadodara [ 7014168258 ] Call Me For Genuine Models ...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Sequential and reinforcement learning for demand side management by Margaux B...
Sequential and reinforcement learning for demand side management by Margaux B...
Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...
Jual obat aborsi Bandung ( 085657271886 ) Cytote pil telat bulan penggugur ka...
Top profile Call Girls In Satna [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Satna [ 7014168258 ] Call Me For Genuine Models We ...
Switzerland Constitution 2002.pdf.........
Switzerland Constitution 2002.pdf.........
Gartner's Data Analytics Maturity Model.pptx
Gartner's Data Analytics Maturity Model.pptx
Harnessing the Power of GenAI for BI and Reporting.pptx
Harnessing the Power of GenAI for BI and Reporting.pptx
Ranking and Scoring Exercises for Research
Ranking and Scoring Exercises for Research
7. Epi of Chronic respiratory diseases.ppt
7. Epi of Chronic respiratory diseases.ppt
Top profile Call Girls In Chandrapur [ 7014168258 ] Call Me For Genuine Model...
Top profile Call Girls In Chandrapur [ 7014168258 ] Call Me For Genuine Model...
Capstone in Interprofessional Informatic // IMPACT OF COVID 19 ON EDUCATION
Capstone in Interprofessional Informatic // IMPACT OF COVID 19 ON EDUCATION
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...
SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...
8. Graph - Data Structures using C++ by Varsha Patil
1.
Oxford University Press
© 2012Data Structures Using C++ by Dr Varsha Patil 1
2.
Oxford University Press
© 2012Data Structures Using C++ by Dr Varsha Patil Graphs as one of the most important non-linear data structures The representation that models various kinds of graphs Some useful graph algorithms 2
3.
Oxford University Press
© 2012Data Structures Using C++ by Dr Varsha Patil A graph G is a discrete structure consisting of nodes (vertices) and the lines joining the nodes (edges) For finite graphs, V and E are finite. We can write a graph as G = (V, E) Graph traversals— Visiting all the vertices and edges in a systematic fashion is called as a graph traversal 3
4.
Oxford University Press
© 2012Data Structures Using C++ by Dr Varsha Patil Graphs are classified as directed and undirected graphs In an undirected graph, an edge is a set of two vertices where order does not make any relevance, whereas in a directed graph, an edge is an ordered pair 4
5.
Oxford University Press
© 2012Data Structures Using C++ by Dr Varsha Patil Graph 5 create() :Graph insert vertex(Graph, v) :Graph delete vertex(Graph, v) :Graph insert edge(Graph, u, v) :Graph delete edge(Graph, u, v) :Graph is empty(Graph) :Boolean; end graph
6.
Oxford University Press
© 2012Data Structures Using C++ by Dr Varsha Patil Adjacency matrix (sequential representation) Adjacency list (linked representation) Adjacency Multilist Inverse Adjacency List 6 Representation of Graphs
7.
Oxford University Press
© 2012Data Structures Using C++ by Dr Varsha Patil The graphs represented using a sequential representation using matrices is called an adjacency matrix 7 Adjacency Matrix
8.
Oxford University Press
© 2012Data Structures Using C++ by Dr Varsha Patil 8 Adjacency Matrix representation
9.
Oxford University Press
© 2012Data Structures Using C++ by Dr Varsha Patil In an adjacency list, the n rows of the adjacency list are represented as n-linked lists, one list per vertex of the graph We can represent G by an array Head, where Head[i] is a pointer to the adjacency list of vertex i Each node of the list has at least two fields: vertex and link The vertex field contains the vertex–id, and link field stores the pointer to the next node storing another vertex adjacent to i 9 Adjacency Lists
10.
Oxford University Press
© 2012Data Structures Using C++ by Dr Varsha Patil 10
11.
Oxford University Press
© 2012Data Structures Using C++ by Dr Varsha Patil 11
12.
Oxford University Press
© 2012Data Structures Using C++ by Dr Varsha Patil 12 Multiclass are lists where nodes may be shared among several other lists
13.
Oxford University Press
© 2012Data Structures Using C++ by Dr Varsha Patil The node structure of such a list can be represented as follows : 13
14.
Oxford University Press
© 2012Data Structures Using C++ by Dr Varsha Patil 14
15.
Oxford University Press
© 2012Data Structures Using C++ by Dr Varsha Patil Inverse adjacency lists is a set of lists that contain one list for vertex Each list contains a node per vertex adjacent to the vertex it represents 15
16.
Oxford University Press
© 2012Data Structures Using C++ by Dr Varsha Patil 16
17.
Oxford University Press
© 2012Data Structures Using C++ by Dr Varsha Patil DFS starts at the vertex v of G as a start vertex and v is marked as visited Then, each unvisited vertex adjacent to v is searched using the DFS recursively Once all the vertices that can be reached from v have been visited, the search of v is complete If some vertices remain unvisited, we select an unvisited vertex as a new start vertex and then repeat the process until all the vertices of G are marked visited 17
18.
Oxford University Press
© 2012Data Structures Using C++ by Dr Varsha Patil 18 (a) Graph and its (b) adjacency list representation
19.
Oxford University Press
© 2012Data Structures Using C++ by Dr Varsha Patil A tree is a connected graph with no cycles A spanning tree is a sub-graph of G that has all vertices of G and is a tree A minimum spanning tree of a weighted graph G is the spanning tree of G whose edges sum to minimum weight 19
20.
Oxford University Press
© 2012Data Structures Using C++ by Dr Varsha Patil In BFS, all the unvisited vertices adjacent to i are visited after visiting the start vertex i and marking it visited Next, the unvisited vertices adjacent to these vertices are visited and so on until the entire graph has been traversed 20
21.
Oxford University Press
© 2012Data Structures Using C++ by Dr Varsha Patil 21 Breadth-first search sequence for the graph
22.
Oxford University Press
© 2012Data Structures Using C++ by Dr Varsha Patil A tree is a connected graph with no cycles A spanning tree is a sub-graph of G that has all vertices of G and is a tree A minimum spanning tree of a weighted graph G is the spanning tree of G whose edges sum to minimum weight 22
23.
Oxford University Press
© 2012Data Structures Using C++ by Dr Varsha Patil 23
24.
Oxford University Press
© 2012Data Structures Using C++ by Dr Varsha Patil An undirected graph is connected if there is at least one path between every pair of vertices in the graph A connected component of a graph is a maximal connected sub- graph, that is, every vertex in a connected component is reachable from the vertices in the component 24 Connected Components
25.
Oxford University Press
© 2012Data Structures Using C++ by Dr Varsha Patil Following fig shows the Sample graph with one connected component 25
26.
Oxford University Press
© 2012Data Structures Using C++ by Dr Varsha Patil Following fig shows the Graph with two connected components 26
27.
Oxford University Press
© 2012Data Structures Using C++ by Dr Varsha Patil Prim’s algorithm starts from one vertex and grows the rest of the tree by adding one vertex at a time, by adding the associated edges This algorithm builds a tree by iteratively adding edges until a minimal spanning tree is obtained, that is, when all nodes are added At each iteration, it adds to the current tree a vertex though minimum weight edge that does not complete a cycle 27 Prim’s Algorithm
28.
Oxford University Press
© 2012Data Structures Using C++ by Dr Varsha Patil 28 Minimum Spanning Tree Minimum Spanning Tree
29.
Oxford University Press
© 2012Data Structures Using C++ by Dr Varsha Patil Another way to construct a minimum spanning tree for a graph G is to start with a graph T = (V′, E′ = ø) consisting of the n vertices of G and having no edges In Prim’s algorithm, we start with one connected component, add a vertex to have one connected component and no cycles, and end up with one connected component Here, we start with n connected components; at each step, the number of connected components would reduce by one and end up with one connected component 29 Kruskal’s Algorithm
30.
Oxford University Press
© 2012Data Structures Using C++ by Dr Varsha Patil The shortest path between two given vertices is the path having minimum length This problem can be solved by one of the greedy algorithms, by Edger W. Dijkstra, often called as Dijkstra’s algorithm 30 Shortest Path Algorithm
31.
Oxford University Press
© 2012Data Structures Using C++ by Dr Varsha Patil 31 Shortest Path Algorithm Directed weighted graph Shortest Path
32.
Oxford University Press
© 2012Data Structures Using C++ by Dr Varsha Patil Graphs are one of the most important non-linear data structures. A graph is a representation of relation Vertices represent elements and edges represent relationships In other words, a graph is a collection of nodes (vertices) and arcs joining pair of the nodes (edges) Graphs are classified as directed and undirected graphs. In an undirected graph, an edge is a set of two vertices where order does not make any relevance, whereas in a directed graph, an edge is an ordered pair. 32 Summary
33.
Oxford University Press
© 2012Data Structures Using C++ by Dr Varsha Patil Graphs are implemented using an array or a linked list representation An adjacency list is a data structure for representing a graph by keeping a list of the neighbour vertices for each vertex An adjacency matrix is a data structure for representing a graph as a Boolean matrix where 0 means no edge and 1 corresponds to an edge A minimum spanning tree is a tree, containing all the vertices of a graph, where the total weight of the edges is minimum The two popularly used algorithms to compute minimum spanning tree are the following: Prim’s and Kruskal’s algorithms Dijkstra’s algorithm is another common algorithm for graphs to find the shortest path between two vertices of a graph 33 Summary
34.
Oxford University Press
© 2012Data Structures Using C++ by Dr Varsha Patil End of Chapter 8…! 34
Download now