# OK to post homework # Salman Manzoor, 4/6/25, Assignment 18 read `C18.txt`: with(Statistics): AveLengthSP:=proc(G,a) local dists, lis, i, curr, j, totaldist: dists:=G[3]: lis:=DijP(G,a)[2]: totaldist:=0: for i from 1 to nops(lis) do curr:=a: for j from 2 to nops(lis[i]) do totaldist+=dists[{curr,lis[i][j]}]: curr:=lis[i][j]: od: od: totaldist/G[1]: end: AveLengthStat:=proc(n,p,K,M) local S,ra,i,G,a: S:=[]: ra:=rand(1..n): for i from 1 to M do G:=RWG(n,p,K): a:=ra(): S:=[op(S),AveLengthSP(G,a)]: od: [Mean(S),Variance(S)]: end: