copy_graph.html 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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: Copy 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>copy_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 copy_graph(const VertexListGraph&amp; G, MutableGraph&amp; G_copy,
  19. const bgl_named_params&lt;P, T, R&gt;&amp; params = <i>all defaults</i>)
  20. </PRE>
  21. This function copies all of the vertices and edges from graph
  22. <tt>G</tt> into <tt>G_copy</tt>. Also, it copies the vertex and edge
  23. properties, either by using the <tt>vertex_all</tt> and
  24. <tt>edge_all</tt> property maps, or by user-supplied copy functions.
  25. <H3>Where Defined</H3>
  26. <P>
  27. <a href="../../../boost/graph/copy.hpp"><TT>boost/graph/copy.hpp</TT></a>
  28. <P>
  29. <H3>Parameters</H3>
  30. IN: <tt>const VertexListGraph&amp; G</tt>
  31. <blockquote>
  32. A directed or undirected graph. The graph type must be a model of <a href="./VertexListGraph.html">Vertex List Graph</a>.
  33. </blockquote>
  34. OUT: <tt>MutableGraph&amp; G_copy</tt>
  35. <blockquote>
  36. The resulting copy of the graph. The graph type must be a model of <a
  37. href="./MutableGraph.html">Mutable Graph</a>.
  38. </blockquote>
  39. <h3>Named Parameters</h3>
  40. IN: <tt>vertex_copy(VertexCopier vc)</tt>
  41. <blockquote>
  42. 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
  43. into the corresponding vertex in the copy.<br>
  44. <b>Default:</b> <tt>vertex_copier&lt;VertexListGraph, MutableGraph&gt;</tt>
  45. which uses the property tag <tt>vertex_all</tt> to access a property
  46. map from the graph.
  47. </blockquote>
  48. IN: <tt>edge_copy(EdgeCopier ec)</tt>
  49. <blockquote>
  50. 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
  51. into the corresponding edge in the copy.<br>
  52. <b>Default:</b> <tt>edge_copier&lt;VertexListGraph, MutableGraph&gt;</tt>
  53. which uses the property tag <tt>edge_all</tt> to access a property
  54. map from the graph.
  55. </blockquote>
  56. IN: <tt>vertex_index_map(VertexIndexMap i_map)</tt>
  57. <blockquote>
  58. The vertex index map type must be a model of <a
  59. href="../../property_map/doc/ReadablePropertyMap.html">Readable Property
  60. Map</a> and must map the vertex descriptors of <tt>G</tt> to the
  61. integers in the half-open range <tt>[0,num_vertices(G))</tt>.<br>
  62. <b>Default:</b> <tt>get(vertex_index, G)</tt>.
  63. Note: if you use this default, make sure your graph has
  64. an internal <tt>vertex_index</tt> property. For example,
  65. <tt>adjacency_list</tt> with <tt>VertexList=listS</tt> does
  66. not have an internal <tt>vertex_index</tt> property.
  67. </blockquote>
  68. UTIL/OUT: <tt>orig_to_copy(Orig2CopyMap c)</tt>
  69. <blockquote>
  70. This maps vertices in the original graph to vertices in the copy.
  71. <b>Default:</b> an <a
  72. href="../../property_map/doc/iterator_property_map.html">
  73. </tt>iterator_property_map</tt></a> created from a
  74. <tt>std::vector</tt> of the output graph's vertex descriptor type of size
  75. <tt>num_vertices(g)</tt> and using the <tt>i_map</tt> for the index
  76. map.
  77. </blockquote>
  78. <H3>Complexity</H3>
  79. <P>
  80. The time complexity is <i>O(V + E)</i>.
  81. <br>
  82. <HR>
  83. <TABLE>
  84. <TR valign=top>
  85. <TD nowrap>Copyright &copy; 2000-2001</TD><TD>
  86. <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>)
  87. </TD></TR></TABLE>
  88. </BODY>
  89. </HTML>