jacint@534: // -*- c++ -*- 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: marci@558: /// Generates a random graph with n nodes and m edges. marci@558: /// Before generating the random graph, \c g.clear() is called. jacint@534: template marci@558: void randomGraph(Graph& g, int n, int m) { jacint@534: g.clear(); marci@558: std::vector nodes; jacint@534: for (int i=0; i marci@558: void randomBipartiteGraph(Graph& g, int a, int b, int m) { marci@558: g.clear(); marci@558: std::vector s_nodes; marci@558: std::vector t_nodes; marci@558: for (int i=0; i