public Graph generateRandomMMapGraph ( String graphName , int size , float dens ) { Graph graph = null ; String dir = "graphs/MMap/" + graphName ; SerializationUtils . deleteMMapGraph ( dir ) ; graph = new Graph ( new MMapGraphStructure ( dir ) ) ; Random rand = new Random ( ) ; for ( int i = 0 ; i < size ; i ++ ) graph . addNode ( new Node ( i ) ) ; for ( int i = 0 ; i < size ; i ++ ) { for ( int j = i + 1 ; j < size ; j ++ ) { if ( rand . nextFloat ( ) < dens ) { int randomCost = Math . abs ( rand . nextInt ( 50 ) ) + 1 ; Edge e = new Edge ( i , j , randomCost ) ; e . setBidirectional ( rand . nextBoolean ( ) ) ; graph . addEdge ( e ) ; } } } return graph ; }
Create a new Graph which has the given graphName size and dens .