In Dijkstra’s Algorithm, on page 367, we saw how Dijkstra’s algorithm helped us find the shortest path within a weighted graph. However, the concept of a shortest path exists within an unweighted...

In Dijkstra’s Algorithm, on page 367, we saw how Dijkstra’s algorithm helped us find the shortest path within a weighted graph. However, the concept of a shortest path exists within an unweighted graph as well. How? The shortest path in a classic (unweighted) graph is the path that takes the fewest number of vertices to get from one vertex to another. This can be especially useful in social networking applications. Take the example network that follows: If we want to know how Idris is to connected Lina, we’d see that she’s connected to her from two different directions. That is, Idris is a seconddegree connection to Lina through Kamil, but she is also a fifth-degree connection through Talia. Now, we’re probably interested in how closely Idris is connected to Lina, so the fact that she’s a fifth-degree connection is unimportant given that they’re also second-degree connections. Write a function that accepts two vertices from a graph and returns the shortest path between them. The function should return an array containing the precise path, such as ["Idris", "Kamil", "Lina"]. Hint: The algorithm may contain elements of both breadth-first search and Dijkstra’s algorithm.

Dec 20, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here