A1 Write a function Connected Component (G,v) which takes as in- put a dictionary representing a graph G, and one of its vertices v, and returns a set of nodes representing the connected com- ponent of v, implementing the method given in the notes. Hint: Create and update lists called visitednodes repres- enting previously visited nodes, latestnodes representing the most recently visited nodes, and newnodes representing nodes neighbouring those in latestnodes and not included in either of the previous categories. A2 Write a function NumberOfComponents (G) which takes as in- put a dictionary representing a graph G and returns a positive integer representing its number of connected components. A3 Recall that an ordinary (unweighted) graph can be considered a weighted graph by assigning every edge weight 1. The "shortest path" from a to b in this interpretation is simply the path from a to b with the fewest edges. This makes Dijkstra's algorithm simpler as the shortest path from a to b will simply be the first one found.
A1 Write a function Connected Component (G,v) which takes as in- put a dictionary representing a graph G, and one of its vertices v, and returns a set of nodes representing the connected com- ponent of v, implementing the method given in the notes. Hint: Create and update lists called visitednodes repres- enting previously visited nodes, latestnodes representing the most recently visited nodes, and newnodes representing nodes neighbouring those in latestnodes and not included in either of the previous categories. A2 Write a function NumberOfComponents (G) which takes as in- put a dictionary representing a graph G and returns a positive integer representing its number of connected components. A3 Recall that an ordinary (unweighted) graph can be considered a weighted graph by assigning every edge weight 1. The "shortest path" from a to b in this interpretation is simply the path from a to b with the fewest edges. This makes Dijkstra's algorithm simpler as the shortest path from a to b will simply be the first one found.
C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter18: Stacks And Queues
Section: Chapter Questions
Problem 16PE:
The implementation of a queue in an array, as given in this chapter, uses the variable count to...
Related questions
Question
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning