Download presentation
Presentation is loading. Please wait.
1
Shortest Path Algorithm (Chandy-Misra 1982): Model and Pseudo Code ididi Smallest Model © Béat Hirsbrunner, University of Fribourg, Switzerland, 1995, rev. 2006 d i + c i1 d i + c ik = min (old d i, d) d
2
1 i (d i + c i1, i) didi = min (old d i, d 1..d n ) ack (d i + c ik, i) ack pred = … num = … succ 1 succ k pred 1 Smallest Model (with Acknowledgment) (d 1, pred 1 ) pred n (d n, pred n ) ack …
3
2 Receive( ) Send( ) to Succ 2 3 1 Succ d Site i Smallest Model (revisited) Pred
4
3 exp Send( ) to Succ Receive( ) 2 3 1 Succ Pred d pred Site i Receive( ) Send( ) to Succ num Send( ) to pred pred Receive(ack) Smallest Complete Model (with termination for non-negative graphs)
5
4 Primitives (01) Send( ) to recipients (02) Receive( )
6
5 (01) InitLocalSourceNodeVariables; (02) Send( ) to all sj in Succ; Initialization : Source Node (without termination) (03) InitLocalNodeVariables; Initialization : Intermediate Nodes (without termination) -- nothing ! Code : Source Node (without termination) LOOP (04) Receive( ) | IF dist < d THEN (05) Update(d); (06) Send( ) to all sj in Succ; END IF; END LOOP; Code : Intermediate Nodes (without termination)
7
6 LOOP SELECT (05) Receive( ) | Send( ) to exp; (06) Receive( ) | Dec(num); (07) IF num = 0 THEN (08) send( ) to all sj in Succ; (09) EXIT LOOP SELECT; END IF; END LOOP SELECT; Code : Source Node (with termination for non-negative graphs) (04) InitLocalNodeVariables; Initialization : Intermediate Nodes (with termination) (01) InitLocalSourceNodeVariables; (02) Send( ) to all sj in Succ; (03) Update(num); Initialization : Source Node (with termination)
8
7 LOOP SELECT (10) Receive( ) | IF dist < d THEN (11 ack!) IF num > 0 THEN Send( ) to pred; END IF; (12) Update(d,pred,num); (13) Send( ) to all sj in Succ; (14 ack!) IF Succ = {} THEN Send( ) to pred; END IF; ELSE (15 ack!) Send( ) to exp; END IF; (16) Receive( ) | Dec(num); (17 ack!) IF num = 0 THEN Send( ) to pred; END IF; (18) Receive( ) | Send( ) to all sj in Succ; (19) EXIT LOOP SELECT; END LOOP SELECT; Code : Intermediate Nodes (with termination for non-negative graphs)
Similar presentations
© 2025 SlidePlayer.com Inc.
All rights reserved.