# HG changeset patch # User marci # Date 1083864131 0 # Node ID 4cbfb435ec2b5ef8d9b337373f149562580191f1 # Parent 9c0ce0a1f00092eb4e71f87a2c6e7cb9dc385414 random graph, random bipartite graph in jacint/graph_gen.h diff -r 9c0ce0a1f000 -r 4cbfb435ec2b src/work/jacint/graph_gen.h --- a/src/work/jacint/graph_gen.h Thu May 06 17:01:31 2004 +0000 +++ b/src/work/jacint/graph_gen.h Thu May 06 17:22:11 2004 +0000 @@ -1,16 +1,7 @@ // -*- c++ -*- -//randomGraph(i,j) gives a random graph on i nodes and j edges. #include #include -//#include -//#include -//#include -//#include -//#include -//#include -//#include - namespace hugo { @@ -38,15 +29,36 @@ } + /// Generates a random graph with n nodes and m edges. + /// Before generating the random graph, \c g.clear() is called. template - void randomGraph (Graph& g, int n, int m) { - typedef typename Graph::Node Node; + void randomGraph(Graph& g, int n, int m) { g.clear(); - std::vector nodes; + std::vector nodes; for (int i=0; i + void randomBipartiteGraph(Graph& g, int a, int b, int m) { + g.clear(); + std::vector s_nodes; + std::vector t_nodes; + for (int i=0; i #include #include -#include #include //#include @@ -13,6 +12,7 @@ #include #include #include +#include using namespace hugo; @@ -79,27 +79,6 @@ int matchingValue() { return mf.flowValue(); } }; -/** - * Inicializalja a veletlenszamgeneratort. - * Figyelem, ez nem jo igazi random szamokhoz, - * erre ne bizzad a titkaidat! - */ -void random_init() -{ - unsigned int seed = getpid(); - seed |= seed << 15; - seed ^= time(0); - - srand(seed); -} - -/** - * Egy veletlen int-et ad vissza 0 es m-1 kozott. - */ -int random(int m) -{ - return int( double(m) * rand() / (RAND_MAX + 1.0) ); -} int main() { //typedef UndirListGraph Graph; @@ -113,9 +92,6 @@ Graph g; - std::vector s_nodes; - std::vector t_nodes; - int a; std::cout << "number of nodes in the first color class="; std::cin >> a; @@ -127,13 +103,8 @@ std::cin >> m; std::cout << "Generatig a random bipartite graph..." << std::endl; - for (int i=0; i