Reputation: 1
I am working with a undirected graph which relates some places to have fun in an amusement park. Each vertex is a place and each node gives us the distance and the average time between two places.
How do I change the criteria of the algorithm to decide which edge is shorter, for instance, instead of comparing the edges by distance, comparing them by the avgTime. I have a Graph<Place, Vecinity> where the type Vecinity has two attributes, distance and avgTime between two places.
Here is some of my code:
public static List<Place> exercise2a(Graph<Place,Vecinity> g, Place p1, Place p2) { var alg = new DijkstraShortestPath<Place, Vecinity>(g); return alg.getPath(p1, p2).getVertexList(); }
This method returns the list of places that belong to the shortest path in terms of distance (although i did not specify it), but i want it also in terms of avgTime.
I want first to apply the algorithm according to the distance attribute and then apply it again according to the avgTime attribute.
I am using the Dijkstra algorithm of the library: org.jgrapht.alg.shortestpath.DijkstraShortestPath
of JGraphT.
Specific documentation: Documentation
Upvotes: 0
Views: 84