Skip to content

Instantly share code, notes, and snippets.

@YounesCheikh
Created October 15, 2012 09:44
Show Gist options
  • Save YounesCheikh/3891723 to your computer and use it in GitHub Desktop.
Save YounesCheikh/3891723 to your computer and use it in GitHub Desktop.
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