straight_line_drawing.html 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <HTML>
  2. <!-- Copyright 2007 Aaron Windsor
  3. Distributed under the Boost Software License, Version 1.0.
  4. (See accompanying file LICENSE_1_0.txt or copy at
  5. http://www.boost.org/LICENSE_1_0.txt)
  6. -->
  7. <Head>
  8. <Title>Boost Graph Library: Chrobak-Payne Straight Line Drawing</Title>
  9. <BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
  10. ALINK="#ff0000">
  11. <IMG SRC="../../../boost.png"
  12. ALT="C++ Boost" width="277" height="86">
  13. <BR Clear>
  14. <H1>Chrobak-Payne Straight Line Drawing</H1>
  15. <p>
  16. <pre>
  17. template&lt;typename Graph,
  18. typename PlanarEmbedding,
  19. typename ForwardIterator,
  20. typename PositionMap,
  21. typename VertexIndexMap&gt;
  22. void chrobak_payne_straight_line_drawing(const Graph& g,
  23. PlanarEmbedding perm,
  24. ForwardIterator ordering_begin,
  25. ForwardIterator ordering_end,
  26. PositionMap drawing,
  27. VertexIndexMap vm
  28. );
  29. </pre>
  30. <br>
  31. <p>
  32. A <i>straight line drawing</i> of a <a href="./planar_graphs.html#planar">
  33. planar graph</a> is a <a href="./planar_graphs.html#plane_drawing">plane
  34. drawing</a> where each edge is drawn using a straight line segment. Since all
  35. edges are line segments, the drawing is completely determined by the placement
  36. of vertices in the plane. <tt>chrobak_payne_straight_line_drawing</tt> uses an
  37. algorithm of Chrobak and Payne
  38. [<a href = "./bibliography.html#chrobakpayne95">71</a>]
  39. to form a straight
  40. line drawing of a planar graph by mapping all <i>n</i> vertices in a planar
  41. graph to integer coordinates in a <i>(2n - 4) x (n - 2)</i> grid.
  42. <center>
  43. <img src="./figs/straight_line_drawing.png">
  44. </center>
  45. <p>
  46. The input graph passed to <tt>chrobak_payne_straight_line_drawing</tt> must
  47. be a <a href="make_maximal_planar.html">maximal planar graph</a> with at least
  48. 3 vertices. Self-loops and parallel edges are ignored by this function. Note
  49. that the restriction that the graph be maximal planar does not
  50. mean that this function can only draw maximal planar graphs (the graph pictured
  51. above is not maximal planar, for example). If you want to
  52. draw a graph <i>g</i>, you can create a copy <i>g'</i> of <i>g</i>, store a
  53. mapping <i>m</i> of vertices in <i>g'</i> to vertices in <i>g</i>,
  54. <a href="make_maximal_planar.html">triangulate</a> <i>g'</i>, and then send
  55. <i>g'</i> in as the input to <tt>chrobak_payne_straight_line_drawing</tt>. The
  56. drawing returned can then be applied to <i>g</i> using <i>m</i> to translate
  57. vertices from one graph to another, since <i>g</i> contains a subset of the
  58. edges in <i>g'</i>.
  59. <h3>Complexity</h3>
  60. If the vertex index map provides constant-time access to indices, this
  61. function takes time <i>O(n + m)</i> for a planar graph with <i>n</i> vertices
  62. and <i>m</i> edges. Note that
  63. in a simple planar graph with <i>f</i> faces, <i>m</i> edges, and <i>n</i>
  64. vertices, both <i>f</i> and <i>m</i> are <i>O(n)</i>.
  65. <H3>Where Defined</H3>
  66. <P>
  67. <a href="../../../boost/graph/chrobak_payne_drawing.hpp">
  68. <TT>boost/graph/chrobak_payne_drawing.hpp</TT>
  69. </a>
  70. <h3>Parameters</h3>
  71. IN: <tt>Graph&amp; g</tt>
  72. <blockquote>
  73. An undirected graph. The graph type must be a model of <a
  74. href="VertexListGraph.html">Vertex List Graph</a>
  75. </blockquote>
  76. IN <tt>PlanarEmbedding embedding</tt>
  77. <blockquote>
  78. A <a href="../../property_map/doc/ReadablePropertyMap.html">Readable Property Map
  79. </a> that models the <a href="PlanarEmbedding.html">PlanarEmbedding</a>
  80. concept.
  81. </blockquote>
  82. IN <tt>ForwardIterator</tt>
  83. <blockquote>
  84. A ForwardIterator that has <tt>value_type</tt> equal to
  85. <tt>graph_traits&lt;Graph&gt;::vertex_descriptor</tt>.
  86. </blockquote>
  87. OUT: <tt>PositionMap</tt>
  88. <blockquote>
  89. A <a href="../../property_map/doc/LvaluePropertyMap.html">Writable LValue Property
  90. Map</a> that models the Position Map concept. The Position Map concept requires
  91. that the value mapped to be an object that has members <tt>x</tt> and
  92. <tt>y</tt>. For example, if <tt>p</tt> models PositionMap and <tt>v</tt>
  93. is a vertex in the graph, <tt>p[v].x</tt> and <tt>p[v].y</tt> are valid
  94. expressions. The type of <tt>x</tt> and <tt>y</tt> must be implicitly
  95. convertable to <tt>std::size_t</tt>.
  96. </blockquote>
  97. IN: <tt>VertexIndexMap vm</tt>
  98. <blockquote>
  99. A <a href="../../property_map/doc/ReadablePropertyMap.html">Readable Property Map
  100. </a> that maps vertices from <tt>g</tt> to distinct integers in the range
  101. <tt>[0, num_vertices(g) )</tt><br>
  102. <b>Default</b>: <tt>get(vertex_index,g)</tt><br>
  103. </blockquote>
  104. <H3>Example</H3>
  105. <P>
  106. <a href="../example/straight_line_drawing.cpp">
  107. <TT>examples/straight_line_drawing.cpp</TT>
  108. </a>
  109. <h3>See Also</h3>
  110. <p>
  111. <ul>
  112. <li> <a href="planar_graphs.html">Planar Graphs in the Boost Graph Library</a>
  113. <li> <a href="is_straight_line_drawing.html"><tt>is_straight_line_drawing</tt>
  114. </a>
  115. </ul>
  116. <br>
  117. <HR>
  118. Copyright &copy; 2007 Aaron Windsor (<a href="mailto:aaron.windsor@gmail.com">
  119. aaron.windsor@gmail.com</a>)
  120. </BODY>
  121. </HTML>