Bond percolation (square lattice)

leng=10;
prob=0.3;
g=GridGraph[{leng,leng}];
ESet=EdgeList[g];
GridGraph[{leng,leng},EdgeStyle-> Flatten[Table[{ESet[[k]]-> If[RandomReal[{0,1}]<prob,{Black,Thick},Dashed]},{k,1,Length[ESet]}],1]]

leng=10;
prob=0.5;
g=GridGraph[{leng,leng}];
ESet=EdgeList[g];
GridGraph[{leng,leng},EdgeStyle-> Flatten[Table[{ESet[[k]]-> If[RandomReal[{0,1}]<prob,{Black,Thick},Dashed]},{k,1,Length[ESet]}],1]]

leng=10;
prob=0.7;
g=GridGraph[{leng,leng}];
ESet=EdgeList[g];
GridGraph[{leng,leng},EdgeStyle-> Flatten[Table[{ESet[[k]]-> If[RandomReal[{0,1}]<prob,{Black,Thick},Dashed]},{k,1,Length[ESet]}],1]]

Site percolation (square lattice)

leng=10;
prob=0.3;
GridGraph[{leng,leng},VertexStyle-> Flatten[Table[{k-> If[RandomReal[{0,1}]<prob,Black, White]},{k,1,leng^2}],1],VertexSize-> 0.3]

leng=10;
prob=0.5;
GridGraph[{leng,leng},VertexStyle-> Flatten[Table[{k-> If[RandomReal[{0,1}]<prob,Black, White]},{k,1,leng^2}],1],VertexSize-> 0.3]

leng=10;
prob=0.7;
GridGraph[{leng,leng},VertexStyle-> Flatten[Table[{k-> If[RandomReal[{0,1}]<prob,Black, White]},{k,1,leng^2}],1],VertexSize-> 0.3]

Bond percolation (Cayley tree)

(*leng: number of levels*)
leng=5;
prob=0.3;
g=CompleteKaryTree[leng,2];
ESet=EdgeList[g];
CompleteKaryTree[leng,2,EdgeStyle-> Flatten[Table[{ESet[[k]]-> If[RandomReal[{0,1}]<prob,{Black,Thick}, Dashed]},{k,1,Length[ESet]}],1]]

(*leng: number of levels*)
leng=5;
prob=0.5;
g=CompleteKaryTree[leng,2];
ESet=EdgeList[g];
CompleteKaryTree[leng,2,EdgeStyle-> Flatten[Table[{ESet[[k]]-> If[RandomReal[{0,1}]<prob,{Black,Thick}, Dashed]},{k,1,Length[ESet]}],1]]

(*leng: number of levels*)
leng=5;
prob=0.7;
g=CompleteKaryTree[leng,2];
ESet=EdgeList[g];
CompleteKaryTree[leng,2,EdgeStyle-> Flatten[Table[{ESet[[k]]-> If[RandomReal[{0,1}]<prob,{Black,Thick}, Dashed]},{k,1,Length[ESet]}],1]]

Site percolation (Cayley tree)

(*leng: number of levels*)
leng=5;
prob=0.3;
g=CompleteKaryTree[leng,2];
CompleteKaryTree[leng,2,VertexStyle-> Flatten[Table[{k-> If[RandomReal[{0,1}]<prob,Black, White]},{k,1,Length[VertexList[g]]}],1],VertexSize-> 0.3]

(*leng: number of levels*)
leng=5;
prob=0.5;
g=CompleteKaryTree[leng,2];
CompleteKaryTree[leng,2,VertexStyle-> Flatten[Table[{k-> If[RandomReal[{0,1}]<prob,Black, White]},{k,1,Length[VertexList[g]]}],1],VertexSize-> 0.3]

(*leng: number of levels*)
leng=5;
prob=0.7;
g=CompleteKaryTree[leng,2];
CompleteKaryTree[leng,2,VertexStyle-> Flatten[Table[{k-> If[RandomReal[{0,1}]<prob,Black, White]},{k,1,Length[VertexList[g]]}],1],VertexSize-> 0.3]