Question: Please modify my Java code. Please modify my Dijkstras? algorithm code to do the following: right now my algorithm accepts one source node and outputs
Please modify my Java code.
Please modify my Dijkstras? algorithm code to do the following:
right now my algorithm accepts one source node and outputs the shortest path to all the others. Please make the few changes described below. The output it wants is something I am struggling with. In Java please.
Thank You

import java.util.*; import java.lang.*; import java.io.*;
class Dijkstra { static int numberOfVerticies = 0; int getMinDistance(int distance[], Boolean isSet[], int numberOfVertices) { // Initialize value with maximum integer int min = Integer.MAX_VALUE; // take position as -1 int position = -1; for (int v = 0; v
void shortestPath(int adjacencyMatrix[][], int source, int numberOfVertices) { // the output array which holds the distance of all the vertices from source int distance[] = new int[numberOfVertices]; // isSet[i] will true if vertex i is included in shortest // path tree or shortest distance from source to i is finalized Boolean isSet[] = new Boolean[numberOfVertices]; // Set all distances as max integer value and isSet[] as false for (int i = 0; i destination = Distance"); for (int i = 0; i " + i + " : " + distance[i]); }
// Main public static void main(String[] args) { System.out.print(" Enter number of vertices : "); Scanner scanner = new Scanner(System.in); numberOfVerticies=scanner.nextInt(); System.out.println("Enter input:"); int adjacencyMatrix[][] = new int[numberOfVerticies][numberOfVerticies]; for (int i = 0; i
System.out.print(" Enter source node: "); int source = scanner.nextInt();
dijkstra.shortestPath(adjacencyMatrix, source, numberOfVerticies); } }
outputs the corresponding routing matrix. The routing matrix will be written both to the screen and to an output file. Use Dijkstra's algorithm to find the shortest cost and path between nodes The program runs from the command line with two optional command line arguments. Use the following command line options to indicate the presence ofa command line argument: -i (for input file name) and -o (for output file name). If no command line arguments are present, the program uses "xy_input.txt and xy-output.txt" as default input and output file names respectively. See examples below: java xy_rmatrix java xy rmatrix -o xy rmatrixo.txt java xy _rmatrix -i xy rmatrixi.txt-o xy-rmatrixo.txt Sample Input/Output: Edges are bi-directional A E A D 2 C D 2 C E 2 D E 7 Routing matrix D.4 C,4 A,1 D,4 D I A2 C,6 B,4 ?? C,6 D,2 D.2 C,4 D,6 C,6 ?,2 C,4 C,2 C,2
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
