sorted_rmat_generator.rst 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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| Sorted R-MAT generator
  7. ===================================
  8. ::
  9. template<typename RandomGenerator, typename Graph,
  10. typename EdgePredicate = keep_all_edges>
  11. class sorted_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. sorted_rmat_iterator();
  20. sorted_rmat_iterator(RandomGenerator& gen, vertices_size_type n,
  21. edges_size_type m, double a, double b, double c,
  22. double d, bool permute_vertices = true);
  23. // Iterator operations
  24. reference operator*() const;
  25. pointer operator->() const;
  26. sorted_rmat_iterator& operator++();
  27. sorted_rmat_iterator operator++(int);
  28. bool operator==(const sorted_rmat_iterator& other) const;
  29. bool operator!=(const sorted_rmat_iterator& other) const;
  30. };
  31. This class template implements a generator for R-MAT graphs [CZF04]_,
  32. suitable for initializing an adjacency_list or other graph structure
  33. with iterator-based initialization. An R-MAT graph has a scale-free
  34. distribution w.r.t. vertex degree and is implemented using
  35. Recursive-MATrix partitioning. The output of this generator is sorted
  36. for use with `compressed sparse row graph`_.
  37. Where Defined
  38. -------------
  39. <``boost/graph/rmat_graph_generator.hpp``>
  40. Constructors
  41. ------------
  42. ::
  43. sorted_rmat_iterator();
  44. Constructs a past-the-end iterator.
  45. ::
  46. sorted_rmat_iterator(RandomGenerator& gen, vertices_size_type n,
  47. edges_size_type m, double a, double b, double c,
  48. double d, bool permute_vertices = true,
  49. EdgePredicate ep = keep_all_edges());
  50. Constructs an R-MAT generator iterator that creates a graph with ``n``
  51. vertices and ``m`` edges. ``a``, ``b``, ``c``, and ``d`` represent
  52. the probability that a generated edge is placed of each of the 4
  53. quadrants of the partitioned adjacency matrix. Probabilities are
  54. drawn from the random number generator ``gen``. Vertex indices are
  55. permuted to eliminate locality when ``permute_vertices`` is true.
  56. ``ep`` allows the user to specify which edges are retained, this is
  57. useful in the case where the user wishes to refrain from storing
  58. remote edges locally during generation to reduce memory consumption.
  59. Example
  60. -------
  61. ::
  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. typedef boost::compressed_sparse_row_graph<> Graph;
  66. typedef boost::sorted_rmat_iterator<boost::minstd_rand, Graph>
  67. RMATGen;
  68. int main()
  69. {
  70. boost::minstd_rand gen;
  71. // Create graph with 100 nodes and 400 edges
  72. Graph g(RMATGen(gen, 100, 400, 0.57, 0.19, 0.19, 0.05),
  73. RMATGen(), 100);
  74. return 0;
  75. }
  76. Bibliography
  77. ------------
  78. .. [CZF04] D Chakrabarti, Y Zhan, and C Faloutsos. R-MAT: A Recursive
  79. Model for Graph Mining. In Proceedings of 4th International Conference
  80. on Data Mining, pages 442--446, 2004.
  81. -----------------------------------------------------------------------------
  82. Copyright (C) 2009 The Trustees of Indiana University.
  83. Authors: Nick Edmonds and Andrew Lumsdaine
  84. .. |Logo| image:: pbgl-logo.png
  85. :align: middle
  86. :alt: Parallel BGL
  87. :target: http://www.osl.iu.edu/research/pbgl
  88. .. _compressed sparse row graph: http://www.boost.org/libs/graph/doc/compressed_sparse_row.html