Question: Please help me complete my main. I ' m working on a route management system in Java, aimed at calculating and optimizing routes between different
Please help me complete my main. Im working on a route management system in Java, aimed at calculating and optimizing routes between different locations using algorithms and data structures. Each location will be represented as a node in an undirected graph, and connections between locations will be modeled as edges. These edges should have weight and time attributes. I have all the calculation methods already done, but I need to know if they work and why I have to make the user interaction menu. I want you to help me call the calculation functions from the main. For example, if the user chooses option then it should add a location a node and say how many edges it will have and their attributes, and also say with which node it will connect. For example, node will have edge connecting to node the edge has a weight of and a time of Below I attach at least the titles of the methods of my controller class and main due to lack of space I do not include them entirely
public class LocationManager implements Serializable
private static final long serialVersionUID L;
private Edge matrizAdyacencia;
private List locations;
public LocationManagerint numLocations
matrizAdyacencia new EdgenumLocationsnumLocations;
locations new ArrayList;
public void setAdjacencyMatrixEdge matrizAdyacencia
this.matrizAdyacencia matrizAdyacencia;
public void getAdjacencyMatrixEdge matrizAdyacencia
this.matrizAdyacencia matrizAdyacencia;
public List getLocations
return locations;
public void setLocationsList locations
this.locations locations;
public void addLocationLocation location
locations.addlocation;
public void editLocationint index, Location location
if index && index locations.size
locations.setindex location;
public void deleteLocationint index
if index && index locations.size
locations.removeindex;
for int i index; i locations.size; i
for int j ; j matrizAdyacencia.length; j
matrizAdyacenciaij matrizAdyacenciai j;
for int j ; j matrizAdyacencia.length; j
matrizAdyacenciaji matrizAdyacenciaji ;
public void addConnectionint source, int destination, int weight, int timeMin
if source && source locations.size &&
destination && destination locations.size
matrizAdyacenciasourcedestination new Edgeweight timeMin;
matrizAdyacenciadestinationsource new Edgeweight timeMin; Assuming undirected graph
public List shortestPathDijkstraint start, int end
return shortestPathDijkstrastart end, false;
public List shortestPathDijkstraint start, int end,boolean minimizeTime
private int minDistanceint dist, boolean visited
return minIndex;
private List getPathint start, int end, int parent
public void minimumSpanningTreePrim
class DisjointSet
public int findint x
return parentx;
public void unionint x int y
public void minimumSpanningTreeKruskal
public void shortestPathFloydWarshall
public void minimizeTime
public void minimizeDistance
public void mostrarMatrizAdyacencia
public class Main implements Serializable
public static void mainString args
Scanner scanner new ScannerSystemin;
LocationManager routeSystem new LocationManager;
int opcion;
do
System.out.println Men;
System.out.println Agregar ubicacin;add ubication node
System.out.println Editar ubicacin;edit ubication node and its edges
System.out.println Eliminar ubicacin;delete node all it connetions
System.out.println Calcular ruta ms corta Dijkstra;apply dijkstra for find the shortespath between two nodes
System.out.println Encontrar rbol de expansin mnima Prim; tree of minimal expansion
System.out.println Encontrar rbol de expansin mnima Kruskal;same
System.out.println Optimizar rutas FloydWarshall;floyd To find the shortest path between all locations.
System.out.println Planificar ruta ptima tiempo; to plan routes that minimize time
System.out.println Planificar ruta ptima distancia same but with total distance
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
