rmat_generator.rst 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. .. Copyright (C) 2004-2009 The Trustees of Indiana University.
  2. Use, modification and distribution is subject to the Boost Software
  3. License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  4. http://www.boost.org/LICENSE_1_0.txt)
  5. ===================================
  6. |Logo| R-MAT generator
  7. ===================================
  8. ::
  9. template<typename RandomGenerator, typename Graph>
  10. class rmat_iterator
  11. {
  12. public:
  13. typedef std::input_iterator_tag iterator_category;
  14. typedef std::pair<vertices_size_type, vertices_size_type> value_type;
  15. typedef const value_type& reference;
  16. typedef const value_type* pointer;
  17. typedef void difference_type;
  18. rmat_iterator();
  19. rmat_iterator(RandomGenerator& gen, vertices_size_type n,
  20. edges_size_type m, double a, double b, double c,
  21. double d, bool permute_vertices = true);
  22. // Iterator operations
  23. reference operator*() const;
  24. pointer operator->() const;
  25. rmat_iterator& operator++();
  26. rmat_iterator operator++(int);
  27. bool operator==(const rmat_iterator& other) const;
  28. bool operator!=(const rmat_iterator& other) const;
  29. };
  30. This class template implements a generator for R-MAT graphs [CZF04]_,
  31. suitable for initializing an adjacency_list or other graph structure
  32. with iterator-based initialization. An R-MAT graph has a scale-free
  33. distribution w.r.t. vertex degree and is implemented using
  34. Recursive-MATrix partitioning.
  35. Where Defined
  36. -------------
  37. <``boost/graph/rmat_graph_generator.hpp``>
  38. Constructors
  39. ------------
  40. ::
  41. rmat_iterator();
  42. Constructs a past-the-end iterator.
  43. ::
  44. rmat_iterator(RandomGenerator& gen, vertices_size_type n,
  45. edges_size_type m, double a, double b, double c,
  46. double d, bool permute_vertices = true);
  47. Constructs an R-MAT generator iterator that creates a graph with ``n``
  48. vertices and ``m`` edges. ``a``, ``b``, ``c``, and ``d`` represent
  49. the probability that a generated edge is placed of each of the 4
  50. quadrants of the partitioned adjacency matrix. Probabilities are
  51. drawn from the random number generator gen. Vertex indices are
  52. permuted to eliminate locality when ``permute_vertices`` is true.
  53. Example
  54. -------
  55. ::
  56. #include <boost/graph/adjacency_list.hpp>
  57. #include <boost/graph/rmat_graph_generator.hpp>
  58. #include <boost/random/linear_congruential.hpp>
  59. typedef boost::adjacency_list<> Graph;
  60. typedef boost::rmat_iterator<boost::minstd_rand, Graph> RMATGen;
  61. int main()
  62. {
  63. boost::minstd_rand gen;
  64. // Create graph with 100 nodes and 400 edges
  65. Graph g(RMATGen(gen, 100, 400, 0.57, 0.19, 0.19, 0.05), RMATGen(), 100);
  66. return 0;
  67. }
  68. Bibliography
  69. ------------
  70. .. [CZF04] D Chakrabarti, Y Zhan, and C Faloutsos. R-MAT: A Recursive
  71. Model for Graph Mining. In Proceedings of 4th International Conference
  72. on Data Mining, pages 442--446, 2004.
  73. -----------------------------------------------------------------------------
  74. Copyright (C) 2009 The Trustees of Indiana University.
  75. Authors: Nick Edmonds and Andrew Lumsdaine
  76. .. |Logo| image:: pbgl-logo.png
  77. :align: middle
  78. :alt: Parallel BGL
  79. :target: http://www.osl.iu.edu/research/pbgl