Boost logo

Boost-Commit :

From: asutton_at_[hidden]
Date: 2008-05-30 07:37:16


Author: asutton
Date: 2008-05-30 07:37:16 EDT (Fri, 30 May 2008)
New Revision: 45936
URL: http://svn.boost.org/trac/boost/changeset/45936

Log:
Added missing files.

Added:
   sandbox/SOC/2008/graphs/libs/graphs/add_edges.hpp (contents, props changed)
   sandbox/SOC/2008/graphs/libs/graphs/random_vertex.hpp (contents, props changed)

Added: sandbox/SOC/2008/graphs/libs/graphs/add_edges.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/graphs/libs/graphs/add_edges.hpp 2008-05-30 07:37:16 EDT (Fri, 30 May 2008)
@@ -0,0 +1,21 @@
+
+#ifndef ADD_EDGES_HPP
+#define ADD_EDGES_HPP
+
+#include "random_vertex.hpp"
+
+template <typename Graph>
+void
+add_edges(Graph& g, int n)
+{
+ typedef typename Graph::vertex_descriptor Vertex;
+
+ for(int i = 0; i < n; ++i) {
+ Vertex u = random_vertex(g);
+ Vertex v = random_vertex(g);
+ g.add_edge(u, v);
+ }
+}
+
+#endif
+

Added: sandbox/SOC/2008/graphs/libs/graphs/random_vertex.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/graphs/libs/graphs/random_vertex.hpp 2008-05-30 07:37:16 EDT (Fri, 30 May 2008)
@@ -0,0 +1,21 @@
+
+#ifndef RANDOM_VERTEX_HPP
+#define RANDOM_VERTEX_HPP
+
+#include <boost/utility.hpp>
+
+// Probably an inefficient implementation of a random vertex.
+// This just picks some vertex in the range of vertices.
+template <typename Graph>
+typename Graph::vertex_descriptor
+random_vertex(Graph const& g)
+{
+ using std::rand;
+ using boost::next;
+
+ int n = rand() % g.num_vertices();
+ return *next(g.begin_vertices(), n);
+}
+
+#endif
+


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk