Question: Check my code and see the error preventing it to run successsfully most especially in the pom.xml and update it for me . #Dijkstra.java package
Check my code and see the error preventing it to run successsfully most especially in the pom.xml and update it for me
#Dijkstra.java
package org.example;
import org.graphstream.graph.Graph;
import org.graphstream.graph.implementations.SingleGraph;
import org.graphstream.graph.Node;
import org.graphstream.graph.Edge;
import java.util.Arrays;
public class Dijkstra
private static final int INFINITY Integer.MAXVALUE;
private static final int UNDEFINED ;
public static void dijkstraint graph, int source
int n graph.length;
int dist new intn;
int prev new intn;
boolean visited new booleann;
Arrays.filldist INFINITY;
Arrays.fillprev UNDEFINED;
distsource;
for int i ; i n; i
int u ;
for int j ; j n; j
if visitedj && u distj distu
u j;
if distu INFINITY break;
visitedu true;
for int v ; v n; v
if graphuv && distu graphuv distv
distv distu graphuv;
prevv u;
System.out.printlnArraystoStringdist;
System.out.printlnArraystoStringprev;
Create and visualize graph with GraphStream
visualizeGraphgraph dist, prev, source;
private static void visualizeGraphint graph, int dist, int prev, int source
Graph g new SingleGraphDijkstra;
Add nodes
for int i ; i graph.length; i
Node node gaddNodeStringvalueOfi;
node.setAttributeuilabel", i disti;
Add edges
for int u ; u graph.length; u
for int v ; v graphulength; v
if graphuv
Edge edge gaddEdgeu v String.valueOfu String.valueOfv true;
edge.setAttributeuilabel", graphuv;
Highlight shortest paths
for int v ; v prev.length; v
if prevv UNDEFINED
Edge edge ggetEdgeprevv v;
if edge null
edge.setAttributeuistyle", "fillcolor: red;";
try
gdisplay;
catch Exception e
Handle the exception and provide an alternative visualization
System.err.printlnFailed to launch the viewer. Exception: egetMessage;
alternativeVisualizeGraphgraph dist, prev;
private static void alternativeVisualizeGraphint graph, int dist, int prev
System.out.printlnGraph visualization using text:";
for int i ; i graph.length; i
for int j ; j graphilength; j
if graphij
System.out.printlnEdge between i and j with weight graphij;
System.out.printlnShortest paths:";
for int v ; v prev.length; v
if prevv UNDEFINED
System.out.printlnEdge from prevv to v in the shortest path";
public static void mainString args
int graph
;
dijkstragraph;
#Maven pom.xml
org.example
Dijkstra
SNAPSHOT
UTF
org.graphstream
gscore
#Error Message
Failed to launch the viewer. Exception: Cannot launch viewer.
Graph visualization using text:
Edge between and with weight
Edge between and with weight
Edge between and with weight
Edge between and with weight
Edge between and with weight
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
