random graph generate function, fix random length bug