[Lemon-commits] [lemon_svn] marci: r778 - hugo/trunk/src/work/jacint

Lemon SVN svn at lemon.cs.elte.hu
Mon Nov 6 20:41:26 CET 2006


Author: marci
Date: Mon May 10 18:32:21 2004
New Revision: 778

Modified:
   hugo/trunk/src/work/jacint/graph_gen.h

Log:
complete graphs


Modified: hugo/trunk/src/work/jacint/graph_gen.h
==============================================================================
--- hugo/trunk/src/work/jacint/graph_gen.h	(original)
+++ hugo/trunk/src/work/jacint/graph_gen.h	Mon May 10 18:32:21 2004
@@ -62,7 +62,7 @@
   }
 
   /// Generates a complete graph in the undirected sense 
-  /// with n nodes and m edges.
+  /// with n nodes.
   /// Before generating the random graph, \c g.clear() is called.
   template<typename Graph>
   void completeGraph(Graph& g, int n) {
@@ -74,5 +74,39 @@
       for (int j=i+1; j<n; ++j)
 	g.addEdge(nodes[i], nodes[j]);
   }
+
+  /// Generates a complete bidirected graph on n nodes.
+  /// Before generating the random graph, \c g.clear() is called.
+  template<typename Graph>
+  void completeBidirectedGraph(Graph& g, int n) {
+    g.clear();
+    std::vector<typename Graph::Node> nodes;
+    for (int i=0; i<n; ++i)
+      nodes.push_back(g.addNode());
+    for (int i=0; i<n; ++i) 
+      for (int j=i+1; j<n; ++j) {
+	g.addEdge(nodes[i], nodes[j]);	
+	g.addEdge(nodes[j], nodes[i]);
+      }
+  }
+
+  /// Generates a complete bipartite graph with a and b nodes 
+  /// in the color classes.
+  /// Before generating the random graph, \c g.clear() is called.
+  template<typename Graph>
+  void completeBipartiteGraph(Graph& g, int a, int b) {
+    g.clear();
+    std::vector<typename Graph::Node> s_nodes;
+    std::vector<typename Graph::Node> t_nodes;
+    for (int i=0; i<a; ++i)
+      ///\bug g.addNode(g.S_CLASS) would be better.
+      s_nodes.push_back(g.addNode(false));
+    for (int i=0; i<b; ++i)
+      ///\bug g.addNode(g.T_CLASS) would be better.
+      t_nodes.push_back(g.addNode(true));
+    for (int i=0; i<a; ++i) 
+      for (int j=0; j<b; ++j)       
+	g.addEdge(s_nodes[i], t_nodes[j]);
+  }
   
 } //namespace hugo



More information about the Lemon-commits mailing list