Changeset 598:1faa5bec1717 in lemon0.x for src/work
 Timestamp:
 05/10/04 18:32:21 (17 years ago)
 Branch:
 default
 Phase:
 public
 Convert:
 svn:c9d7d8f590d60310b91f818b3a526b0e/lemon/trunk@778
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

src/work/jacint/graph_gen.h
r593 r598 63 63 64 64 /// Generates a complete graph in the undirected sense 65 /// with n nodes and m edges.65 /// with n nodes. 66 66 /// Before generating the random graph, \c g.clear() is called. 67 67 template<typename Graph> … … 75 75 g.addEdge(nodes[i], nodes[j]); 76 76 } 77 78 /// Generates a complete bidirected graph on n nodes. 79 /// Before generating the random graph, \c g.clear() is called. 80 template<typename Graph> 81 void completeBidirectedGraph(Graph& g, int n) { 82 g.clear(); 83 std::vector<typename Graph::Node> nodes; 84 for (int i=0; i<n; ++i) 85 nodes.push_back(g.addNode()); 86 for (int i=0; i<n; ++i) 87 for (int j=i+1; j<n; ++j) { 88 g.addEdge(nodes[i], nodes[j]); 89 g.addEdge(nodes[j], nodes[i]); 90 } 91 } 92 93 /// Generates a complete bipartite graph with a and b nodes 94 /// in the color classes. 95 /// Before generating the random graph, \c g.clear() is called. 96 template<typename Graph> 97 void completeBipartiteGraph(Graph& g, int a, int b) { 98 g.clear(); 99 std::vector<typename Graph::Node> s_nodes; 100 std::vector<typename Graph::Node> t_nodes; 101 for (int i=0; i<a; ++i) 102 ///\bug g.addNode(g.S_CLASS) would be better. 103 s_nodes.push_back(g.addNode(false)); 104 for (int i=0; i<b; ++i) 105 ///\bug g.addNode(g.T_CLASS) would be better. 106 t_nodes.push_back(g.addNode(true)); 107 for (int i=0; i<a; ++i) 108 for (int j=0; j<b; ++j) 109 g.addEdge(s_nodes[i], t_nodes[j]); 110 } 77 111 78 112 } //namespace hugo
Note: See TracChangeset
for help on using the changeset viewer.