Research Article

A Gradual Approach for Multimodel Journey Planning: A Case Study in Izmir, Turkey

Algorithm 2

Finding routes containing two transfers.
Inputs: origin, origin line ,  , ,
for each node n in Graph:
-n.dist  ≔ infinity;
-n.trCnt  ≔ 0;   //  Transfer Count
-n.previous  ≔ undefined;
origin.dist  ≔ 0;
Q  ≔ Priority queue according to distance;
enqueue origin into Q;
while Q.isEmpty != true:
-u  ≔ node with min distance in Q;
-remove u from Q;
-for each outbound edge e of node u:
--v  ≔ node reachable from u with edge e;
--e.weight  ≔ infinity;
--if e.Line  :
---if u.previous != null: prev_e  ≔  edge used for reaching to u;
----if e is a line:
-----if ((u.trCnt = 2 and e.Line = prev_e.Line) or
          (u.trCnt = 1 and e.Line != prev_e.Line and e.Line    ) or
          (u.trCnt = 1 and e.Line = prev_e.Line) or
          (u.trCnt = 0 and e.Line != prev_e.Line and e.Line    ) or
          (u.trCnt = 0 and e.Line = prev_e.Line)): e.weigth  ≔  ;
----else  //  e is a foot-edge
-----if ((u.trCnt = 0 and prev_e is a line) or
-----(u.trCnt = 1 and prev_e is a line)): e.weigth  ≔  ;
-----else e.weigth  ≔ infinity;
---else  //  u.previous = null:
----if e.Line is : e.weigth  ≔  ;
-for each outbound edge e of node u:
--v  ≔ node reachable from u with edge e;
--prev_e  ≔ edge used for reaching to u;
--dist_v  ≔  u.dist + e.weigth;
--if dist_v < v.dist:
---dequeue v from Q with key v.dist;
---v.dist  ≔  dist_v;
---v.previous  ≔  u;
---v.trCnt  ≔  u.trCnt;
---if e.Line != prev_e.Line: v.trCnt  ≔  u.trCnt + 1;
---enqueue v into Q with key dist_v;
S  ≔ empty sequence;
u  ≔ target;
while u.previous is not null:
-insert u into S;
-u  ≔  u.previous;