Created
October 15, 2012 09:44
-
-
Save YounesCheikh/3891723 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
larg_pcc := proc (G, x) | |
local y, z, CarnetDeVisite, Distance, Pere; | |
global Visite, OrdreVisite; | |
Visite := [seq(false, i = 1 .. nops(G))]; | |
Visite[x] := true; | |
CarnetDeVisite := [x]; | |
OrdreVisite := []; | |
Distance := [seq(-1, i = 1 .. nops(G))]; | |
Pere := linalg:-vector(nops(G), proc (i) options operator, arrow; -1 end proc); Distance[x] := 0; print(Distance); while CarnetDeVisite <> [] do y := CarnetDeVisite[1]; CarnetDeVisite := enleve_tete(CarnetDeVisite); print("Carnet :", CarnetDeVisite, "y=", y, "Visite : ", Visite); OrdreVisite := ajoutFin(y, OrdreVisite); for z in G[y] do if Visite[z] = false then CarnetDeVisite := ajoutFin(z, CarnetDeVisite); Visite[z] := true; Distance[z] := Distance[y]+1; Pere[z] := y end if end do end do; evalm(Pere) end proc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment