Flight reservation Graph question

  • Zuzu

    Hello Everyone

    First of all, well done, this lib is really great !
    I discovered this lib this week, and my first project works, I am modelize simple flight reservation.

    As edge I have created an Flight Class
    As vertex I have created an Airport Class

    I have put duration for each flight and succeed to associated 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>() {
                public Integer transform(Flight link) {
                        return link.duration;                
            DijkstraShortestPath<Airport, Flight> alg = new DijkstraShortestPath(g, wtTransformer);        
            Number dist = alg.getDistance(LAI, MRS);

    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 durate from flight AND between flight. Cause to get shortest path from one to another flight we need to take care about time to way between flight and not only flight duration.
    But DiskstraShortestPath allow only Transformer as: Transformer<Object, Integer> 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 ;) !