kamada_kawai_spring_layout.html 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <html>
  3. <!--
  4. Copyright (c) 2004, 2010 Trustees of Indiana University
  5. Distributed under the Boost Software License, Version 1.0.
  6. (See accompanying file LICENSE_1_0.txt or copy at
  7. http://www.boost.org/LICENSE_1_0.txt)
  8. -->
  9. <head>
  10. <meta name="generator" content=
  11. "HTML Tidy for Mac OS X (vers 12 April 2005), see www.w3.org">
  12. <meta http-equiv="Content-Type" content=
  13. "text/html; charset=us-ascii">
  14. <title>Function kamada_kawai_spring_layout</title>
  15. </head>
  16. <body bgcolor="white" text="black" link="#0000FF" vlink="#840084"
  17. alink="#0000FF">
  18. <table cellpadding="2" width="100%">
  19. <tr>
  20. <td valign="top"><img src="../../../boost.png" alt=
  21. "boost.png (6897 bytes)" width="277" height="86"></td>
  22. <td align="center"><a href="../../../index.htm">Home</a></td>
  23. <td align="center"><a href="../../libraries.htm">Libraries</a></td>
  24. <td align="center"><a href=
  25. "http://www.boost.org/people/people.htm">People</a></td>
  26. <td align="center"><a href="http://www.boost.org/more/faq.htm">FAQ</a></td>
  27. <td align="center"><a href="../../../more/index.htm">More</a></td>
  28. </tr>
  29. </table>
  30. <hr>
  31. <div class="refentry" lang="en"><a name="id103831-bb" id=
  32. "id103831-bb"></a>
  33. <div class="titlepage"></div>
  34. <div class="refnamediv">
  35. <h2><img src="figs/python.gif" alt="(Python)"><span class=
  36. "refentrytitle">Function kamada_kawai_spring_layout</span></h2>
  37. <p>boost::kamada_kawai_spring_layout &mdash; Kamada-Kawai spring
  38. layout for connected, undirected graphs.</p>
  39. </div>
  40. <h2 xmlns:rev=
  41. "http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class=
  42. "refsynopsisdiv-title">Synopsis</h2>
  43. <div xmlns:rev=
  44. "http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class=
  45. "refsynopsisdiv">
  46. <pre class="synopsis">
  47. <span class="bold"><b>template</b></span>&lt;<span class=
  48. "bold"><b>typename</b></span> Topology, <span class=
  49. "bold"><b>typename</b></span> Graph, <span class=
  50. "bold"><b>typename</b></span> PositionMap, <span class=
  51. "bold"><b>typename</b></span> WeightMap, <span class=
  52. "bold"><b>typename</b></span> T,
  53. <span class=
  54. "bold"><b>bool</b></span> EdgeOrSideLength, <span class=
  55. "bold"><b>typename</b></span> Done, <span class=
  56. "bold"><b>typename</b></span> VertexIndexMap,
  57. <span class=
  58. "bold"><b>typename</b></span> DistanceMatrix, <span class=
  59. "bold"><b>typename</b></span> SpringStrengthMatrix,
  60. <span class=
  61. "bold"><b>typename</b></span> PartialDerivativeMap&gt;
  62. <span class="type"><span class=
  63. "bold"><b>bool</b></span></span> kamada_kawai_spring_layout(<span class="bold"><b>const</b></span> Graph &amp; g, PositionMap position,
  64. WeightMap weight,
  65. <b>const</b> Topology&amp; space,
  66. <span class=
  67. "emphasis"><em>unspecified</em></span> edge_or_side_length, Done done,
  68. <span class=
  69. "bold"><b>typename</b></span> property_traits&lt; WeightMap &gt;::value_type spring_constant,
  70. VertexIndexMap index,
  71. DistanceMatrix distance,
  72. SpringStrengthMatrix spring_strength,
  73. PartialDerivativeMap partial_derivatives);
  74. <span class="bold"><b>template</b></span>&lt;<span class=
  75. "bold"><b>typename</b></span> Topology, <span class=
  76. "bold"><b>typename</b></span> Graph, <span class=
  77. "bold"><b>typename</b></span> PositionMap, <span class=
  78. "bold"><b>typename</b></span> WeightMap, <span class=
  79. "bold"><b>typename</b></span> T,
  80. <span class=
  81. "bold"><b>bool</b></span> EdgeOrSideLength, <span class=
  82. "bold"><b>typename</b></span> Done, <span class=
  83. "bold"><b>typename</b></span> VertexIndexMap&gt;
  84. <span class="type"><span class=
  85. "bold"><b>bool</b></span></span> kamada_kawai_spring_layout(<span class="bold"><b>const</b></span> Graph &amp; g, PositionMap position,
  86. WeightMap weight,
  87. <b>const</b> Topology&amp; space,
  88. <span class=
  89. "emphasis"><em>unspecified</em></span> edge_or_side_length, Done done,
  90. <span class=
  91. "bold"><b>typename</b></span> property_traits&lt; WeightMap &gt;::value_type spring_constant,
  92. VertexIndexMap index);
  93. <span class="bold"><b>template</b></span>&lt;<span class=
  94. "bold"><b>typename</b></span> Topology, <span class=
  95. "bold"><b>typename</b></span> Graph, <span class=
  96. "bold"><b>typename</b></span> PositionMap, <span class=
  97. "bold"><b>typename</b></span> WeightMap, <span class=
  98. "bold"><b>typename</b></span> T,
  99. <span class=
  100. "bold"><b>bool</b></span> EdgeOrSideLength, <span class=
  101. "bold"><b>typename</b></span> Done&gt;
  102. <span class="type"><span class=
  103. "bold"><b>bool</b></span></span> kamada_kawai_spring_layout(<span class="bold"><b>const</b></span> Graph &amp; g, PositionMap position,
  104. WeightMap weight,
  105. <b>const</b> Topology&amp; space,
  106. <span class=
  107. "emphasis"><em>unspecified</em></span> edge_or_side_length, Done done,
  108. <span class=
  109. "bold"><b>typename</b></span> property_traits&lt; WeightMap &gt;::value_type spring_constant = typename property_traits&lt; WeightMap &gt;::value_type(1));
  110. <span class="bold"><b>template</b></span>&lt;<span class=
  111. "bold"><b>typename</b></span> Topology, <span class=
  112. "bold"><b>typename</b></span> Graph, <span class=
  113. "bold"><b>typename</b></span> PositionMap, <span class=
  114. "bold"><b>typename</b></span> WeightMap, <span class=
  115. "bold"><b>typename</b></span> T,
  116. <span class=
  117. "bold"><b>bool</b></span> EdgeOrSideLength&gt;
  118. <span class="type"><span class=
  119. "bold"><b>bool</b></span></span> kamada_kawai_spring_layout(<span class="bold"><b>const</b></span> Graph &amp; g, PositionMap position,
  120. WeightMap weight,
  121. <b>const</b> Topology&amp; space,
  122. <span class=
  123. "emphasis"><em>unspecified</em></span> edge_or_side_length);
  124. </pre></div>
  125. <div class="refsect1" lang="en"><a name="id822881" id=
  126. "id822881"></a>
  127. <h2>Where Defined</h2>
  128. <a href=
  129. "../../../boost/graph/kamada_kawai_spring_layout.hpp">boost/graph/kamada_kawai_spring_layout.hpp</a>
  130. <h2>Description</h2>
  131. <p>This algorithm&nbsp;[<a href=
  132. "bibliography.html#kamada89">57</a>] performs graph layout (in two
  133. dimensions) for connected, undirected graphs. It operates by
  134. relating the layout of graphs to a dynamic spring system and
  135. minimizing the energy within that system. The strength of a spring
  136. between two vertices is inversely proportional to the square of the
  137. shortest distance (in graph terms) between those two vertices.
  138. Essentially, vertices that are closer in the graph-theoretic sense
  139. (i.e., by following edges) will have stronger springs and will
  140. therefore be placed closer together.</p>
  141. <p>Prior to invoking this algorithm, it is recommended that the
  142. vertices be placed along the vertices of a regular n-sided polygon
  143. via <a href="circle_layout.html"><tt>circle_layout</tt></a>.</p>
  144. <p><b xmlns:rev=
  145. "http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision"><span class="term">
  146. Returns</span></b>: <tt class="computeroutput">true</tt> if layout
  147. was successful or <tt class="computeroutput">false</tt> if a
  148. negative weight cycle was detected or the graph is
  149. disconnected.</p>
  150. <h2>Parameters</h2>
  151. IN: <tt>const Graph&amp; g</tt>
  152. <blockquote>
  153. The graph, whose type <tt>Graph</tt> must model the
  154. <a href="VertexListGraph.html">VertexListGraph</a>,
  155. <a href="EdgeListGraph.html">EdgeListGraph</a>, and
  156. <a href="IncidenceGraph.html">IncidenceGraph</a> concepts. The
  157. graph must be undirected and connected. <br>
  158. <b>Python</b>: This parameter is named <tt>graph</tt> in Python.
  159. </blockquote>
  160. OUT: <tt>PositionMap position</tt>
  161. <blockquote>
  162. This property map is used to store the position of each vertex. The
  163. type <tt>PositionMap</tt> must be a model of <a
  164. href="../../property_map/doc/WritablePropertyMap.html">Writable Property
  165. Map</a>, with the graph's vertex descriptor type as its key type and
  166. <tt>Topology::point_type</tt> as its value type.<br>
  167. <b>Python</b>: The position map must be a <tt>vertex_point2d_map</tt> for
  168. the graph.<br>
  169. <b>Python default</b>: <tt>graph.get_vertex_point2d_map("position")</tt>
  170. </blockquote>
  171. IN: <tt>weight_map(WeightMap w_map)</tt>
  172. <blockquote>
  173. The weight or ``length'' of each edge in the graph. The weights
  174. must all be non-negative, and the algorithm will throw a
  175. <a href="./exception.html#negative_edge"><tt>negative_edge</tt></a>
  176. exception is one of the edges is negative.
  177. The type <tt>WeightMap</tt> must be a model of
  178. <a href="../../property_map/doc/ReadablePropertyMap.html">Readable Property Map</a>. The edge descriptor type of
  179. the graph needs to be usable as the key type for the weight
  180. map. The value type for this map must be
  181. the same as the value type of the distance map.<br>
  182. <b>Default:</b> <tt>get(edge_weight, g)</tt><br>
  183. <b>Python</b>: Must be an <tt>edge_double_map</tt> for the graph.<br>
  184. <b>Python default</b>: <tt>graph.get_edge_double_map("weight")</tt>
  185. </blockquote>
  186. IN: <tt>const Topology&amp; space</tt>
  187. <blockquote>
  188. The topology used to lay out the vertices. This parameter describes both the
  189. size and shape of the layout area, as well as its dimensionality; up to three
  190. dimensions are supported by the current implementation. Topologies are
  191. described in more detail
  192. (with a list of BGL-provided topologies) <a href="topology.html">in separate
  193. documentation</a>.
  194. </blockquote>
  195. IN: <tt>EdgeOrSideLength edge_or_side_length</tt>
  196. <blockquote>
  197. Provides either the unit length <tt class= "computeroutput">e</tt> of
  198. an edge in the layout or the length of a side <tt
  199. class="computeroutput">s</tt> of the display area, and must be
  200. either <tt class= "computeroutput">boost::edge_length(e)</tt> or <tt
  201. class= "computeroutput">boost::side_length(s)</tt> , respectively.
  202. <b>Python</b>: In Python, this value always refers to the side length
  203. and may only be a <tt>double</tt>.
  204. </blockquote>
  205. IN: <tt>Done done</tt>
  206. <blockquote>
  207. A 4-argument function object that is passed the current
  208. value of delta_p (i.e., the energy of vertex <tt class=
  209. "computeroutput">p</tt> ), the vertex <tt class=
  210. "computeroutput">p</tt> , the graph <tt class=
  211. "computeroutput">g</tt> , and a boolean flag indicating whether
  212. <tt class="computeroutput">delta_p</tt> is the maximum energy in
  213. the system (when <tt class="computeroutput">true</tt> ) or the
  214. energy of the vertex being moved.
  215. <b>Default</b>: <a href=
  216. "layout_tolerance.html"><tt class=
  217. "computeroutput">layout_tolerance</tt></a> instantiated over the
  218. value type of the weight map.<br>
  219. <b>Python</b>: Any callable Python object with an appropriate signature suffices.
  220. </blockquote>
  221. IN: <tt>typename property_traits&lt;WeightMap&gt;::value_type spring_constant</tt>
  222. <blockquote>
  223. The constant multiplied by each spring's strength.
  224. Larger values create systems with more energy that can take longer
  225. to stabilize; smaller values create systems with less energy that
  226. stabilize quickly but do not necessarily result in pleasing
  227. layouts.<br>
  228. <b>Default</b>: 1.
  229. </blockquote>
  230. IN: <tt>VertexIndexMap index</tt>
  231. <blockquote>
  232. As a mapping from vertices to index values between 0 and
  233. <tt class="computeroutput">num_vertices(g)</tt> .<br>
  234. <b>Default</b>:<tt class="computeroutput">get(vertex_index,g)</tt>.
  235. Note: if you use this default, make sure your graph has
  236. an internal <tt>vertex_index</tt> property. For example,
  237. <tt>adjacency_list</tt> with <tt>VertexList=listS</tt> does
  238. not have an internal <tt>vertex_index</tt> property.
  239. <br>
  240. <b>Python</b>: Unsupported parameter.
  241. </blockquote>
  242. UTIL/OUT: <tt>DistanceMap distance</tt>
  243. <blockquote>
  244. This parameter will be used to store the distance from every vertex to
  245. every other vertex, which is computed in the first stages of the
  246. algorithm. This value's type must be a model of <a
  247. href="BasicMatrix.html"><tt>BasicMatrix</tt></a> with value type equal to
  248. the value type of the weight map.<br>
  249. <b>Default</b>: A vector of vectors.<br>
  250. <b>Python</b>: Unsupported parameter.
  251. </blockquote>
  252. UTIL/OUT: <tt>SpringStrengthMatrix spring_strength</tt>
  253. <blockquote>
  254. This matrix will be used to store the strength of the spring between
  255. every pair of vertices. This value's type must be a model of <a
  256. href="BasicMatrix.html">BasicMatrix</a> with value type equal to the
  257. value type of the weight map.<br>
  258. <b>Default</b>: A vector of vectors of the value type of the weight map.<br>
  259. <b>Python</b>: Unsupported parameter.
  260. </blockquote>
  261. UTIL: <tt>PartialDerivativeMap partial_derivatives</tt>
  262. <blockquote>
  263. A property map that will be used to store the partial derivatives of
  264. each vertex with respect to the vertex's current coordinates.
  265. coordinates. This must be a
  266. <a href="../../property_map/doc/ReadWritePropertyMap.html">Read/Write
  267. Property Map</a> whose value type is <tt>Topology::point_difference_type</tt>.
  268. The default is an iterator property map built using the graph's vertex index
  269. map.<br>
  270. <b>Default</b>: An <tt>iterator_property_map</tt> created from
  271. an <tt>std::vector</tt> of <tt>Topology::point_difference_type</tt>.<br>
  272. <b>Python</b>: Unsupported parameter.
  273. </blockquote>
  274. <b>Python</b> IN: <tt>bool progressive</tt>
  275. <blockquote>
  276. When <tt>false</tt>, performs layout of the graph on a circle before
  277. running the Kamada-Kawai algorithm. If <tt>true</tt>, the algorithm
  278. is executing starting with the vertex configuration in
  279. the <tt>position</tt> map.<br>
  280. <b>Default</b>: <tt>False</tt>.
  281. </blockquote>
  282. </div>
  283. </div>
  284. </div>
  285. <table xmlns:rev=
  286. "http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width=
  287. "100%">
  288. <tr>
  289. <td align="left"></td>
  290. <td align="right"></td>
  291. </tr>
  292. </table>
  293. <hr>
  294. <table>
  295. <tr valign="top">
  296. <td nowrap>Copyright &copy; 2004, 2010 Trustees of Indiana University</td>
  297. <td><a href="http://www.boost.org/people/doug_gregor.html">Douglas Gregor</a>,
  298. Indiana University (dgregor -at cs.indiana.edu)<br>
  299. <a href="https://homes.cs.washington.edu/~al75">Andrew Lumsdaine</a>, Indiana
  300. University (<a href=
  301. "mailto:lums@osl.iu.edu">lums@osl.iu.edu</a>)</td>
  302. </tr>
  303. </table>
  304. </body>
  305. </html>