# Initialisations la matrice de transition M est à remplir séparément
:Input "Source ",S
:Input "Dest ",D
:dim M(1)→N
:0→m
:For (I,1,N)
: max(m,max(vc▸li M(I))→m
:End
:seq((m+1)*N,I,1,N)→Dist # Distances au sommet initial
:0→Dist(S)
:seq(−1,I,1,N)→Chem # Arbre des plus courts chemins
:seq(1,I,1,N)→NFai # Sommet passé ou non
# Boucle principale
:For (I,1,N)
# Choix du sommet
: (m+1)*N→dmin
: For (J,1,N)
: If Dist(J)<dmin and NFai(J)==1
: Then
: Dist(J)→dmin
: J→T
: End
: End
: 0→NFai(T)
# Recherche du plus court chemin partant de T
: For (J,1,N)
: If NFai(J)==1 and M(T,J)≠0 and M(T,J)+Dist(T)<Dist(J)
: Then
: M(T,J)+Dist(T)→Dist(J)
: T→Chem(J)
: End
: End
:Disp T # Pour afficher l’ordre des sommets choisis
:End
# Affichages finaux
:{D}→Chem1
:D→E
:While E≠S
: Chem(E)→E
: E→Chem1(dimL Chem1+1)
:End
:Disp Chem1 # On part de la destination vers la source
:Disp Dist(D)
IyBJbml0aWFsaXNhdGlvbnMgbGEgbWF0cmljZSBkZSB0cmFuc2l0aW9uIE0gZXN0IMOgIHJlbXBsaXIgc8OpcGFyw6ltZW50Cgo6SW5wdXQgIlNvdXJjZSAiLFMKOklucHV0ICJEZXN0ICIsRAo6ZGltIE0oMSnihpJOCjow4oaSbQo6Rm9yIChJLDEsTikKOgltYXgobSxtYXgodmPilrhsaSBNKEkpKeKGkm0KOkVuZAo6c2VxKChtKzEpKk4sSSwxLE4p4oaSRGlzdCAjIERpc3RhbmNlcyBhdSBzb21tZXQgaW5pdGlhbAo6MOKGkkRpc3QoUykKOnNlcSjiiJIxLEksMSxOKeKGkkNoZW0gIyBBcmJyZSBkZXMgcGx1cyBjb3VydHMgY2hlbWlucwo6c2VxKDEsSSwxLE4p4oaSTkZhaSAjIFNvbW1ldCBwYXNzw6kgb3Ugbm9uCgojIEJvdWNsZSBwcmluY2lwYWxlCgo6Rm9yIChJLD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