SlideShare a Scribd company logo
1 of 29
 Graphs are collections of nodes connected by edges
G = (V,E) where V is a set of nodes and E a set of
edges.
 Graphs are useful in a number of applications
– Shortest path problems
– Maximum flow problem
 Graphs unlike trees are more general for they can
have connected components.
 Directed Graphs: A directed graph edges allow
travel in one direction. graph
 Undirected Graphs: An undirected edges allow
travel in either direction
A graph is an ordered pair G=(V,E) with a set of
vertices or nodes and the edges that connect them.
 A subgraph of a graph has a subset of the vertices
and edges.
 The edges indicate how we can move through the
graph.
 A path is a subset of E that is a series of edges
between two nodes.
 A graph is connected if there is at least one path
between every pair of nodes.
The length of a path in a graph is the number of edges in
the path.
 A complete graph is one that has an edge between
every pair of nodes.
 A weighted graph is one where each edge has a cost for
traveling between the nodes.
 A cycle is a path that begins and ends at the same node.
 An acyclic graph is one that has no cycles.
An acyclic, connected graph is also called an unrooted
tree
Number of Edges – Undirected Graph
 The no. of possible pairs in an n vertex graph is n*(n-1)
 Since edge (u,v) is the same as edge (v,u), the number of
edges in an undirected graph is n*(n- 1)/2.
Number of Edges - Directed Graph
 The no. of possible pairs in an n vertex graph is n*(n-1)
 Since edge (u,v) is not the same as edge (v,u), the number
of edges in a directed graph is n*(n-1)
 Thus, the number of edges in a directed graph is ≤ n*(n-1)
For graphs to be computationally useful, they
have to be conveniently represented in programs
 There are two computer representations of
graphs:
 Adjacency matrix (Sequential representation)
 Adjacency lists ( Linked representation)
A square grid of boolean values
If the graph contains N vertices, then the grid
contains N rows and N columns.
 For two vertices numbered I and J, the element at
row I and column J is true(0) if there is an edge from I
to J, otherwise false(1).
In an adjacency list, the n rows of the adjacency list are
represented as n-linked lists, one list per vertex of the graph
 A graph of n nodes is represented by a one dimensional array L
of linked lists, where
● L[i] is the linked list containing all the nodes adjacent from
node i.
● The nodes in the list L[i] are in no particular order.
For a weighted graph, this list would also include the weight for
each edge.
 Some algorithms require that every vertex of a graph
be visited exactly once.
 The order in which the vertices are visited may be
important, and may depend upon the particular
algorithm.
 The two common traversals:
- depth-first
- breadth-first
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
The order of the
depth-first traversal
of this graph starting
at node 1 would be:
1, 2, 3, 4, 7, 5, 6, 8, 9
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.
 From the starting node, we follow all paths of length
one.
 Then we follow paths of length two that go to unvisited
nodes.
 We continue increasing the length of the paths until
there are no unvisited nodes along any of the paths.
The order of the
breadth-first traversal
of this graph starting
at node 1 would be:
1, 2, 8, 3, 7, 4, 5, 9, 6
 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
Spanning trees (a) Graph (b) Spanning tree
(c) Minimum spanning tree
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 subgraph, that is, every vertex in a
connected component is reachable from the vertices in
the component
This figure shows
the Sample graph with
one connected component
 This figure shows the Graph
with two connected components
 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 weighted edge that does not
complete a cycle.
 Minimum Spanning tree using Prim’s algorithm.
 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
The shortest path between
two given vertices is the path
having minimum length.
In Computer science graphs are used to represent the
flow of computation.
Google maps uses graphs for building transportation
systems.
In Facebook, users are considered to be the vertices and if
they are friends then there is an edge running between them.
This is an undirected graph
In World Wide Web, web pages are considered to be the
vertices. There is an edge from a page u to other page v if there is
a link of page v on page u. This is an example of Directed graph.
In Operating System, we come across the Resource Allocation
Graph where each process and resources are considered to be
vertices. Edges are drawn from resources to the allocated process,
or from requesting process to the requested resource. If this
leads to any formation of a cycle then a deadlock will occur.
The number of elements in the adjacency matrix of a graph
having 7 vertices is __________
a) 7 b) 14 c) 36 d) 49
What would be the number of zeros in the adjacency matrix of
the given graph?
a) 10 b) 6 c) 16 d) 0
 A graph with all vertices having equal degree is known as a __
a) Multi Graph b) Regular Graph
c) Simple Graph d) Complete Graph
NON-LINEAR DATA STRUCTURE-Graphs.pptx

More Related Content

Similar to NON-LINEAR DATA STRUCTURE-Graphs.pptx

graph representation.pdf
graph representation.pdfgraph representation.pdf
graph representation.pdfamitbhachne
 
data structures and algorithms Unit 2
data structures and algorithms Unit 2data structures and algorithms Unit 2
data structures and algorithms Unit 2infanciaj
 
Unit-6 Graph.ppsx ppt
Unit-6 Graph.ppsx                                       pptUnit-6 Graph.ppsx                                       ppt
Unit-6 Graph.ppsx pptDhruvilSTATUS
 
Graph applications chapter
Graph applications chapterGraph applications chapter
Graph applications chapterSavit Chandra
 
Graph theory concepts complex networks presents-rouhollah nabati
Graph theory concepts   complex networks presents-rouhollah nabatiGraph theory concepts   complex networks presents-rouhollah nabati
Graph theory concepts complex networks presents-rouhollah nabatinabati
 
Lecture 5b graphs and hashing
Lecture 5b graphs and hashingLecture 5b graphs and hashing
Lecture 5b graphs and hashingVictor Palmar
 
Graph_data_structure_information_engineering.pptx
Graph_data_structure_information_engineering.pptxGraph_data_structure_information_engineering.pptx
Graph_data_structure_information_engineering.pptxsahilpawar2426
 
Graph ASS DBATU.pptx
Graph ASS DBATU.pptxGraph ASS DBATU.pptx
Graph ASS DBATU.pptxARVIND SARDAR
 
graph_theory_1-11.pdf___________________
graph_theory_1-11.pdf___________________graph_theory_1-11.pdf___________________
graph_theory_1-11.pdf___________________ssuser1989da
 
358 33 powerpoint-slides_13-graphs_chapter-13
358 33 powerpoint-slides_13-graphs_chapter-13358 33 powerpoint-slides_13-graphs_chapter-13
358 33 powerpoint-slides_13-graphs_chapter-13sumitbardhan
 
VANU no sql ppt.pptx
VANU no sql ppt.pptxVANU no sql ppt.pptx
VANU no sql ppt.pptxMJeyavarthini
 
Social network analysis
Social network analysisSocial network analysis
Social network analysisStefanie Zhao
 
FREQUENT SUBGRAPH MINING ALGORITHMS - A SURVEY AND FRAMEWORK FOR CLASSIFICATION
FREQUENT SUBGRAPH MINING ALGORITHMS - A SURVEY AND FRAMEWORK FOR CLASSIFICATIONFREQUENT SUBGRAPH MINING ALGORITHMS - A SURVEY AND FRAMEWORK FOR CLASSIFICATION
FREQUENT SUBGRAPH MINING ALGORITHMS - A SURVEY AND FRAMEWORK FOR CLASSIFICATIONcscpconf
 

Similar to NON-LINEAR DATA STRUCTURE-Graphs.pptx (20)

Graphs.pptx
Graphs.pptxGraphs.pptx
Graphs.pptx
 
graph representation.pdf
graph representation.pdfgraph representation.pdf
graph representation.pdf
 
data structures and algorithms Unit 2
data structures and algorithms Unit 2data structures and algorithms Unit 2
data structures and algorithms Unit 2
 
Unit-6 Graph.ppsx ppt
Unit-6 Graph.ppsx                                       pptUnit-6 Graph.ppsx                                       ppt
Unit-6 Graph.ppsx ppt
 
Graph applications chapter
Graph applications chapterGraph applications chapter
Graph applications chapter
 
Graph theory concepts complex networks presents-rouhollah nabati
Graph theory concepts   complex networks presents-rouhollah nabatiGraph theory concepts   complex networks presents-rouhollah nabati
Graph theory concepts complex networks presents-rouhollah nabati
 
Lecture 5b graphs and hashing
Lecture 5b graphs and hashingLecture 5b graphs and hashing
Lecture 5b graphs and hashing
 
09_DS_MCA_Graphs.pdf
09_DS_MCA_Graphs.pdf09_DS_MCA_Graphs.pdf
09_DS_MCA_Graphs.pdf
 
Graph_data_structure_information_engineering.pptx
Graph_data_structure_information_engineering.pptxGraph_data_structure_information_engineering.pptx
Graph_data_structure_information_engineering.pptx
 
Graph ASS DBATU.pptx
Graph ASS DBATU.pptxGraph ASS DBATU.pptx
Graph ASS DBATU.pptx
 
Graphs
GraphsGraphs
Graphs
 
graph_theory_1-11.pdf___________________
graph_theory_1-11.pdf___________________graph_theory_1-11.pdf___________________
graph_theory_1-11.pdf___________________
 
358 33 powerpoint-slides_13-graphs_chapter-13
358 33 powerpoint-slides_13-graphs_chapter-13358 33 powerpoint-slides_13-graphs_chapter-13
358 33 powerpoint-slides_13-graphs_chapter-13
 
graph ASS (1).ppt
graph ASS (1).pptgraph ASS (1).ppt
graph ASS (1).ppt
 
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
 
Social network analysis
Social network analysisSocial network analysis
Social network analysis
 
10.graph
10.graph10.graph
10.graph
 
FREQUENT SUBGRAPH MINING ALGORITHMS - A SURVEY AND FRAMEWORK FOR CLASSIFICATION
FREQUENT SUBGRAPH MINING ALGORITHMS - A SURVEY AND FRAMEWORK FOR CLASSIFICATIONFREQUENT SUBGRAPH MINING ALGORITHMS - A SURVEY AND FRAMEWORK FOR CLASSIFICATION
FREQUENT SUBGRAPH MINING ALGORITHMS - A SURVEY AND FRAMEWORK FOR CLASSIFICATION
 
Graphs
GraphsGraphs
Graphs
 

Recently uploaded

Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfakmcokerachita
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 

Recently uploaded (20)

Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdf
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 

NON-LINEAR DATA STRUCTURE-Graphs.pptx

  • 1.  Graphs are collections of nodes connected by edges G = (V,E) where V is a set of nodes and E a set of edges.  Graphs are useful in a number of applications – Shortest path problems – Maximum flow problem  Graphs unlike trees are more general for they can have connected components.
  • 2.  Directed Graphs: A directed graph edges allow travel in one direction. graph  Undirected Graphs: An undirected edges allow travel in either direction
  • 3. A graph is an ordered pair G=(V,E) with a set of vertices or nodes and the edges that connect them.  A subgraph of a graph has a subset of the vertices and edges.  The edges indicate how we can move through the graph.  A path is a subset of E that is a series of edges between two nodes.  A graph is connected if there is at least one path between every pair of nodes.
  • 4. The length of a path in a graph is the number of edges in the path.  A complete graph is one that has an edge between every pair of nodes.  A weighted graph is one where each edge has a cost for traveling between the nodes.  A cycle is a path that begins and ends at the same node.  An acyclic graph is one that has no cycles. An acyclic, connected graph is also called an unrooted tree
  • 5. Number of Edges – Undirected Graph  The no. of possible pairs in an n vertex graph is n*(n-1)  Since edge (u,v) is the same as edge (v,u), the number of edges in an undirected graph is n*(n- 1)/2. Number of Edges - Directed Graph  The no. of possible pairs in an n vertex graph is n*(n-1)  Since edge (u,v) is not the same as edge (v,u), the number of edges in a directed graph is n*(n-1)  Thus, the number of edges in a directed graph is ≤ n*(n-1)
  • 6. For graphs to be computationally useful, they have to be conveniently represented in programs  There are two computer representations of graphs:  Adjacency matrix (Sequential representation)  Adjacency lists ( Linked representation)
  • 7. A square grid of boolean values If the graph contains N vertices, then the grid contains N rows and N columns.  For two vertices numbered I and J, the element at row I and column J is true(0) if there is an edge from I to J, otherwise false(1).
  • 8.
  • 9.
  • 10. In an adjacency list, the n rows of the adjacency list are represented as n-linked lists, one list per vertex of the graph  A graph of n nodes is represented by a one dimensional array L of linked lists, where ● L[i] is the linked list containing all the nodes adjacent from node i. ● The nodes in the list L[i] are in no particular order. For a weighted graph, this list would also include the weight for each edge.
  • 11.
  • 12.
  • 13.  Some algorithms require that every vertex of a graph be visited exactly once.  The order in which the vertices are visited may be important, and may depend upon the particular algorithm.  The two common traversals: - depth-first - breadth-first
  • 14. 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
  • 15. The order of the depth-first traversal of this graph starting at node 1 would be: 1, 2, 3, 4, 7, 5, 6, 8, 9
  • 16. 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.  From the starting node, we follow all paths of length one.  Then we follow paths of length two that go to unvisited nodes.  We continue increasing the length of the paths until there are no unvisited nodes along any of the paths.
  • 17. The order of the breadth-first traversal of this graph starting at node 1 would be: 1, 2, 8, 3, 7, 4, 5, 9, 6
  • 18.  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. Spanning trees (a) Graph (b) Spanning tree (c) Minimum spanning tree
  • 20. 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 subgraph, that is, every vertex in a connected component is reachable from the vertices in the component
  • 21. This figure shows the Sample graph with one connected component  This figure shows the Graph with two connected components
  • 22.  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 weighted edge that does not complete a cycle.
  • 23.  Minimum Spanning tree using Prim’s algorithm.
  • 24.  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
  • 25. The shortest path between two given vertices is the path having minimum length.
  • 26. In Computer science graphs are used to represent the flow of computation. Google maps uses graphs for building transportation systems. In Facebook, users are considered to be the vertices and if they are friends then there is an edge running between them. This is an undirected graph
  • 27. In World Wide Web, web pages are considered to be the vertices. There is an edge from a page u to other page v if there is a link of page v on page u. This is an example of Directed graph. In Operating System, we come across the Resource Allocation Graph where each process and resources are considered to be vertices. Edges are drawn from resources to the allocated process, or from requesting process to the requested resource. If this leads to any formation of a cycle then a deadlock will occur.
  • 28. The number of elements in the adjacency matrix of a graph having 7 vertices is __________ a) 7 b) 14 c) 36 d) 49 What would be the number of zeros in the adjacency matrix of the given graph? a) 10 b) 6 c) 16 d) 0  A graph with all vertices having equal degree is known as a __ a) Multi Graph b) Regular Graph c) Simple Graph d) Complete Graph