Here's the line that throws this error
(x,neighbor) = random.sample(out_edge_list,1)
Here's the line that throws this error
(x,neighbor) = random.sample(out_edge_list,1)
You're asking for 1 unique random element. So you're getting back something like [5]. If the 5 goes into x, what goes into neighbor?
Perhaps you meant to ask for 2 elements?
(x, neighbor) = random.sample(out_edge_list, 2)
Here the solution. I changed the line to
(x,neighbor) = random.sample(out_edge_list,1)[0]