ShortestPath(s, t, G) |
1. Queue1.enQueue(s) |
1. Queue2.enQueue(t) |
2. InitializeDoubleSource(SPCost, Pi, Clr, s, t, G) |
3. Flag ← 0 |
4. While (Queue1 <> Null OR Queue2 <> Null) AND Flag = 0 |
5. Do SPfromSource(SPCost, Pi, Clr, G) |
6. SPfromDestination(SPCost, Pi, Clr, G) |
SPfromSource(G) |
1. while u ← Queue1.deQueue() <> Green |
2. for each v belongs to Adj[u] |
3. do if Clrv = Green OR LightYellow OR LightRed |
4. then Clrv ← LightYellow |
5. SPCostv ← min(SPCostu +W(u,v), SPCostv) |
6. If SPCost is updated |
7. Then Piv ← u |
8. If Clrv = Green OR LightRed |
9. Then Queue.enQueue(v) |
10. If Clrv = DarkRed |
11. Then Concatinate two paths and store |
12. CPCost ← min(CPCostu + CPCostv + w(u,v), CPCost) |
13. If Clrv = DarkYellow |
14. then skip |
15. Clru ← LightRed |
SPfromDestination(G) |
1. while u ← Queue2.deQueue() <> Green |
2. for each v belongs to Adj[u] |
3. do if Clrv = Green OR DarkYellow OR DarkRed |
4. then Clrv ← DarkYellow |
5. SPCostv ← min(SPCostu +W(u,v), SPCostv) |
6. If SPCostv is updated |
7. Then Piv ← u |
8. If Clrv = Green OR DarkRed |
9. Then Queue.enQueue(v) |
10. If Clrv = LightRed |
11. Then Concatinate two paths and store |
12. SPCostv ← min(SPCostu + SPCostv + w(u,v), SPCostv) |
13. If Clrv = LightYellow |
14. then skip |
15. Clru ← DarkRed |