unique_rmat_generator.rst 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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| Unique R-MAT generator
  7. ===================================
  8. ::
  9. template<typename RandomGenerator, typename Graph>
  10. class unique_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. unique_rmat_iterator();
  19. unique_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. unique_rmat_iterator& operator++();
  26. unique_rmat_iterator operator++(int);
  27. bool operator==(const unique_rmat_iterator& other) const;
  28. bool operator!=(const unique_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. The edge list produced by this iterator
  35. is guaranteed not to contain parallel edges.
  36. Where Defined
  37. -------------
  38. <``boost/graph/rmat_graph_generator.hpp``>
  39. Constructors
  40. ------------
  41. ::
  42. unique_rmat_iterator();
  43. Constructs a past-the-end iterator.
  44. ::
  45. unique_rmat_iterator(RandomGenerator& gen, vertices_size_type n,
  46. edges_size_type m, double a, double b, double c,
  47. double d, bool permute_vertices = true,
  48. EdgePredicate ep = keep_all_edges());
  49. Constructs an R-MAT generator iterator that creates a graph with ``n``
  50. vertices and ``m`` edges. ``a``, ``b``, ``c``, and ``d`` represent
  51. the probability that a generated edge is placed of each of the 4
  52. quadrants of the partitioned adjacency matrix. Probabilities are
  53. drawn from the random number generator ``gen``. Vertex indices are
  54. permuted to eliminate locality when ``permute_vertices`` is true.
  55. ``ep`` allows the user to specify which edges are retained, this is
  56. useful in the case where the user wishes to refrain from storing
  57. remote edges locally during generation to reduce memory consumption.
  58. Example
  59. -------
  60. ::
  61. #include <boost/graph/adjacency_list.hpp>
  62. #include <boost/graph/rmat_graph_generator.hpp>
  63. #include <boost/random/linear_congruential.hpp>
  64. typedef boost::adjacency_list<> Graph;
  65. typedef boost::unique_rmat_iterator<boost::minstd_rand, Graph> RMATGen;
  66. int main()
  67. {
  68. boost::minstd_rand gen;
  69. // Create graph with 100 nodes and 400 edges
  70. Graph g(RMATGen(gen, 100, 400, 0.57, 0.19, 0.19, 0.05,),
  71. RMATGen(), 100);
  72. return 0;
  73. }
  74. Bibliography
  75. ------------
  76. .. [CZF04] D Chakrabarti, Y Zhan, and C Faloutsos. R-MAT: A Recursive
  77. Model for Graph Mining. In Proceedings of 4th International Conference
  78. on Data Mining, pages 442--446, 2004.
  79. -----------------------------------------------------------------------------
  80. Copyright (C) 2009 The Trustees of Indiana University.
  81. Authors: Nick Edmonds and Andrew Lumsdaine
  82. .. |Logo| image:: pbgl-logo.png
  83. :align: middle
  84. :alt: Parallel BGL
  85. :target: http://www.osl.iu.edu/research/pbgl