scalable_rmat_generator.rst 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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| Scalable R-MAT generator
  7. ===================================
  8. ::
  9. template<typename ProcessGroup, typename Distribution,
  10. typename RandomGenerator, typename Graph>
  11. class scalable_rmat_iterator
  12. {
  13. public:
  14. typedef std::input_iterator_tag iterator_category;
  15. typedef std::pair<vertices_size_type, vertices_size_type> value_type;
  16. typedef const value_type& reference;
  17. typedef const value_type* pointer;
  18. typedef void difference_type;
  19. scalable_rmat_iterator();
  20. scalable_rmat_iterator(ProcessGroup pg, Distribution distrib,
  21. RandomGenerator& gen, vertices_size_type n,
  22. edges_size_type m, double a, double b, double c,
  23. double d, bool permute_vertices = true);
  24. // Iterator operations
  25. reference operator*() const;
  26. pointer operator->() const;
  27. scalable_rmat_iterator& operator++();
  28. scalable_rmat_iterator operator++(int);
  29. bool operator==(const scalable_rmat_iterator& other) const;
  30. bool operator!=(const scalable_rmat_iterator& other) const;
  31. };
  32. This class template implements a generator for R-MAT graphs [CZF04]_,
  33. suitable for initializing an adjacency_list or other graph structure
  34. with iterator-based initialization. An R-MAT graph has a scale-free
  35. distribution w.r.t. vertex degree and is implemented using
  36. Recursive-MATrix partitioning.
  37. Where Defined
  38. -------------
  39. <``boost/graph/rmat_graph_generator.hpp``>
  40. Constructors
  41. ------------
  42. ::
  43. scalable_rmat_iterator();
  44. Constructs a past-the-end iterator.
  45. ::
  46. scalable_rmat_iterator(ProcessGroup pg, Distribution distrib,
  47. RandomGenerator& gen, vertices_size_type n,
  48. edges_size_type m, double a, double b, double c,
  49. double d, bool permute_vertices = true);
  50. Constructs an R-MAT generator iterator that creates a graph with ``n``
  51. vertices and ``m`` edges. Inside the ``scalable_rmat_iterator``
  52. processes communicate using ``pg`` to generate their local edges as
  53. defined by ``distrib``. ``a``, ``b``, ``c``, and ``d`` represent the
  54. probability that a generated edge is placed of each of the 4 quadrants
  55. of the partitioned adjacency matrix. Probabilities are drawn from the
  56. random number generator ``gen``. Vertex indices are permuted to
  57. eliminate locality when ``permute_vertices`` is true.
  58. Example
  59. -------
  60. ::
  61. #include <boost/graph/distributed/mpi_process_group.hpp>
  62. #include <boost/graph/compressed_sparse_row_graph.hpp>
  63. #include <boost/graph/rmat_graph_generator.hpp>
  64. #include <boost/random/linear_congruential.hpp>
  65. using boost::graph::distributed::mpi_process_group;
  66. typedef compressed_sparse_row_graph<directedS, no_property, no_property, no_property,
  67. distributedS<mpi_process_group> > Graph;
  68. typedef boost::scalable_rmat_iterator<boost::minstd_rand, Graph> RMATGen;
  69. int main()
  70. {
  71. boost::minstd_rand gen;
  72. mpi_process_group pg;
  73. int N = 100;
  74. boost::parallel::variant_distribution<ProcessGroup> distrib
  75. = boost::parallel::block(pg, N);
  76. // Create graph with 100 nodes and 400 edges
  77. Graph g(RMATGen(pg, distrib, gen, N, 400, 0.57, 0.19, 0.19, 0.05),
  78. RMATGen(), N, pg, distrib);
  79. return 0;
  80. }
  81. Bibliography
  82. ------------
  83. .. [CZF04] D Chakrabarti, Y Zhan, and C Faloutsos. R-MAT: A Recursive
  84. Model for Graph Mining. In Proceedings of 4th International Conference
  85. on Data Mining, pages 442--446, 2004.
  86. -----------------------------------------------------------------------------
  87. Copyright (C) 2009 The Trustees of Indiana University.
  88. Authors: Nick Edmonds, Brian Barrett, and Andrew Lumsdaine
  89. .. |Logo| image:: pbgl-logo.png
  90. :align: middle
  91. :alt: Parallel BGL
  92. :target: http://www.osl.iu.edu/research/pbgl
  93. .. _Sequential connected components: http://www.boost.org/libs/graph/doc/connected_components.html