• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

sst/elements/genericProc/programs/MTGL/test/test_find_degree_distribution.h

Go to the documentation of this file.
00001 /*  _________________________________________________________________________
00002  *
00003  *  MTGL: The MultiThreaded Graph Library
00004  *  Copyright (c) 2008 Sandia Corporation.
00005  *  This software is distributed under the BSD License.
00006  *  Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
00007  *  the U.S. Government retains certain rights in this software.
00008  *  For more information, see the README file in the top MTGL directory.
00009  *  _________________________________________________________________________
00010  */
00011 
00012 /****************************************************************************/
00013 /*! \file test_find_degree_distribution.h
00014 
00015     \author Vitus Leung (vjleung@sandia.gov)
00016 
00017     \date 3/3/2008
00018 */
00019 /****************************************************************************/
00020 
00021 #include <cmath>
00022 
00023 #include <mtgl/util.hpp>
00024 #include <mtgl/metrics.hpp>
00025 
00026 using namespace mtgl;
00027 
00028 #ifndef GET_FREQ
00029 #define GET_FREQ
00030 
00031 double get_freq()
00032 {
00033 #ifdef __MTA__
00034   double freq = mta_clock_freq();
00035 #else
00036   double freq = 1000000;
00037 #endif
00038   return freq;
00039 }
00040 #endif
00041 
00042 template <typename graph>
00043 void test_find_degree_distribution(graph& g)
00044 {
00045   int ord = num_vertices(g);
00046   int size = num_edges(g);
00047   int maxdegree = (int) ceil(log(2. * ord - 1) / log(2.)) + 1;
00048   double* result = (double*) malloc(maxdegree * sizeof(double));
00049 
00050   find_degree_distribution<graph> fdd(g, result, "dd_test.out");
00051   int ticks1 = fdd.run();
00052   fprintf(stdout, "degree distribution:\n");
00053 
00054   for (int i = 0; i < maxdegree; ++i)
00055   {
00056     fprintf(stdout, "%2d %lf\n", i, result[i]);
00057   }
00058 
00059   fprintf(stderr, "RESULT: find_degree_distrbution %lu (%6.2lf, 0)\n",
00060           size, ticks1/get_freq());
00061 
00062   free(result);
00063 }

Generated on Fri Oct 22 2010 11:02:23 for SST by  doxygen 1.7.1