Here is my code for the karger min cut algorithm.. To the best of my knowledge the algorithm i have implemented is right. But I don get the answer right. If someone can check wh
I totally agree with the above answers. But when I run your code with Python 3.x, it turns out to produce Code 1. This code sometimes works, but sometimes fails. In fact, as @user_3317704 mentioned above, there is a mistake in your code:
for edge in edgelist:
if edge[0] == edge[1]:
edgelist.remove(edge)
You should not change the items of the list when you do a for-do. It raises mistakes. For your reference, it could be
newEdgeList = edgeList.copy();
for edge in edgeList:
if edge[0] == edge[1]:
newEdgeList.remove(edge);
edgeList = newEdgeList;