transpose_graph.html 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <HTML>
  2. <!--
  3. Copyright (c) Jeremy Siek 2000
  4. Distributed under the Boost Software License, Version 1.0.
  5. (See accompanying file LICENSE_1_0.txt or copy at
  6. http://www.boost.org/LICENSE_1_0.txt)
  7. -->
  8. <Head>
  9. <Title>Boost Graph Library: Transpose Graph</Title>
  10. <BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
  11. ALINK="#ff0000">
  12. <IMG SRC="../../../boost.png"
  13. ALT="C++ Boost" width="277" height="86">
  14. <BR Clear>
  15. <H1><TT>transpose_graph</TT></H1>
  16. <PRE>
  17. template &lt;class <a href="./VertexListGraph.html">VertexListGraph</a>, class <a href="./MutableGraph.html">MutableGraph</a>&gt;
  18. void transpose_graph(const VertexListGraph&amp; G, MutableGraph&amp; G_T,
  19. const bgl_named_params&lt;P, T, R&gt;&amp; params = <i>all defaults</i>)
  20. </PRE>
  21. <P>
  22. This function computes the transpose of a directed graph. The
  23. transpose of a directed graph <i>G = (V, E)</i>is the graph
  24. <i>G<sup>T</sup> = (V, E<sup>T</sup>)</i> , where <i>E<sup>T</sup> =
  25. {(v, u) in V x V: (u, v) in E}</i> . i.e., <i>G<sup>T</sup></i> is
  26. <i>G</i> with all its edges reversed. Graph <TT>G_T</TT> passed into
  27. the algorithm must have no vertices and
  28. no edges. The vertices and edges will be added by <tt>transpose_graph()</tt> by
  29. calling <tt>add_vertex</tt> and <tt>add_edge</tt> as follows for each edge
  30. <i>(u,v)</i> in <tt>G</tt>.
  31. <H3>Example</H3>
  32. Here's an example of transposing a graph:
  33. <a href="../example/transpose-example.cpp"><tt>example/transpose-example.cpp</tt></a>.
  34. <H3>Where Defined</H3>
  35. <P>
  36. <a href="../../../boost/graph/transpose_graph.hpp"><TT>boost/graph/transpose_graph.hpp</TT></a>
  37. <P>
  38. <H3>Parameters</H3>
  39. IN: <tt>const VertexListGraph&amp; G</tt>
  40. <blockquote>
  41. A directed graph. The graph type must be a model of <a href="./VertexListGraph.html">Vertex List Graph</a>.
  42. </blockquote>
  43. OUT: <tt>const MutableGraph&amp; G_T</tt>
  44. <blockquote>
  45. The transposed graph. The graph type must be a model of <a
  46. href="./MutableGraph.html">Mutable Graph</a>.
  47. </blockquote>
  48. <h3>Named Parameters</h3>
  49. IN: <tt>vertex_copy(VertexCopier vc)</tt>
  50. <blockquote>
  51. This is a <a href="http://www.boost.org/sgi/stl/BinaryFunction.html">Binary Function</a> that copies the properties of a vertex in the original graph
  52. into the corresponding vertex in the copy.<br>
  53. <b>Default:</b> <tt>vertex_copier&lt;VertexListGraph, MutableGraph&gt;</tt>
  54. which uses the property tag <tt>vertex_all</tt> to access a property
  55. map from the graph.
  56. </blockquote>
  57. IN: <tt>edge_copy(EdgeCopier ec)</tt>
  58. <blockquote>
  59. This is a <a href="http://www.boost.org/sgi/stl/BinaryFunction.html">Binary Function</a> that copies the properties of an edge in the original graph
  60. into the corresponding edge in the copy.<br>
  61. <b>Default:</b> <tt>edge_copier&lt;VertexListGraph, MutableGraph&gt;</tt>
  62. which uses the property tag <tt>edge_all</tt> to access a property
  63. map from the graph.
  64. </blockquote>
  65. IN: <tt>vertex_index_map(VertexIndexMap i_map)</tt>
  66. <blockquote>
  67. The vertex index map type must be a model of <a
  68. href="../../property_map/doc/ReadablePropertyMap.html">Readable Property
  69. Map</a> and must map the vertex descriptors of <tt>G</tt> to the
  70. integers from 0 to <tt>num_vertices(G)</tt>.<br>
  71. <b>Default:</b> <tt>get(vertex_index, G)</tt>
  72. Note: if you use this default, make sure your graph has
  73. an internal <tt>vertex_index</tt> property. For example,
  74. <tt>adjacency_list</tt> with <tt>VertexList=listS</tt> does
  75. not have an internal <tt>vertex_index</tt> property.
  76. </blockquote>
  77. UTIL/OUT: <tt>orig_to_copy(Orig2CopyMap c)</tt>
  78. <blockquote>
  79. This maps vertices in the original graph to vertices in the copy.
  80. <b>Default:</b> an <a
  81. href="../../property_map/doc/iterator_property_map.html">
  82. </tt>iterator_property_map</tt></a> created from a
  83. <tt>std::vector</tt> of the output graph's vertex descriptor type of size
  84. <tt>num_vertices(g)</tt> and using the <tt>i_map</tt> for the index
  85. map.
  86. </blockquote>
  87. <H3>Complexity</H3>
  88. <P>
  89. The time complexity is <i>O(V + E)</i>.
  90. <br>
  91. <HR>
  92. <TABLE>
  93. <TR valign=top>
  94. <TD nowrap>Copyright &copy; 2000-2001</TD><TD>
  95. <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>)
  96. </TD></TR></TABLE>
  97. </BODY>
  98. </HTML>