Boost logo

Boost-Commit :

From: asutton_at_[hidden]
Date: 2007-06-06 19:32:03


Author: asutton
Date: 2007-06-06 19:32:03 EDT (Wed, 06 Jun 2007)
New Revision: 4478
URL: http://svn.boost.org/trac/boost/changeset/4478

Log:
Added a simple test program for computing graph stats in
the movies directory - stil very much a work in progress.

Added:
   sandbox/SOC/2007/graphs/libs/graph/examples/movies/stats.cpp
Text files modified:
   sandbox/SOC/2007/graphs/boost/graph/degree_distribution.hpp | 13 ++++++-------
   sandbox/SOC/2007/graphs/libs/graph/examples/movies/Jamfile.v2 | 5 +++++
   2 files changed, 11 insertions(+), 7 deletions(-)

Modified: sandbox/SOC/2007/graphs/boost/graph/degree_distribution.hpp
==============================================================================
--- sandbox/SOC/2007/graphs/boost/graph/degree_distribution.hpp (original)
+++ sandbox/SOC/2007/graphs/boost/graph/degree_distribution.hpp 2007-06-06 19:32:03 EDT (Wed, 06 Jun 2007)
@@ -13,19 +13,18 @@
         typename BidirectionalGraph,
         typename Container
>
- typename graph_traits<BindirectionalGraph>::degree_size_type
+ typename graph_traits<BidirectionalGraph>::degree_size_type
     degree_distribution(BidirectionalGraph &g, Container &dist)
     {
- typedef BidirectionalGraph graph;
- typedef typename graph_traits<Graph>::vertex_descriptor vertex;
- typedef typename graph_traits<Graph>::degree_size_type degree;
+ typedef BidirectionalGraph Graph;
+ typedef typename graph_traits<Graph>::degree_size_type Degree;
 
         // stash the degree of each vertex into its bucket - degree 1
         // goes into index 1, degree 90 goes into index 90, etc.
- degree max = 0;
- vertex_iterator i, j;
+ Degree max = 0;
+ typename Graph::vertex_iterator i, j;
         for(tie(i, j) = vertices(g); i != j; ++i) {
- degree d = degree(*i, g);
+ Degree d = degree(*i, g);
 
             // we may need to resize the array to accomodate the
             // incrementation of this degrees bucket.

Modified: sandbox/SOC/2007/graphs/libs/graph/examples/movies/Jamfile.v2
==============================================================================
--- sandbox/SOC/2007/graphs/libs/graph/examples/movies/Jamfile.v2 (original)
+++ sandbox/SOC/2007/graphs/libs/graph/examples/movies/Jamfile.v2 2007-06-06 19:32:03 EDT (Wed, 06 Jun 2007)
@@ -8,3 +8,8 @@
         : six_degrees.cpp movies.cpp
         : <include>../../../../
         ;
+
+exe movie_stats
+ : stats.cpp movies.cpp
+ : <include>../../../../
+ ;
\ No newline at end of file

Added: sandbox/SOC/2007/graphs/libs/graph/examples/movies/stats.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/graphs/libs/graph/examples/movies/stats.cpp 2007-06-06 19:32:03 EDT (Wed, 06 Jun 2007)
@@ -0,0 +1,36 @@
+// (C) Copyright Andrew Sutton 2007
+//
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0 (See accompanying file
+// LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+
+#include <iostream>
+#include <iterator>
+#include <algorithm>
+
+#include <boost/graph/undirected_graph.hpp>
+#include <boost/graph/degree_distribution.hpp>
+
+#include "movies.hpp"
+
+using namespace std;
+using namespace boost;
+
+int
+main(int argc, char *argv[])
+{
+ Graph g;
+ ActorMap actors;
+
+ // build the movie graph from std input
+ build_movie_graph(cin, g, actors);
+
+ // compute the degree distribution
+ vector<size_t> dist;
+ degree_distribution(g, dist);
+ copy(dist.begin(), dist.end(),
+ ostream_iterator<size_t>(cout, " "));
+ cout << "\n";
+
+ return 0;
+}


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