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.ioSerializable;
import java.util.ArrayList;
import java.util.List;
public class LocationManager implements Serializable
private static final long serialVersionUID L;
public Graph graph;
private List misLocations;
private ListmisEdges;
private ArrayListmisUsers;
private static LocationManager managernull;
private static User loginUser;
public LocationManager
super;
graph new Graph;
misLocations new ArrayList;
misEdges new ArrayList;
misUsers new ArrayList;
public static LocationManager getInstance
if managernull
manager new LocationManager;
return manager;
public List getLocations
return misLocations;
public Graph getGraph
return graph;
public List getMisLocations
return misLocations;
public void setMisLocationsList misLocations
this.misLocations misLocations;
public static LocationManager getManager
return manager;
public static void setManagerLocationManager manager
LocationManager.manager manager;
public void setGraphGraph graph
this.graph graph;
public void agregarLocationLocation location
misLocations.addlocation;
public void agregarEdgeEdge edge
misEdges.addedge;
public Location buscarLocationByCodigoString idLocation
Location aux null;
boolean encontrado false;
int i;
while encontrado && i edges;
public LocationString id String name, ArrayList edges
super;
this.id id;
this.name name;
this.edges edges;
package sistemaDeRutas;
import java.ioSerializable;
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 L;
private Graph grafo;
public DijkstraAlgorithmGraph grafo
this.grafo grafo;
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
