]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/graph_parallel/doc/html/metis.html
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / graph_parallel / doc / html / metis.html
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 METIS Input Routines</title>
8 <link rel="stylesheet" href="../../../../rst.css" type="text/css" />
9 </head>
10 <body>
11 <div class="document" id="logo-metis-input-routines">
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> METIS Input Routines</h1>
13
14 <!-- Copyright (C) 2004-2008 The Trustees of Indiana University.
15 Use, modification and distribution is subject to the Boost Software
16 License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
17 http://www.boost.org/LICENSE_1_0.txt) -->
18 <pre class="literal-block">
19 namespace boost {
20 namespace graph {
21 class metis_reader;
22 class metis_exception;
23 class metis_input_exception;
24 class metis_distribution;
25 }
26 }
27 </pre>
28 <p><a class="reference external" href="http://www-users.cs.umn.edu/~karypis/metis/metis/">METIS</a> is a set of programs for partitioning graphs (among other
29 things). The Parallel BGL can read the METIS graph format and
30 partition format, allowing one to easily load METIS-partitioned
31 graphs into the Parallel BGL's data structures.</p>
32 <div class="contents topic" id="contents">
33 <p class="topic-title first">Contents</p>
34 <ul class="simple">
35 <li><a class="reference internal" href="#where-defined" id="id3">Where Defined</a><ul>
36 <li><a class="reference internal" href="#graph-reader" id="id4">Graph Reader</a></li>
37 </ul>
38 </li>
39 <li><a class="reference internal" href="#usage" id="id5">Usage</a></li>
40 <li><a class="reference internal" href="#associated-types" id="id6">Associated Types</a></li>
41 <li><a class="reference internal" href="#member-functions" id="id7">Member Functions</a><ul>
42 <li><a class="reference internal" href="#partition-reader" id="id8">Partition Reader</a></li>
43 </ul>
44 </li>
45 <li><a class="reference internal" href="#id1" id="id9">Usage</a></li>
46 <li><a class="reference internal" href="#id2" id="id10">Member Functions</a></li>
47 </ul>
48 </div>
49 <div class="section" id="where-defined">
50 <h1><a class="toc-backref" href="#id3">Where Defined</a></h1>
51 <p>&lt;<tt class="docutils literal"><span class="pre">boost/graph/metis.hpp</span></tt>&gt;</p>
52 <div class="section" id="graph-reader">
53 <h2><a class="toc-backref" href="#id4">Graph Reader</a></h2>
54 <pre class="literal-block">
55 class metis_reader
56 {
57 public:
58 typedef std::size_t vertices_size_type;
59 typedef std::size_t edges_size_type;
60 typedef double vertex_weight_type;
61 typedef double edge_weight_type;
62
63 class edge_iterator;
64 class edge_weight_iterator;
65
66 metis_reader(std::istream&amp; in);
67
68 edge_iterator begin();
69 edge_iterator end();
70 edge_weight_iterator weight_begin();
71
72 vertices_size_type num_vertices() const;
73 edges_size_type num_edges() const;
74
75 std::size_t num_vertex_weights() const;
76
77 vertex_weight_type vertex_weight(vertices_size_type v, std::size_t n);
78
79 bool has_edge_weights() const;
80 };
81 </pre>
82 </div>
83 </div>
84 <div class="section" id="usage">
85 <h1><a class="toc-backref" href="#id5">Usage</a></h1>
86 <p>The METIS reader provides an iterator interface to the METIS graph
87 file. The iterator interface is most useful when constructing Parallel
88 BGL graphs on-the-fly. For instance, the following code builds a graph
89 <tt class="docutils literal"><span class="pre">g</span></tt> from a METIS graph stored in <tt class="docutils literal"><span class="pre">argv[1]</span></tt>.</p>
90 <pre class="literal-block">
91 std::ifstream in_graph(argv[1]);
92 metis_reader reader(in_graph);
93 Graph g(reader.begin(), reader.end(),
94 reader.weight_begin(),
95 reader.num_vertices());
96 </pre>
97 <p>The calls to <tt class="docutils literal"><span class="pre">begin()</span></tt> and <tt class="docutils literal"><span class="pre">end()</span></tt> return an iterator range for
98 the edges in the graph; the call to <tt class="docutils literal"><span class="pre">weight_begin()</span></tt> returns an
99 iterator that will enumerate the weights of the edges in the
100 graph. For a distributed graph, the distribution will be determined
101 automatically by the graph; to use a METIS partitioning, see the
102 section <a class="reference internal" href="#partition-reader">Partition Reader</a>.</p>
103 </div>
104 <div class="section" id="associated-types">
105 <h1><a class="toc-backref" href="#id6">Associated Types</a></h1>
106 <pre class="literal-block">
107 metis_reader::edge_iterator
108 </pre>
109 <p>An <a class="reference external" href="http://www.sgi.com/tech/stl/InputIterator.html">Input Iterator</a> that enumerates the edges in the METIS graph, and
110 is suitable for use as the <tt class="docutils literal"><span class="pre">EdgeIterator</span></tt> of an <a class="reference external" href="http://www.boost.org/libs/graph/doc/adjacency_list.html">adjacency_list</a>.
111 The <tt class="docutils literal"><span class="pre">value_type</span></tt> of this iterator is a pair of vertex numbers.</p>
112 <hr class="docutils" />
113 <pre class="literal-block">
114 metis_reader::edge_weight_iterator
115 </pre>
116 <p>An <a class="reference external" href="http://www.sgi.com/tech/stl/InputIterator.html">Input Iterator</a> that enumerates the edge weights in the METIS
117 graph. The <tt class="docutils literal"><span class="pre">value_type</span></tt> of this iterator is <tt class="docutils literal"><span class="pre">edge_weight_type</span></tt>. If
118 the edges in the METIS graph are unweighted, the result of
119 dereferencing this iterator will always be zero.</p>
120 </div>
121 <div class="section" id="member-functions">
122 <h1><a class="toc-backref" href="#id7">Member Functions</a></h1>
123 <pre class="literal-block">
124 metis_reader(std::istream&amp; in);
125 </pre>
126 <p>Constructs a new METIS reader that will retrieve edges from the input
127 stream <tt class="docutils literal"><span class="pre">in</span></tt>. If any errors are encountered while initially parsing
128 <tt class="docutils literal"><span class="pre">in</span></tt>, <tt class="docutils literal"><span class="pre">metis_input_exception</span></tt> will be thrown.</p>
129 <hr class="docutils" />
130 <pre class="literal-block">
131 edge_iterator begin();
132 </pre>
133 <p>Returns an iterator to the first edge in the METIS file.</p>
134 <hr class="docutils" />
135 <pre class="literal-block">
136 edge_iterator end();
137 </pre>
138 <p>Returns an iterator one past the last edge in the METIS file.</p>
139 <hr class="docutils" />
140 <pre class="literal-block">
141 edge_weight_iterator weight_begin();
142 </pre>
143 <p>Returns an iterator to the first edge weight in the METIS file. The
144 weight iterator should be moved in concert with the edge iterator;
145 when the edge iterator moves, the edge weight changes. If the edges
146 in the graph are unweighted, the weight returned will always be zero.</p>
147 <hr class="docutils" />
148 <pre class="literal-block">
149 vertices_size_type num_vertices() const;
150 </pre>
151 <p>Returns the number of vertices in the graph.</p>
152 <hr class="docutils" />
153 <pre class="literal-block">
154 edges_size_type num_edges() const;
155 </pre>
156 <p>Returns the number of edges in the graph.</p>
157 <hr class="docutils" />
158 <pre class="literal-block">
159 std::size_t num_vertex_weights() const;
160 </pre>
161 <p>Returns the number of weights attached to each vertex.</p>
162 <hr class="docutils" />
163 <pre class="literal-block">
164 vertex_weight_type vertex_weight(vertices_size_type v, std::size_t n);
165 </pre>
166 <hr class="docutils" />
167 <pre class="literal-block">
168 bool has_edge_weights() const;
169 </pre>
170 <p>Returns <tt class="docutils literal"><span class="pre">true</span></tt> when the edges of the graph have weights, <tt class="docutils literal"><span class="pre">false</span></tt>
171 otherwise. When <tt class="docutils literal"><span class="pre">false</span></tt>, the edge weight iterator is still valid
172 but returns zero for the weight of each edge.</p>
173 <div class="section" id="partition-reader">
174 <h2><a class="toc-backref" href="#id8">Partition Reader</a></h2>
175 <pre class="literal-block">
176 class metis_distribution
177 {
178 public:
179 typedef int process_id_type;
180 typedef std::size_t size_type;
181
182 metis_distribution(std::istream&amp; in, process_id_type my_id);
183
184 size_type block_size(process_id_type id, size_type) const;
185 process_id_type operator()(size_type n);
186 size_type local(size_type n) const;
187 size_type global(size_type n) const;
188 size_type global(process_id_type id, size_type n) const;
189
190 private:
191 std::istream&amp; in;
192 process_id_type my_id;
193 std::vector&lt;process_id_type&gt; vertices;
194 };
195 </pre>
196 </div>
197 </div>
198 <div class="section" id="id1">
199 <h1><a class="toc-backref" href="#id9">Usage</a></h1>
200 <p>The class <tt class="docutils literal"><span class="pre">metis_distribution</span></tt> loads a METIS partition file and
201 makes it available as a Distribution suitable for use with the
202 <a class="reference external" href="distributed_adjacency_list.html">distributed adjacency list</a> graph type. To load a METIS graph using
203 a METIS partitioning, use a <tt class="docutils literal"><span class="pre">metis_reader</span></tt> object for the graph and
204 a <tt class="docutils literal"><span class="pre">metis_distribution</span></tt> object for the distribution, as in the
205 following example.</p>
206 <pre class="literal-block">
207 std::ifstream in_graph(argv[1]);
208 metis_reader reader(in_graph);
209
210 std::ifstream in_partitions(argv[2]);
211 metis_distribution dist(in_partitions, process_id(pg));
212 Graph g(reader.begin(), reader.end(),
213 reader.weight_begin(),
214 reader.num_vertices(),
215 pg,
216 dist);
217 </pre>
218 <p>In this example, <tt class="docutils literal"><span class="pre">argv[1]</span></tt> is the graph and <tt class="docutils literal"><span class="pre">argv[2]</span></tt> is the
219 partition file generated by <tt class="docutils literal"><span class="pre">pmetis</span></tt>. The <tt class="docutils literal"><span class="pre">dist</span></tt> object loads the
220 partitioning information from the input stream it is given and uses
221 that to distributed the adjacency list. Note that the input stream
222 must be in the METIS partition file format and must have been
223 partitioned for the same number of processes are there are in the
224 process group <tt class="docutils literal"><span class="pre">pg</span></tt>.</p>
225 </div>
226 <div class="section" id="id2">
227 <h1><a class="toc-backref" href="#id10">Member Functions</a></h1>
228 <pre class="literal-block">
229 metis_distribution(std::istream&amp; in, process_id_type my_id);
230 </pre>
231 <p>Creates a new METIS distribution from the input stream
232 <tt class="docutils literal"><span class="pre">in</span></tt>. <tt class="docutils literal"><span class="pre">my_id</span></tt> is the process ID of the current process in the
233 process group over which the graph will be distributed.</p>
234 <hr class="docutils" />
235 <pre class="literal-block">
236 size_type block_size(process_id_type id, size_type) const;
237 </pre>
238 <p>Returns the number of vertices to be stored in the process
239 <tt class="docutils literal"><span class="pre">id</span></tt>. The second parameter, <tt class="docutils literal"><span class="pre">size_type</span></tt>, is unused and may be any
240 value.</p>
241 <hr class="docutils" />
242 <pre class="literal-block">
243 process_id_type operator()(size_type n);
244 </pre>
245 <p>Returns the ID for the process that will store vertex number <tt class="docutils literal"><span class="pre">n</span></tt>.</p>
246 <hr class="docutils" />
247 <pre class="literal-block">
248 size_type local(size_type n) const;
249 </pre>
250 <p>Returns the local index of vertex number <tt class="docutils literal"><span class="pre">n</span></tt> within its owning
251 process.</p>
252 <hr class="docutils" />
253 <pre class="literal-block">
254 size_type global(size_type n) const;
255 </pre>
256 <p>Returns the global index of the current processor's local vertex <tt class="docutils literal"><span class="pre">n</span></tt>.</p>
257 <hr class="docutils" />
258 <pre class="literal-block">
259 size_type global(process_id_type id, size_type n) const;
260 </pre>
261 <p>Returns the global index of the process <tt class="docutils literal"><span class="pre">id</span></tt>'s local vertex <tt class="docutils literal"><span class="pre">n</span></tt>.</p>
262 <hr class="docutils" />
263 <p>Copyright (C) 2005 The Trustees of Indiana University.</p>
264 <p>Authors: Douglas Gregor and Andrew Lumsdaine</p>
265 </div>
266 </div>
267 <div class="footer">
268 <hr class="footer" />
269 Generated on: 2009-05-31 00:21 UTC.
270 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.
271
272 </div>
273 </body>
274 </html>