I am trying to implement the karger random contraction algorithm which involves selection of 2 adjacent vertices of a graph at random and contracting them till only 2 vertices are left in total.I am using this code for random number generation
#include <time.h>
#include <stdlib.h>
srand(time(NULL));
int r = rand() % v; (v is the number of vertices in the graph and will decrease by 1 for every contraction)
my input data is like:
1 (adjacency list of 1)
2 (adjacency list of 2)
3 (adjacency list of 3) so on till 200 vertices and their adjacency lists.
Since i have to delete nodes on the go, the two random numbers i generate, i am using them for positions i.e. i will select the vertices at the two positions and contract those two if they are adjacent nodes
I have to run the algorithm approx c*(n log n) times to get the proper min cut,
but i am unable to get min cut < 20 ,What am i doing wrong?I think "Its not random enough" how can i improve my solution?