this is quite memory inefficient, having to store O(N^2) size array. I just checked in a method to generate undirected graph to master. please check it out.