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 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462
|
<HTML>
<!--
-- Copyright (c) 2004 Trustees of Indiana University
--
-- 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: Gürsoy-Atun Layout</Title>
<script language="JavaScript" type="text/JavaScript">
<!--
function address(host, user) {
var atchar = '@';
var thingy = user+atchar+host;
thingy = '<a hre' + 'f=' + "mai" + "lto:" + thingy + '>' + user+atchar+host + '</a>';
document.write(thingy);
}
//-->
</script>
</head>
<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
ALINK="#ff0000">
<IMG SRC="../../../boost.png"
ALT="C++ Boost" width="277" height="86">
<BR Clear>
<TT>gursoy_atun_layout</TT>
</H1>
<P>
<h3>Synopsis</h3>
<PRE>
<em>// Non-named parameter version</em>
template<typename VertexListAndIncidenceGraph, typename Topology,
typename PositionMap, typename VertexIndexMap,
typename EdgeWeightMap>
void
gursoy_atun_layout(const VertexListAndIncidenceGraph& g,
const Topology& space,
PositionMap position,
int nsteps = num_vertices(g),
double diameter_initial = sqrt((double)num_vertices(g)),
double diameter_final = 1,
double learning_constant_initial = 0.8,
double learning_constant_final = 0.2,
VertexIndexMap vertex_index_map = get(vertex_index, g),
EdgeWeightMap weight = dummy_property_map());
<em>// Named parameter version</em>
template<typename VertexListAndIncidenceGraph, typename Topology,
typename PositionMap, typename P, typename T, typename R>
void
gursoy_atun_layout(const VertexListAndIncidenceGraph& g,
const Topology& space,
PositionMap position,
const bgl_named_params<P,T,R>& params = <em>all defaults</em>);
<em>// Topologies</em>
template<std::size_t Dims> class <a href="#convex_topology">convex_topology</a>;
template<std::size_t Dims, typename RandomNumberGenerator = minstd_rand> class <a href="#hypercube_topology">hypercube_topology</a>;
template<typename RandomNumberGenerator = minstd_rand> class <a href="#square_topology">square_topology</a>;
template<typename RandomNumberGenerator = minstd_rand> class <a href="#cube_topology">cube_topology</a>;
template<std::size_t Dims, typename RandomNumberGenerator = minstd_rand> class <a href="#ball_topology">ball_topology</a>;
template<typename RandomNumberGenerator = minstd_rand> class <a href="#circle_topology">circle_topology</a>;
template<typename RandomNumberGenerator = minstd_rand> class <a href="#sphere_topology">sphere_topology</a>;
template<typename RandomNumberGenerator = minstd_rand> class <a href="#heart_topology">heart_topology</a>;
</PRE>
<h3>Description</h3>
<P> This algorithm [<A HREF="bibliography.html#gursoy00">60</A>]
performs layout of directed graphs, either weighted or unweighted. This
algorithm is very different from the <a
href="kamada_kawai_spring_layout.html">Kamada-Kawai</a> and <a
href="fruchterman_reingold.html">Fruchterman-Reingold</a> algorithms,
because it does not explicitly strive to layout graphs in a visually
pleasing manner. Instead, it attempts to distribute the vertices
uniformly within a <em>topology</em> (e.g., rectangle, sphere, heart shape),
keeping vertices close to their neighbors. The algorithm itself is
based on <a
href="http://davis.wpi.edu/~matt/courses/soms/">Self-Organizing
Maps</a>.
<p> <a href="#topologies">Various topologies</a> are provided that
produce different, interesting results. The <a
href="#square_topology">square topology</a> can be used for normal
display of graphs or distributing vertices for parallel computation on
a process array, for instance. Other topologies, such as the <a
href="#sphere_topology">sphere topology</a> (or N-dimensional <a
href="#ball_topology">ball topology</a>) make sense for different
problems, whereas the <a href="#heart_topology">heart topology</a> is
just plain fun. One can also <a href="#topology-concept">define a
topology</a> to suit other particular needs. <br>
<a href="#square_topology"><img src="figs/ga-square.png"></a>
<a href="#heart_topology"><img src="figs/ga-heart.png"></a>
<a href="#circle_topology"><img src="figs/ga-circle.png"></a>
<h3>Where Defined</h3>
<a href="../../../boost/graph/gursoy_atun_layout.hpp"><tt>boost/graph/gursoy_atun_layout.hpp</tt></a>
<h3>Parameters</h3>
IN: <tt>const Graph& g</tt>
<blockquote>
The graph object on which the algorithm will be applied. The type
<tt>Graph</tt> must be a model of <a
href="./VertexAndEdgeListGraph.html">Vertex List Graph</a> and <a
href="IncidenceGraph.html">Incidence Graph</a>.
</blockquote>
IN: <tt>const Topology& space</tt>
<blockquote>
The topology on which the graph will be layed out. The type must
model the <a href="#topology-concept">Topology</a> concept.
</blockquote>
OUT: <tt>PositionMap position</tt>
<blockquote>
The property map that stores the position of each vertex. The type
<tt>PositionMap</tt> must be a model of <a
href="../../property_map/LvaluePropertyMap.html">Lvalue Property
Map</a> such that the vertex descriptor type of <tt>Graph</tt> is
convertible to its key type. Its value type must be the type of a
point in the topology.
</blockquote>
IN: <tt>int nsteps</tt>
<blockquote>
The number of iterations to perform.<br>
<b>Default</b>: <tt>num_vertices(g)</tt>
</blockquote>
IN: <tt>double diameter_initial</tt>
<blockquote>
When a vertex is selected to be updated, all vertices that are
reachable from that vertex within a certain diameter (in graph
terms) will also be updated. This diameter begins at
<tt>diameter_initial</tt> in the first iteration and ends at
<tt>diameter_final</tt> in the last iteration, progressing
exponentially. Generally the diameter decreases, in a manner similar to
the cooling schedule in <a
href="fruchterman_reingold.html">Fruchterman-Reingold</a>. The
diameter should typically decrease in later iterations, so this value
should not be less than <tt>diameter_final</tt>.<br>
<b>Default</b>: <tt>sqrt((double)num_vertices(g))</tt>
</blockquote>
IN: <tt>double diameter_final</tt>
<blockquote>
The final value of the diameter.<br>
<b>Default</b>: 1.0
</blockquote>
IN: <tt>double learning_constant_initial</tt>
<blockquote>
The learning rate affects how far vertices can moved to rearrange
themselves in a given iteration. The learning rate progresses
linearly from the initial value to the final value, both of which
should be between 0 and 1. The learning rate should typically
decrease, so the initial value should not exceed the final
value.<br> <b>Default</b>: 0.8
</blockquote>
IN: <tt>double learning_constant_final</tt>
<blockquote>
The final learning rate constant.<br>
<b>Default</b>: 0.2
</blockquote>
IN: <tt>VertexIndexMap vertex_index_map</tt>
<blockquote>
This maps each vertex to an integer in the range <tt>[0,
num_vertices(g))</tt>.
The type <tt>VertexIndexMap</tt> must be a model of <a
href="../../property_map/ReadablePropertyMap.html">Readable Property
Map</a>. The value type of the map must be an integer type. The
vertex descriptor type of the graph needs to be usable as the key
type of the map.<br>
<b>Default:</b> <tt>get(vertex_index, g)</tt>
Note: if you use this default, make sure your graph has
an internal <tt>vertex_index</tt> property. For example,
<tt>adjacenty_list</tt> with <tt>VertexList=listS</tt> does
not have an internal <tt>vertex_index</tt> property.
</blockquote>
IN: <tt>EdgeWeightMap weight</tt>
<blockquote>
This maps each edge to an weight.
num_vertices(g))</tt>. This is only necessary when no
displacement map is provided.
The type <tt>EdgeWeightMap</tt> must be a model of <a
href="../../property_map/ReadablePropertyMap.html">Readable Property
Map</a>. The value type of the map must be an floating-point type
compatible with <tt>double</tt>. The edge descriptor type of the
graph needs to be usable as the key type of the map. When this map
is a <tt>dummy_property_map</tt>, the algorithm assumes the graph is
unweighted.<br>
<b>Default:</b> <tt>dummy_property_map()</tt>
</blockquote>
<h3>Named Parameters</h3>
IN: <tt>iterations(int n)</tt>
<blockquote>
Executes the algorithm for <em>n</em> iterations.<br>
<b>Default:</b> <tt>num_vertices(g)</tt>
</blockquote>
IN: <tt>diameter_range(std::pair<T, T> range)</tt>
<blockquote>
Range specifying the parameters (<tt>diameter_initial</tt>, <tt>diameter_final</tt>). <br>
<b>Default:</b> <tt>std::make_pair(sqrt((double)num_vertices(g)), 1.0)</tt>
</blockquote>
IN: <tt>learning_constant_range(std::pair<T, T> range)</tt>
<blockquote>
Range specifying the parameters (<tt>learning_constant_initial</tt>, <tt>learning_constant_final</tt>). <br>
<b>Default:</b> <tt>std::make_pair(0.8, 0.2)</tt>
</blockquote>
IN: <tt>edge_weight(EdgeWeightMap weight)</tt>
<blockquote>
Equivalent to the non-named <tt>weight</tt> parameter.<br>
<b>Default:</b> <tt>dummy_property_map()</tt>
</blockquote>
IN: <tt>vertex_index_map(VertexIndexMap i_map)</tt>
<blockquote>
Equivalent to the non-named <tt>vertex_index_map</tt> parameter.<br>
<b>Default:</b> <tt>get(vertex_index, g)</tt>
Note: if you use this default, make sure your graph has
an internal <tt>vertex_index</tt> property. For example,
<tt>adjacenty_list</tt> with <tt>VertexList=listS</tt> does
not have an internal <tt>vertex_index</tt> property.
</blockquote>
<a name="topologies"><h3>Topologies</h3></a>
A topology is a description of a space on which layout can be
performed. Some common two, three, and multidimensional topologies
are provided, or you may create your own so long as it meets the
requirements of the <a href="#topology-concept">Topology concept</a>.
<a name="topology-concept"><h4>Topology Concept</h4></a> Let
<tt>Topology</tt> be a model of the Topology concept and let
<tt>space</tt> be an object of type <tt>Topology</tt>. <tt>p1</tt> and
<tt>p2</tt> are objects of associated type <tt>point_type</tt> (see
below). The following expressions must be valid:
<table border="1">
<tr>
<th>Expression</th>
<th>Type</th>
<th>Description</th>
</tr>
<tr>
<td><tt>Topology::point_type</tt></td>
<td>type</td>
<td>The type of points in the space.</td>
</tr>
<tr>
<td><tt>space.random_point()</tt></td>
<td>point_type</td>
<td>Returns a random point (usually uniformly distributed) within
the space.</td>
</tr>
<tr>
<td><tt>space.distance(p1, p2)</tt></td>
<td>double</td>
<td>Get a quantity representing the distance between <tt>p1</tt>
and <tt>p2</tt> using a path going completely inside the space.
This only needs to have the same < relation as actual
distances, and does not need to satisfy the other properties of a
norm in a Banach space.</td>
</tr>
<tr>
<td><tt>space.move_position_toward(p1, fraction, p2)</tt></td>
<td>point_type</td>
<td>Returns a point that is a fraction of the way from <tt>p1</tt>
to <tt>p2</tt>, moving along a "line" in the space according to
the distance measure. <tt>fraction</tt> is a <tt>double</tt>
between 0 and 1, inclusive.</td>
</tr>
</table>
<a name="convex_topology"><h3>Class template <tt>convex_topology</tt></h3></a>
<p>Class template <tt>convex_topology</tt> implements the basic
distance and point movement functions for any convex topology in
<tt>Dims</tt> dimensions. It is not itself a topology, but is intended
as a base class that any convex topology can derive from. The derived
topology need only provide a suitable <tt>random_point</tt> function
that returns a random point within the space.
<pre>
template<std::size_t Dims>
class convex_topology
{
struct point
{
point() { }
double& operator[](std::size_t i) {return values[i];}
const double& operator[](std::size_t i) const {return values[i];}
private:
double values[Dims];
};
public:
typedef point point_type;
double distance(point a, point b) const;
point move_position_toward(point a, double fraction, point b) const;
};
</pre>
<a name="hypercube_topology"><h3>Class template <tt>hypercube_topology</tt></h3></a>
<p>Class template <tt>hypercube_topology</tt> implements a
<tt>Dims</tt>-dimensional hypercube. It is a convex topology whose
points are drawn from a random number generator of type
<tt>RandomNumberGenerator</tt>. The <tt>hypercube_topology</tt> can
be constructed with a given random number generator; if omitted, a
new, default-constructed random number generator will be used. The
resulting layout will be contained within the hypercube, whose sides
measure 2*<tt>scaling</tt> long (points will fall in the range
[-<tt>scaling</tt>, <tt>scaling</tt>] in each dimension).
<pre>
template<std::size_t Dims, typename RandomNumberGenerator = minstd_rand>
class hypercube_topology : public <a href="#convex_topology">convex_topology</a><Dims>
{
public:
explicit hypercube_topology(double scaling = 1.0);
hypercube_topology(RandomNumberGenerator& gen, double scaling = 1.0);
point_type random_point() const;
};
</pre>
<a name="square_topology"><h3>Class template <tt>square_topology</tt></h3></a>
<p>Class template <tt>square_topology</tt> is a two-dimensional
hypercube topology.
<pre>
template<typename RandomNumberGenerator = minstd_rand>
class square_topology : public <a href="#hypercube_topology">hypercube_topology</a><2, RandomNumberGenerator>
{
public:
explicit square_topology(double scaling = 1.0);
square_topology(RandomNumberGenerator& gen, double scaling = 1.0);
};
</pre>
<a name="cube_topology"><h3>Class template <tt>cube_topology</tt></h3></a>
<p>Class template <tt>cube_topology</tt> is a two-dimensional
hypercube topology.
<pre>
template<typename RandomNumberGenerator = minstd_rand>
class cube_topology : public <a href="#hypercube_topology">hypercube_topology</a><3, RandomNumberGenerator>
{
public:
explicit cube_topology(double scaling = 1.0);
cube_topology(RandomNumberGenerator& gen, double scaling = 1.0);
};
</pre>
<a name="ball_topology"><h3>Class template <tt>ball_topology</tt></h3></a>
<p>Class template <tt>ball_topology</tt> implements a
<tt>Dims</tt>-dimensional ball. It is a convex topology whose points
are drawn from a random number generator of type
<tt>RandomNumberGenerator</tt> but reside inside the ball. The
<tt>ball_topology</tt> can be constructed with a given random number
generator; if omitted, a new, default-constructed random number
generator will be used. The resulting layout will be contained within
the ball with the given <tt>radius</tt>.
<pre>
template<std::size_t Dims, typename RandomNumberGenerator = minstd_rand>
class ball_topology : public <a href="#convex_topology">convex_topology</a><Dims>
{
public:
explicit ball_topology(double radius = 1.0);
ball_topology(RandomNumberGenerator& gen, double radius = 1.0);
point_type random_point() const;
};
</pre>
<a name="circle_topology"><h3>Class template <tt>circle_topology</tt></h3></a>
<p>Class template <tt>circle_topology</tt> is a two-dimensional
ball topology.
<pre>
template<typename RandomNumberGenerator = minstd_rand>
class circle_topology : public <a href="#ball_topology">ball_topology</a><2, RandomNumberGenerator>
{
public:
explicit circle_topology(double radius = 1.0);
circle_topology(RandomNumberGenerator& gen, double radius = 1.0);
};
</pre>
<a name="sphere_topology"><h3>Class template <tt>sphere_topology</tt></h3></a>
<p>Class template <tt>sphere_topology</tt> is a two-dimensional
ball topology.
<pre>
template<typename RandomNumberGenerator = minstd_rand>
class sphere_topology : public <a href="#ball_topology">ball_topology</a><3, RandomNumberGenerator>
{
public:
explicit sphere_topology(double radius = 1.0);
sphere_topology(RandomNumberGenerator& gen, double radius = 1.0);
};
</pre>
<a name="heart_topology"><h3>Class template <tt>heart_topology</tt></h3></a>
<p>Class template <tt>heart_topology</tt> is topology in the shape of
a heart. It serves as an example of a non-convex, nontrivial topology
for layout.
<pre>
template<typename RandomNumberGenerator = minstd_rand>
class heart_topology
{
public:
typedef <em>unspecified</em> point_type;
heart_topology();
heart_topology(RandomNumberGenerator& gen);
point_type random_point() const;
double distance(point_type a, point_type b) const;
point_type move_position_toward(point_type a, double fraction, point_type b) const;
};
</pre>
<br>
<HR>
<TABLE>
<TR valign=top>
<TD nowrap>Copyright © 2004</TD><TD>
Jeremiah Willcock, Indiana University (<script language="Javascript">address("osl.iu.edu", "jewillco")</script>)<br>
<A HREF="http://www.boost.org/people/doug_gregor.html">Doug Gregor</A>, Indiana University (<script language="Javascript">address("cs.indiana.edu", "dgregor")</script>)<br>
<A HREF=http://www.osl.iu.edu/~lums>Andrew Lumsdaine</A>,
Indiana University (<script language="Javascript">address("osl.iu.edu", "lums")</script>)
</TD></TR></TABLE>
</BODY>
</HTML>
|