jacint@534: // -*- c++ -*- jacint@534: //randomGraph(i,j) gives a random graph on i nodes and j edges. jacint@534: #include jacint@534: #include jacint@534: jacint@534: //#include jacint@534: //#include jacint@534: //#include jacint@534: //#include jacint@534: //#include jacint@534: //#include jacint@534: //#include jacint@534: jacint@534: namespace hugo { jacint@534: jacint@534: jacint@534: /** jacint@534: * Inicializalja a veletlenszamgeneratort. jacint@534: * Figyelem, ez nem jo igazi random szamokhoz, jacint@534: * erre ne bizzad a titkaidat! jacint@534: */ jacint@534: void random_init() jacint@534: { jacint@534: unsigned int seed = getpid(); jacint@534: seed |= seed << 15; jacint@534: seed ^= time(0); jacint@534: jacint@534: srand(seed); jacint@534: } jacint@534: jacint@534: jacint@534: /** jacint@534: * Egy veletlen int-et ad vissza 0 es m-1 kozott. jacint@534: */ jacint@534: int random(int m) jacint@534: { jacint@534: return int( double(m) * rand() / (RAND_MAX + 1.0) ); jacint@534: } jacint@534: jacint@534: jacint@534: template jacint@534: void randomGraph (Graph& g, int n, int m) { jacint@534: typedef typename Graph::Node Node; jacint@534: g.clear(); jacint@534: std::vector nodes; jacint@534: for (int i=0; i