linear time complexity on creating random edges for small values of p