Question: Help with my Java route management system. I will attach the code of my controller class... the idea is to create a kind of CRUD

Help with my Java route management system. I will attach the code of my controller class... the idea is to create a kind of CRUD for the data provided by the user, to eventually show them the most convenient routes in terms of time and distance using search algorithms. One of them is Dijkstra's algorithm. I have a class called 'edge' that handles everything about the graph's edge and another class called 'graph' for the graph's diagram in question. Also, another class called 'location' to record the name and ID (this is to keep everything more organized, it would be like for the vertices of the graph, but if it doesn't seem right, it can be changed).
The question is, how should my Dijkstra class look to calculate the shortest route between two specific locations? and some ideas for finishing my crud.
package sistemaDeRutas;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
public class LocationManager implements Serializable {
/**
*
*/
private static final long serialVersionUID =-1637215435293585128L;
public Graph graph;
private List misLocations;
private ListmisEdges;
private ArrayListmisUsers;
private static LocationManager manager=null;
private static User loginUser;
public LocationManager(){
super();
graph = new Graph();
misLocations = new ArrayList<>();
misEdges= new ArrayList<>();
misUsers= new ArrayList<>();
}
public static LocationManager getInstance(){
if (manager==null)
manager= new LocationManager();
return manager;
}
public List getLocations(){
return misLocations;
}
public Graph getGraph(){
return graph;
}
public List getMisLocations(){
return misLocations;
}
public void setMisLocations(List misLocations){
this.misLocations = misLocations;
}
public static LocationManager getManager(){
return manager;
}
public static void setManager(LocationManager manager){
LocationManager.manager = manager;
}
public void setGraph(Graph graph){
this.graph = graph;
}
public void agregarLocation(Location location){
misLocations.add(location);
}
public void agregarEdge(Edge edge){
misEdges.add(edge);
}
public Location buscarLocationByCodigo(String idLocation){
Location aux = null;
boolean encontrado = false;
int i=0;
while (!encontrado && i edges;
public Location(String id, String name, ArrayList edges){
super();
this.id = id;
this.name = name;
this.edges = edges;
}package sistemaDeRutas;
import java.io.Serializable;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Set;
public class DijkstraAlgorithm implements Serializable {
/**
*
*/
private static final long serialVersionUID =811636579292964346L;
private Graph grafo;
public DijkstraAlgorithm(Graph grafo){
this.grafo = grafo;
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Accounting Questions!