sorted_unique_rmat_generator.html 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6. <meta name="generator" content="Docutils 0.6: http://docutils.sourceforge.net/" />
  7. <title>Parallel BGL Sorted unique R-MAT generator</title>
  8. <link rel="stylesheet" href="../../../../rst.css" type="text/css" />
  9. </head>
  10. <body>
  11. <div class="document" id="logo-sorted-unique-r-mat-generator">
  12. <h1 class="title"><a class="reference external" href="http://www.osl.iu.edu/research/pbgl"><img align="middle" alt="Parallel BGL" class="align-middle" src="pbgl-logo.png" /></a> Sorted unique R-MAT generator</h1>
  13. <!-- Copyright (C) 2004-2009 The Trustees of Indiana University.
  14. Use, modification and distribution is subject to the Boost Software
  15. License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  16. http://www.boost.org/LICENSE_1_0.txt) -->
  17. <pre class="literal-block">
  18. template&lt;typename RandomGenerator, typename Graph,
  19. typename EdgePredicate = keep_all_edges&gt;
  20. class sorted_unique_rmat_iterator
  21. {
  22. public:
  23. typedef std::input_iterator_tag iterator_category;
  24. typedef std::pair&lt;vertices_size_type, vertices_size_type&gt; value_type;
  25. typedef const value_type&amp; reference;
  26. typedef const value_type* pointer;
  27. typedef void difference_type;
  28. sorted_unique_rmat_iterator();
  29. sorted_unique_rmat_iterator(RandomGenerator&amp; gen, vertices_size_type n,
  30. edges_size_type m, double a, double b, double c,
  31. double d, bool bidirectional = true,
  32. bool permute_vertices = true,
  33. EdgePredicate ep = keep_all_edges());
  34. // Iterator operations
  35. reference operator*() const;
  36. pointer operator-&gt;() const;
  37. sorted_unique_rmat_iterator&amp; operator++();
  38. sorted_unique_rmat_iterator operator++(int);
  39. bool operator==(const sorted_unique_rmat_iterator&amp; other) const;
  40. bool operator!=(const sorted_unique_rmat_iterator&amp; other) const;
  41. };
  42. </pre>
  43. <p>This class template implements a generator for R-MAT graphs <a class="citation-reference" href="#czf04" id="id1">[CZF04]</a>,
  44. suitable for initializing an adjacency_list or other graph structure
  45. with iterator-based initialization. An R-MAT graph has a scale-free
  46. distribution w.r.t. vertex degree and is implemented using
  47. Recursive-MATrix partitioning. The output of this generator is sorted
  48. for use with a <a class="reference external" href="http://www.boost.org/libs/graph/doc/compressed_sparse_row.html">compressed sparse row graph</a>. The edge list produced by
  49. this iterator is guaranteed not to contain parallel edges.</p>
  50. <div class="section" id="where-defined">
  51. <h1>Where Defined</h1>
  52. <p>&lt;<tt class="docutils literal"><span class="pre">boost/graph/rmat_graph_generator.hpp</span></tt>&gt;</p>
  53. </div>
  54. <div class="section" id="constructors">
  55. <h1>Constructors</h1>
  56. <pre class="literal-block">
  57. sorted_unique_rmat_iterator();
  58. </pre>
  59. <p>Constructs a past-the-end iterator.</p>
  60. <pre class="literal-block">
  61. sorted_unique_rmat_iterator(RandomGenerator&amp; gen, vertices_size_type n,
  62. edges_size_type m, double a, double b, double c,
  63. double d, bool bidirectional = false,
  64. bool permute_vertices = true,
  65. EdgePredicate ep = keep_all_edges());
  66. </pre>
  67. <p>Constructs an R-MAT generator iterator that creates a graph with <tt class="docutils literal"><span class="pre">n</span></tt>
  68. vertices and <tt class="docutils literal"><span class="pre">m</span></tt> edges. <tt class="docutils literal"><span class="pre">a</span></tt>, <tt class="docutils literal"><span class="pre">b</span></tt>, <tt class="docutils literal"><span class="pre">c</span></tt>, and <tt class="docutils literal"><span class="pre">d</span></tt> represent
  69. the probability that a generated edge is placed of each of the 4
  70. quadrants of the partitioned adjacency matrix. Probabilities are
  71. drawn from the random number generator <tt class="docutils literal"><span class="pre">gen</span></tt>. Vertex indices are
  72. permuted to eliminate locality when <tt class="docutils literal"><span class="pre">permute_vertices</span></tt> is true.
  73. When <tt class="docutils literal"><span class="pre">bidirectional</span></tt> is <tt class="docutils literal"><span class="pre">true</span></tt> for every edge s-t, the
  74. corresponding anti-edge t-s is added as well, these anti-edges are not
  75. counted towards <tt class="docutils literal"><span class="pre">m</span></tt>. <tt class="docutils literal"><span class="pre">ep</span></tt> allows the user to specify which edges
  76. are retained, this is useful in the case where the user wishes to
  77. refrain from storing remote edges locally during generation to reduce
  78. memory consumption.</p>
  79. </div>
  80. <div class="section" id="example">
  81. <h1>Example</h1>
  82. <pre class="literal-block">
  83. #include &lt;boost/graph/distributed/mpi_process_group.hpp&gt;
  84. #include &lt;boost/graph/compressed_sparse_row_graph.hpp&gt;
  85. #include &lt;boost/graph/rmat_graph_generator.hpp&gt;
  86. #include &lt;boost/random/linear_congruential.hpp&gt;
  87. using boost::graph::distributed::mpi_process_group;
  88. typedef compressed_sparse_row_graph&lt;directedS, no_property, no_property, no_property,
  89. distributedS&lt;mpi_process_group&gt; &gt; Graph;
  90. typedef keep_local_edges&lt;boost::parallel::variant_distribution&lt;mpi_process_group&gt;,
  91. mpi_process_group::process_id_type&gt; EdgeFilter;
  92. typedef boost::sorted_unique_rmat_iterator&lt;boost::minstd_rand, Graph&gt; RMATGen;
  93. int main()
  94. {
  95. boost::minstd_rand gen;
  96. mpi_process_group pg;
  97. int N = 100;
  98. boost::parallel::variant_distribution&lt;ProcessGroup&gt; distrib
  99. = boost::parallel::block(pg, N);
  100. mpi_process_group::process_id_type id = process_id(pg);
  101. // Create graph with 100 nodes and 400 edges
  102. Graph g(RMATGen(gen, N, 400, 0.57, 0.19, 0.19, 0.05, true,
  103. true, EdgeFilter(distrib, id)),
  104. RMATGen(), N, pg, distrib);
  105. return 0;
  106. }
  107. </pre>
  108. </div>
  109. <div class="section" id="bibliography">
  110. <h1>Bibliography</h1>
  111. <table class="docutils citation" frame="void" id="czf04" rules="none">
  112. <colgroup><col class="label" /><col /></colgroup>
  113. <tbody valign="top">
  114. <tr><td class="label"><a class="fn-backref" href="#id1">[CZF04]</a></td><td>D Chakrabarti, Y Zhan, and C Faloutsos. R-MAT: A Recursive
  115. Model for Graph Mining. In Proceedings of 4th International Conference
  116. on Data Mining, pages 442--446, 2004.</td></tr>
  117. </tbody>
  118. </table>
  119. <hr class="docutils" />
  120. <p>Copyright (C) 2009 The Trustees of Indiana University.</p>
  121. <p>Authors: Nick Edmonds and Andrew Lumsdaine</p>
  122. </div>
  123. </div>
  124. <div class="footer">
  125. <hr class="footer" />
  126. Generated on: 2009-05-31 00:21 UTC.
  127. Generated by <a class="reference external" href="http://docutils.sourceforge.net/">Docutils</a> from <a class="reference external" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> source.
  128. </div>
  129. </body>
  130. </html>