Implementing Karger algorithm for graph minimum cut