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

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


Author: marci
Date: Mon May 10 10:25:10 2004
New Revision: 772

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

Log:
comleteGraph


Modified: hugo/trunk/src/hugo/graph_wrapper.h
==============================================================================
--- hugo/trunk/src/hugo/graph_wrapper.h	(original)
+++ hugo/trunk/src/hugo/graph_wrapper.h	Mon May 10 10:25:10 2004
@@ -465,6 +465,25 @@
 
     /// Returns true if \c n is hidden.
     bool hidden(const Edge& e) const { return !(*edge_filter_map)[e]; }
+
+    /// This is a linear time operation an works only if 
+    /// NodeIt is defined.
+    int nodeNum() const { 
+      int i=0;
+      NodeIt n;
+      for (this->first(n); this->valid(n); this->next(n)) ++i;
+      return i; 
+    }
+
+    /// This is a linear time operation and works only if 
+    /// EdgeIt is defined.
+    int edgeNum() const { 
+      int i=0;
+      EdgeIt e;
+      for (this->first(e); this->valid(e); this->next(e)) ++i;
+      return i; 
+    }
+
   };
 
 
@@ -1318,6 +1337,5 @@
 
 } //namespace hugo
 
-
 #endif //HUGO_GRAPH_WRAPPER_H
 

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 10:25:10 2004
@@ -61,4 +61,18 @@
       g.addEdge(s_nodes[random(a)], t_nodes[random(b)]);
   }
 
+  /// Generates a complete graph in the undirected sense 
+  /// with n nodes and m edges.
+  /// Before generating the random graph, \c g.clear() is called.
+  template<typename Graph>
+  void completeGraph(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]);
+  }
+  
 } //namespace hugo



More information about the Lemon-commits mailing list