(1) | function Shortest_Path(↓SV, ↓FV, ↓L, ↑Topol) |
(2) | Topol ← ∅ |
(3) | correct ← true |
(4) | Start_Finish_Test(↓SV, ↓FV, ↓L, ↑↓correct) // admissibility of the start/finish vertices |
(5) | if correct then |
(6) | General_Init() // setting initial marks of all vertices |
(7) | Start_Finish_Init(↓SV, ↓FV) // initialisation activities related to the start/finish vertices |
(8) | Start_Mark(↓SV, ↓L) // remarking of transit successors of the start/finish vertices |
(9) | repeat |
(10) | if TV ≠ ∅ then |
(11) | Vert_Select(↑) // selection of a new current vertex |
(12) | if UV ≠ FVthen |
(13) | Succ_Mark(↓, ↓L) // remarking successors of the current vertex |
(14) | end |
(15) | end |
(16) | until (TV = ∅ or UV = FV) // algorithm termination testing |
(17) | Get_Path(↑↓Topol) // getting a topology of the shortest path |
(18) | end |
(19) | end |
(20) | function Start_Finish_Test(↓SV, ↓FV, ↓L, ↓↑okay) |
(21) | if (SV = ∅ or FV = ∅) then |
(22) | okay ← false |
(23) | exit |
(24) | end |
(25) | for each ∈ SVdo |
(26) | Get_Indexes(↓, ↑i, ↑x) |
(27) | for each ∈ FVdo |
(28) | Get_Indexes(↓, ↑j, ↑y) |
(29) | if (x = y and i ≠ j) then |
(30) | okay ← false // inadmissible combination of the start and finish vertices |
(31) | exit |
(32) | end |
(33) | if (ω () < L or κ () < L) then |
(34) | okay ← false // inadmissible weights/vacancies of the start/finish vertices |
(35) | exit |
(36) | end |
(37) | end |
(38) | end |
(39) | end |
(40) | function General_Init() |
(41) | for z = 1 to n\2 do // symbol “\” denotes an integer division |
(42) | for k = 1 to 2 do |
(43) | ← d∞ // initialisation of the row vector of distance marks |
(44) | ← none // initialisation of the row vector of marks-predecessors |
(45) | end |
(46) | end |
(47) | TV ← ∅ |
(48) | UV ← ∅ |
(49) | end |
(50) | function Start_Finish_Init(↓SV, ↓FV) |
(51) | for each ∈ SVdo |
(52) | Get_Indexes(↓, ↑i, ↑x) |
(53) | for each ∈ FVdo |
(54) | Get_Indexes(↓, ↑j, ↑y) |
(55) | a ← (3 − i) |
(56) | b ← (3 − j) |
(57) | if SV = FVthen |
(58) | XV ← {} // the forbidden vertex is a pair vertex to the start vertex |
(59) | else |
(60) | XV ← {, } // the forbidden vertex is a pair vertex to the finish vertex |
(61) | ← 0 // initialisation of selected distance marks |
(62) | end |
(63) | end |
(64) | end |
(65) | end |
(66) | function Start_Mark(↓SV, ↓L) |
(67) | for each ∈ SVdo |
(68) | for each ∈ () do |
(69) | if ( ∉ XVand κ () ≥ L) then |
(70) | TV ← TV ∪ {} // insertion of admissible transit successors into the set TV |
(71) | ← 0 // initialisation of selected distance marks |
(72) | ← // initialisation of selected marks-predecessors |
(73) | end |
(74) | end |
(75) | end |
(76) | end |
(77) | function Vert_Select(↑) |
(78) | if TV ≠ ∅ then |
(79) | Min_Dist(↓TV, ↑) // selection of a vertex with the lowest distance mark |
(80) | TV ← TV − {} |
(81) | if ∈ FVthen |
(82) | UV ← UV ∪ {} |
(83) | end |
(84) | end |
(85) | end |
(86) | function Try_Change_Mark(↓, ↓) |
(87) | Get_Indexes(↓, ↑k, ↑z) |
(88) | Get_Indexes(↓, ↑l, ↑s) |
(89) | if > + ε ([, ]) then |
(90) | ← + ε ([, ]) // remarking of the successor () of the vertex |
(91) | ← |
(92) | if ∉ TVthen |
(93) | TV ← TV ∪ {} |
(94) | end |
(95) | end |
(96) | end |
(97) | function Succ_Mark(↓, ↓L) |
(98) | for each ∈ ()do |
(99) | if ( ∉ XVand κ () ≥ L and κ () = ω ()) then |
(100) | Try_Change_Mark(↓, ↓) // potential remarking of the transit successor of |
(101) | end |
(102) | end |
(103) | for each ∈ () do |
(104) | if ( ∉ XVand κ () ≥ L) then |
(105) | Try_Change_Mark(↓, ↓) // potential remarking of the reverse successor of |
(106) | end |
(107) | end |
(108) | end |
(109) | function Get_Path(↑↓Seq) |
(110) | if UV ≠ ∅ then |
(111) | Min_Dist(↓UV, ↑) |
(112) | Get_Indexes(↓, ↑j, ↑y) |
(113) | z ← y |
(114) | k ← j |
(115) | i ← 0 |
(116) | while ( ≠ none or ∈ SV) do |
(117) | Seq ← Seq ∪ {[i, ]} // successive reconstruction of the shortest path topology |
(118) | if ∈ SVthen |
(119) | exit |
(120) | end |
(121) | Predecessor(↓, ↑l, ↑t) // getting a predecessor of the vertex |
(122) | z ← t |
(123) | k ← l |
(124) | i ← i + 1 |
(125) | end |
(126) | end |
(127) | end |