HavoqGT
havoqgt::rmat_edge_generator Class Reference

#include <rmat_edge_generator.hpp>

Classes

class  input_iterator_type
 InputIterator class for rmat_edge_generator. More...
 

Public Types

typedef uint64_t vertex_descriptor
 
typedef std::pair< uint64_t, uint64_t > edge_type
 

Public Member Functions

 rmat_edge_generator (uint64_t seed, uint64_t vertex_scale, uint64_t edge_count, double a, double b, double c, double d, bool scramble, bool undirected)
 seed used to be 5489 More...
 
input_iterator_type begin ()
 Returns the begin of the input iterator. More...
 
input_iterator_type end ()
 Returns the end of the input iterator. More...
 
void sanity_max_vertex_id ()
 
uint64_t max_vertex_id ()
 
size_t size ()
 

Protected Member Functions

edge_type generate_edge ()
 Generates a new RMAT edge. This function was adapted from the Boost Graph Library. More...
 
edge_type generate_edge (boost::uniform_01< boost::mt19937 > &gen)
 

Protected Attributes

const uint64_t m_seed
 
boost::mt19937 m_rng
 
boost::uniform_01< boost::mt19937 > m_gen
 
const uint64_t m_vertex_scale
 
const uint64_t m_edge_count
 
const bool m_scramble
 
const bool m_undirected
 
const double m_rmat_a
 
const double m_rmat_b
 
const double m_rmat_c
 
const double m_rmat_d
 

Detailed Description

RMAT edge generator, based on Boost Graph's RMAT generator

Options include scrambling vertices based on a hash funciton, and symmetrizing the list. Generated edges are not sorted. May contain duplicate and self edges.

Definition at line 68 of file rmat_edge_generator.hpp.

Member Typedef Documentation

typedef std::pair<uint64_t, uint64_t> havoqgt::rmat_edge_generator::edge_type

Definition at line 72 of file rmat_edge_generator.hpp.

Definition at line 71 of file rmat_edge_generator.hpp.

Constructor & Destructor Documentation

havoqgt::rmat_edge_generator::rmat_edge_generator ( uint64_t  seed,
uint64_t  vertex_scale,
uint64_t  edge_count,
double  a,
double  b,
double  c,
double  d,
bool  scramble,
bool  undirected 
)
inline

seed used to be 5489

Definition at line 150 of file rmat_edge_generator.hpp.

153  : m_seed(seed)
154  , m_rng(seed)
155  , m_gen(m_rng)
156  , m_vertex_scale(vertex_scale)
157  , m_edge_count(edge_count)
158  , m_scramble(scramble)
159  , m_undirected(undirected)
160  , m_rmat_a(a)
161  , m_rmat_b(b)
162  , m_rmat_c(c)
163  , m_rmat_d(d) {
164 
165  // sanity_max_vertex_id();
166 
167  // #ifdef DEBUG
168  // auto itr1 = begin();
169  // auto itr2 = begin();
170  // while (itr1 != end()) {
171  // assert(itr2 != end());
172  // assert(*itr1 == *itr2);
173  // assert(itr1 == itr2);
174  // itr1++;
175  // itr2++;
176  // }
177  // #endif
178  }
boost::uniform_01< boost::mt19937 > m_gen

Member Function Documentation

input_iterator_type havoqgt::rmat_edge_generator::begin ( )
inline

Returns the begin of the input iterator.

Definition at line 182 of file rmat_edge_generator.hpp.

182  {
183  return input_iterator_type(this, 0);
184  }

Here is the caller graph for this function:

input_iterator_type havoqgt::rmat_edge_generator::end ( )
inline

Returns the end of the input iterator.

Definition at line 187 of file rmat_edge_generator.hpp.

187  {
188  return input_iterator_type(this, m_edge_count);
189  }

Here is the caller graph for this function:

edge_type havoqgt::rmat_edge_generator::generate_edge ( )
inlineprotected

Generates a new RMAT edge. This function was adapted from the Boost Graph Library.

Definition at line 215 of file rmat_edge_generator.hpp.

215  {
216  return generate_edge(m_gen);
217  }
edge_type generate_edge()
Generates a new RMAT edge. This function was adapted from the Boost Graph Library.
boost::uniform_01< boost::mt19937 > m_gen

Here is the caller graph for this function:

edge_type havoqgt::rmat_edge_generator::generate_edge ( boost::uniform_01< boost::mt19937 > &  gen)
inlineprotected

Definition at line 218 of file rmat_edge_generator.hpp.

218  {
219  double rmat_a = m_rmat_a;
220  double rmat_b = m_rmat_b;
221  double rmat_c = m_rmat_c;
222  double rmat_d = m_rmat_d;
223  uint64_t u = 0, v = 0;
224  uint64_t step = (uint64_t(1) << m_vertex_scale)/2;
225  for (unsigned int j = 0; j < m_vertex_scale; ++j) {
226  double p = gen();
227 
228  if (p < rmat_a)
229  ;
230  else if (p >= rmat_a && p < rmat_a + rmat_b)
231  v += step;
232  else if (p >= rmat_a + rmat_b && p < rmat_a + rmat_b + rmat_c)
233  u += step;
234  else { // p > a + b + c && p < a + b + c + d
235  u += step;
236  v += step;
237  }
238 
239  step /= 2;
240 
241  // 0.2 and 0.9 are hardcoded in the reference SSCA implementation.
242  // The maximum change in any given value should be less than 10%
243  rmat_a *= 0.9 + 0.2 * gen();
244  rmat_b *= 0.9 + 0.2 * gen();
245  rmat_c *= 0.9 + 0.2 * gen();
246  rmat_d *= 0.9 + 0.2 * gen();
247 
248  double S = rmat_a + rmat_b + rmat_c + rmat_d;
249 
250  rmat_a /= S; rmat_b /= S; rmat_c /= S;
251  // d /= S;
252  // Ensure all values add up to 1, regardless of floating point errors
253  rmat_d = 1. - rmat_a - rmat_b - rmat_c;
254  }
255  if(m_scramble) {
256  u = havoqgt::detail::hash_nbits(u, m_vertex_scale);
257  v = havoqgt::detail::hash_nbits(v, m_vertex_scale);
258  }
259 
260  return std::make_pair(u, v);
261  }
#define S(x)
Definition: error.hpp:57
uint64_t hash_nbits(uint64_t input, int n)
Definition: hash.hpp:115

Here is the call graph for this function:

uint64_t havoqgt::rmat_edge_generator::max_vertex_id ( )
inline

Definition at line 205 of file rmat_edge_generator.hpp.

205  {
206  return (uint64_t(1) << uint64_t(m_vertex_scale)) - 1;
207  }

Here is the caller graph for this function:

void havoqgt::rmat_edge_generator::sanity_max_vertex_id ( )
inline

Definition at line 191 of file rmat_edge_generator.hpp.

191  {
192  auto itr = begin();
193  auto itr_end = end();
194 
195  uint64_t value = 0;
196  while (itr != itr_end) {
197  value = std::max(value, (*itr).first);
198  value = std::max(value, (*itr).second);
199  }
200 
201  std::cout << " value: " << value << std::endl;
202  assert(max_vertex_id() == value);
203 
204  }
input_iterator_type begin()
Returns the begin of the input iterator.
input_iterator_type end()
Returns the end of the input iterator.

Here is the call graph for this function:

size_t havoqgt::rmat_edge_generator::size ( )
inline

Definition at line 209 of file rmat_edge_generator.hpp.

209  {
210  return m_edge_count;
211  }

Member Data Documentation

const uint64_t havoqgt::rmat_edge_generator::m_edge_count
protected

Definition at line 268 of file rmat_edge_generator.hpp.

boost::uniform_01<boost::mt19937> havoqgt::rmat_edge_generator::m_gen
protected

Definition at line 266 of file rmat_edge_generator.hpp.

const double havoqgt::rmat_edge_generator::m_rmat_a
protected

Definition at line 271 of file rmat_edge_generator.hpp.

const double havoqgt::rmat_edge_generator::m_rmat_b
protected

Definition at line 272 of file rmat_edge_generator.hpp.

const double havoqgt::rmat_edge_generator::m_rmat_c
protected

Definition at line 273 of file rmat_edge_generator.hpp.

const double havoqgt::rmat_edge_generator::m_rmat_d
protected

Definition at line 274 of file rmat_edge_generator.hpp.

boost::mt19937 havoqgt::rmat_edge_generator::m_rng
protected

Definition at line 265 of file rmat_edge_generator.hpp.

const bool havoqgt::rmat_edge_generator::m_scramble
protected

Definition at line 269 of file rmat_edge_generator.hpp.

const uint64_t havoqgt::rmat_edge_generator::m_seed
protected

Definition at line 264 of file rmat_edge_generator.hpp.

const bool havoqgt::rmat_edge_generator::m_undirected
protected

Definition at line 270 of file rmat_edge_generator.hpp.

const uint64_t havoqgt::rmat_edge_generator::m_vertex_scale
protected

Definition at line 267 of file rmat_edge_generator.hpp.


The documentation for this class was generated from the following file: