src/work/jacint/graph_gen.h
changeset 597 a6e2b02f496a
parent 558 4cbfb435ec2b
child 598 1faa5bec1717
equal deleted inserted replaced
1:84a52d907f08 2:b23dcdc2233b
    59       t_nodes.push_back(g.addNode(true));
    59       t_nodes.push_back(g.addNode(true));
    60     for (int i=0; i<m; ++i) 
    60     for (int i=0; i<m; ++i) 
    61       g.addEdge(s_nodes[random(a)], t_nodes[random(b)]);
    61       g.addEdge(s_nodes[random(a)], t_nodes[random(b)]);
    62   }
    62   }
    63 
    63 
       
    64   /// Generates a complete graph in the undirected sense 
       
    65   /// with n nodes and m edges.
       
    66   /// Before generating the random graph, \c g.clear() is called.
       
    67   template<typename Graph>
       
    68   void completeGraph(Graph& g, int n) {
       
    69     g.clear();
       
    70     std::vector<typename Graph::Node> nodes;
       
    71     for (int i=0; i<n; ++i)
       
    72       nodes.push_back(g.addNode());
       
    73     for (int i=0; i<n; ++i) 
       
    74       for (int j=i+1; j<n; ++j)
       
    75 	g.addEdge(nodes[i], nodes[j]);
       
    76   }
       
    77   
    64 } //namespace hugo
    78 } //namespace hugo