how to get the single source shortest path problem for a directed weighted graph using Dijkstra’s algorithm. From the txt.file which looks like: 6 1 2 10 3 0 4 0 5 3 6 8 2 1 0 3 2 4 0 5 4 6 0 3 1 0 2 0 4 9 5 0 6 1 4 1 0 2 0 3 7 5 0 6 2 5 1 0 2 1 3 8 4 2 6 0 6 1 7 2 2 3 0 4 0 5 0
how to get the single source shortest path problem for a directed weighted graph using Dijkstra’s
6
1 2 10 3 0 4 0 5 3 6 8
2 1 0 3 2 4 0 5 4 6 0
3 1 0 2 0 4 9 5 0 6 1
4 1 0 2 0 3 7 5 0 6 2
5 1 0 2 1 3 8 4 2 6 0
6 1 7 2 2 3 0 4 0 5 0
The first line of the file describes the number of vertices (n) of G. For example, the above graph consists of 4 vertices.
Each remaining line of the graph is a list of integers separated by spaces and represents the list of out-neighbors of one vertex. The first number in the line is the name of the vertex. After that, there is a sequence of pairs, consisting of a vertex name and a weight.
For example, the second line of the file:
1 2 8 3 16 4 4
indicates that there is an edge from 1 to 2 of weight 8, an edge from 1 to 3 of weight 16, an edge from 1 to 4 of weight 4, and no other edges from 1.
how would one impliment this into a adjacent matrix or list using java?
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 3 steps with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)