I discovered this lib this week, and my first project works, I modelize simple flight booking.
As edge I have created an Flight Class As vertex I have created an Airport Class
I put duration for each flight and succeed to associate dijsktra algorithm (DijkstraShortestPath)
class Airport {
String name;
}
class Flight {
String flight;
int duration;
}
g = new DirectedSparseMultigraph<Airport, Flight>();
Flight AXXX = new Flight("A57",3);
Flight AYYY = new Flight("A53",1);
ORY = new Airport("ORY");
LYS = new Airport("LYS");
g.addEdge(AXXX, ORY, LYS);
g.addEdge(AYYY, LYS, ORY);
Transformer<Flight, Integer> wtTransformer = new Transformer<Flight, Integer>() {
@Override
public Integer transform(Flight link) {
return link.duration;
}
};
DijkstraShortestPath<Airport, Flight> alg = new DijkstraShortestPath(g, wtTransformer);
Number dist = alg.getDistance(ORY, LYS);
This simple case works well, but now I would to calculate duration as: Flight1 start 12/01/13 at 12:00 and arrival at 13/01/13 at 14h Flight2 start 13/01/13 at 18:00 and arrival at 13/01/13 at 20h
In this case I want to calculate duration of flight AND between flight. Cause to get shortest path from one to another flight we need to take care about time to wait between flight and not only flight duration. But DiskstraShortestPath allow only Transformer as: Transformer so I can’t get reference to previous flight to calculate total duration (wait + flight).
So my question is: what is the best way for my case ? Create new algorithm (inherit DijsktraShortestPath…) Create new GraphType (inherit DirectedSparseMultigraph…)
Thanks for you answer guy ;) !