File: king_ordering.html

package info (click to toggle)
boost1.35 1.35.0-5
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 203,856 kB
  • ctags: 337,867
  • sloc: cpp: 938,683; xml: 56,847; ansic: 41,589; python: 18,999; sh: 11,566; makefile: 664; perl: 494; yacc: 456; asm: 353; csh: 6
file content (235 lines) | stat: -rw-r--r-- 7,887 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
<HTML>
<!--
  ~~ Copyright (c) Jeremy Siek 2000
  ~~
  -- Distributed under the Boost Software License, Version 1.0.
  -- (See accompanying file LICENSE_1_0.txt or copy at
  -- http://www.boost.org/LICENSE_1_0.txt)
-->
  
  
<Head> 
<Title>Boost Graph Library: King Ordering</Title>
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b" 
        ALINK="#ff0000"> 
<IMG SRC="../../../boost.png" 
     ALT="C++ Boost" width="277" height="86"> 

<BR Clear>

<H1>
<img src="figs/python.gif" alt="(Python)"/>
<TT>king_ordering</TT>
</H1>


<P>
<DIV ALIGN="LEFT">
<TABLE CELLPADDING=3 border>
<TR><TH ALIGN="LEFT"><B>Graphs:</B></TH>
<TD ALIGN="LEFT">undirected</TD>
</TR>
<TR><TH ALIGN="LEFT"><B>Properties:</B></TH>
<TD ALIGN="LEFT">color, degree</TD>
</TR>
<TR><TH ALIGN="LEFT"><B>Complexity:</B></TH>
<TD ALIGN="LEFT">time: <i>O(m<sup>2</sup>log(m)|E|)</i> where <i>m = max { degree(v) | v in V }</i> </TD>
</TR>
</TABLE>
</DIV>


<pre>
  (1)
  template &lt;class IncidenceGraph, class OutputIterator,
            class ColorMap, class DegreeMap, class VertexIndexMap&gt;
  OutputIterator
  king_ordering(const IncidenceGraph&amp; g,
                typename graph_traits&lt;Graph&gt;::vertex_descriptor s,
                OutputIterator inverse_permutation, 
                ColorMap color, DegreeMap degree, VertexIndexMap index_map);

  (2)
  template &lt;class IncidenceGraph, class OutputIterator&gt;
  OutputIterator
  king_ordering(const IncidenceGraph&amp; g, OutputIterator inverse_permutation);

  template &lt;class IncidenceGraph, class OutputItrator, class VertexIndexMap&gt;
  OutputIterator
  king_ordering(const IncidenceGraph&amp; g, OutputIterator inverse_permutation,
                VertexIndexMap index_map);

  template &lt;class VertexListGraph, class OutputIterator, 
            class ColorMap, class DegreeMap, class VertexIndexMap&gt;
  OutputIterator
  king_ordering(const VertexListGraph&amp; G, OutputIterator inverse_permutation, 
                ColorMap color, DegreeMap degree, VertexIndexMap index_map);
                         
  (3)
  template &lt;class IncidenceGraph, class OutputIterator,
            class ColorMap, class DegreeMap, class VertexIndexMap&gt;
  OutputIterator
  king_ordering(const IncidenceGraph&amp; g,
    		std::deque&lt; typename
		graph_traits&lt;Graph&gt;::vertex_descriptor &gt; vertex_queue,
                OutputIterator permutation, 
                ColorMap color, DegreeMap degree, VertexIndexMap index_map);
</pre>

<!-- King, I.P. An automatic reordering scheme for simultaneous equations derived from network analysis. Int. J. Numer. Methods Engrg. 2 (1970), 523-533 -->

The goal of the King ordering
algorithm [<a href="bibliography.html#king70">62</a>]is to reduce the <a
href="./bandwidth.html">bandwidth</a> of a graph by reordering the
indices assigned to each vertex.  The King ordering algorithm
works by a local minimization of the i-th bandwidths. The vertices are
basically assigned a breadth-first search order, except that at each
step, the adjacent vertices are placed in the queue in order of
increasing pseudo-degree, where pseudo-degree is defined as the number of 
outgoing edges with white endpoints (vertices yet to be examined).

<p>
Version 1 of the algorithm lets the user choose the ``starting
vertex'', version 2 finds a good starting vertex using the
pseudo-peripheral pair heuristic (among each component), while version 3 
contains the starting nodes for each vertex in the deque.  The choice of the ``starting
vertex'' can have a significant effect on the quality of the ordering.
</p>

<p>
The output of the algorithm are the vertices in the new ordering.
Storing the output into a vector gives you the
permutation from the new ordering to the old ordering.

<pre>
  inv_perm[new_index[u]] == u
</pre>

<p>
Often times, it is the opposite permutation that you want, the
permutation from the old index to the new index. This can easily be
computed in the following way.
</p>

<pre>
  for (size_type i = 0; i != inv_perm.size(); ++i)
    perm[old_index[inv_perm[i]]] = i;
</pre>



<h3>Parameters</h3>

For version 1:

<ul>

<li> <tt>IncidenceGraph&amp; g</tt> &nbsp;(IN) <br> 
  An undirected graph. The graph's type must be a model of <a
  href="./IncidenceGraph.html">IncidenceGraph</a>.<br>
  <b>Python</b>: The parameter is named <tt>graph</tt>.

<li> <tt>vertex_descriptor s</tt> &nbsp(IN) <br>
  The starting vertex.<br>
  <b>Python</b>: Unsupported parameter.

<li> <tt>OutputIterator permutation</tt> &nbsp(OUT) <br> 
  The new vertex ordering. The vertices are written to the <a
  href="http://www.sgi.com/tech/stl/OutputIterator.html">output
  iterator</a> in their new order. <br>
  <b>Python</b>: This parameter is unused in Python. The new vertex
  ordering is returned as a Python <tt>list</tt>.

  
<li> <tt>ColorMap color_map</tt> &nbsp(WORK) <br>
  Used internally to keep track of the progress of the algorithm
  (to avoid visiting the same vertex twice).<br>
  <b>Python</b>: Unsupported parameter.

<li> <tt>DegreeMap degree_map</tt> &nbsp(IN) <br>
  This must map vertices to their degree.<br>
  <b>Python</b>: Unsupported parameter.

</ul>


For version 2:

<ul>

<li> <tt>VertexListGraph&amp; g</tt> &nbsp;(IN) <br> 
  An undirected graph. The graph's type must be a model of <a
  href="./VertexListGraph.html">VertexListGraph</a>.<br>
  <b>Python</b>: The name of this parameter is <tt>graph</tt>.

<li> <tt><a href="http://www.sgi.com/tech/stl/OutputIterator.html">
  OutputIterator</a> permutation</tt> &nbsp(OUT) <br> 
  The new vertex ordering. The vertices are written to the
  output iterator in their new order.<br>
  <b>Python</b>: This parameter is unused in Python. The new vertex
  ordering is returned as a Python <tt>list</tt>.

<li> <tt>ColorMap color_map</tt> &nbsp(WORK) <br>
  Used internally to keep track of the progress of the algorithm
  (to avoid visiting the same vertex twice).<br>
  <b>Python</b>: Unsupported parameter.

<li> <tt>DegreeMap degree_map</tt> &nbsp(IN) <br>
  This must map vertices to their degree.<br>
  <b>Python</b>: Unsupported parameter.
</ul>


For version 3:

<ul>

<li> <tt>IncidenceGraph&amp; g</tt> &nbsp;(IN) <br> 
  An undirected graph. The graph's type must be a model of <a
  href="./IncidenceGraph.html">IncidenceGraph</a>.<br>
  <b>Python</b>: The parameter is named <tt>graph</tt>.

<li> <tt> std::deque&lt; typename graph_traits&lt;Graph&gt;::vertex_descriptor &gt; vertex_queue </tt> &nbsp(IN) <br>
  The deque containing the starting vertices for each component.<br>
  <b>Python</b>: This parameter is unused in Python. The new vertex
  ordering is returned as a Python <tt>list</tt>.

<li> <tt>OutputIterator permutation</tt> &nbsp(OUT) <br> 
  The new vertex ordering. The vertices are written to the <a
  href="http://www.sgi.com/tech/stl/OutputIterator.html">output
  iterator</a> in their new order.<br> 
  <b>Python</b>: This parameter is unused in Python. The new vertex
  ordering is returned as a Python <tt>list</tt>.

<li> <tt>ColorMap color_map</tt> &nbsp(WORK) <br>
  Used internally to keep track of the progress of the algorithm
  (to avoid visiting the same vertex twice).<br>
  <b>Python</b>: Unsupported parameter.

<li> <tt>DegreeMap degree_map</tt> &nbsp(IN) <br>
  This must map vertices to their degree.<br>
  <b>Python</b>: Unsupported parameter.
</ul>



<h3>Example</h3>

See <a
href="../example/king_ordering.cpp"><tt>example/king_ordering.cpp</tt></a>.

<h3>See Also</h3>

<a href="./bandwidth.html">bandwidth</tt></a>,
and <tt>degree_property_map</tt> in <tt>boost/graph/properties.hpp</tt>.

<br>
<HR>
<TABLE>
<TR valign=top>
<TD nowrap>Copyright &copy; 2000-2001</TD><TD>
<A HREF="http://www.boost.org/people/jeremy_siek.htm">Jeremy Siek</A>, Indiana University (<A HREF="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</A>)
</TD></TR></TABLE>

</BODY>
</HTML>