os/ossrv/ossrv_pub/boost_apis/boost/graph/copy.hpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
//
sl@0
     2
//=======================================================================
sl@0
     3
// Copyright 1997-2001 University of Notre Dame.
sl@0
     4
// Authors: Jeremy G. Siek, Lie-Quan Lee, Andrew Lumsdaine
sl@0
     5
//
sl@0
     6
// Distributed under the Boost Software License, Version 1.0. (See
sl@0
     7
// accompanying file LICENSE_1_0.txt or copy at
sl@0
     8
// http://www.boost.org/LICENSE_1_0.txt)
sl@0
     9
//=======================================================================
sl@0
    10
//
sl@0
    11
sl@0
    12
/*
sl@0
    13
  This file implements the following functions:
sl@0
    14
sl@0
    15
sl@0
    16
  template <typename VertexListGraph, typename MutableGraph>
sl@0
    17
  void copy_graph(const VertexListGraph& g_in, MutableGraph& g_out)
sl@0
    18
sl@0
    19
  template <typename VertexListGraph, typename MutableGraph, 
sl@0
    20
    class P, class T, class R>
sl@0
    21
  void copy_graph(const VertexListGraph& g_in, MutableGraph& g_out, 
sl@0
    22
                  const bgl_named_params<P, T, R>& params)
sl@0
    23
sl@0
    24
sl@0
    25
  template <typename IncidenceGraph, typename MutableGraph>
sl@0
    26
  typename graph_traits<MutableGraph>::vertex_descriptor
sl@0
    27
  copy_component(IncidenceGraph& g_in, 
sl@0
    28
                 typename graph_traits<IncidenceGraph>::vertex_descriptor src,
sl@0
    29
                 MutableGraph& g_out)
sl@0
    30
sl@0
    31
  template <typename IncidenceGraph, typename MutableGraph, 
sl@0
    32
           typename P, typename T, typename R>
sl@0
    33
  typename graph_traits<MutableGraph>::vertex_descriptor
sl@0
    34
  copy_component(IncidenceGraph& g_in, 
sl@0
    35
                 typename graph_traits<IncidenceGraph>::vertex_descriptor src,
sl@0
    36
                 MutableGraph& g_out, 
sl@0
    37
                 const bgl_named_params<P, T, R>& params)
sl@0
    38
 */
sl@0
    39
sl@0
    40
sl@0
    41
#ifndef BOOST_GRAPH_COPY_HPP
sl@0
    42
#define BOOST_GRAPH_COPY_HPP
sl@0
    43
sl@0
    44
#include <boost/config.hpp>
sl@0
    45
#include <vector>
sl@0
    46
#include <boost/graph/graph_traits.hpp>
sl@0
    47
#include <boost/property_map.hpp>
sl@0
    48
#include <boost/graph/named_function_params.hpp>
sl@0
    49
#include <boost/graph/breadth_first_search.hpp>
sl@0
    50
#include <boost/type_traits/conversion_traits.hpp>
sl@0
    51
sl@0
    52
namespace boost {
sl@0
    53
sl@0
    54
  namespace detail {
sl@0
    55
sl@0
    56
    // Default edge and vertex property copiers
sl@0
    57
sl@0
    58
    template <typename Graph1, typename Graph2>
sl@0
    59
    struct edge_copier {
sl@0
    60
      edge_copier(const Graph1& g1, Graph2& g2)
sl@0
    61
        : edge_all_map1(get(edge_all, g1)), 
sl@0
    62
          edge_all_map2(get(edge_all, g2)) { }
sl@0
    63
sl@0
    64
      template <typename Edge1, typename Edge2>
sl@0
    65
      void operator()(const Edge1& e1, Edge2& e2) const {
sl@0
    66
        put(edge_all_map2, e2, get(edge_all_map1, e1));
sl@0
    67
      }
sl@0
    68
      typename property_map<Graph1, edge_all_t>::const_type edge_all_map1;
sl@0
    69
      mutable typename property_map<Graph2, edge_all_t>::type edge_all_map2;
sl@0
    70
    };
sl@0
    71
    template <typename Graph1, typename Graph2>
sl@0
    72
    inline edge_copier<Graph1,Graph2>
sl@0
    73
    make_edge_copier(const Graph1& g1, Graph2& g2)
sl@0
    74
    {
sl@0
    75
      return edge_copier<Graph1,Graph2>(g1, g2);
sl@0
    76
    }
sl@0
    77
sl@0
    78
    template <typename Graph1, typename Graph2>
sl@0
    79
    struct vertex_copier {
sl@0
    80
      vertex_copier(const Graph1& g1, Graph2& g2)
sl@0
    81
        : vertex_all_map1(get(vertex_all, g1)), 
sl@0
    82
          vertex_all_map2(get(vertex_all, g2)) { }
sl@0
    83
sl@0
    84
      template <typename Vertex1, typename Vertex2>
sl@0
    85
      void operator()(const Vertex1& v1, Vertex2& v2) const {
sl@0
    86
        put(vertex_all_map2, v2, get(vertex_all_map1, v1));
sl@0
    87
      }
sl@0
    88
      typename property_map<Graph1, vertex_all_t>::const_type vertex_all_map1;
sl@0
    89
      mutable typename property_map<Graph2, vertex_all_t>::type
sl@0
    90
        vertex_all_map2;
sl@0
    91
    };
sl@0
    92
    template <typename Graph1, typename Graph2>
sl@0
    93
    inline vertex_copier<Graph1,Graph2>
sl@0
    94
    make_vertex_copier(const Graph1& g1, Graph2& g2)
sl@0
    95
    {
sl@0
    96
      return vertex_copier<Graph1,Graph2>(g1, g2);
sl@0
    97
    }
sl@0
    98
sl@0
    99
    // Copy all the vertices and edges of graph g_in into graph g_out.
sl@0
   100
    // The copy_vertex and copy_edge function objects control how vertex
sl@0
   101
    // and edge properties are copied.
sl@0
   102
sl@0
   103
    template <int Version>
sl@0
   104
    struct copy_graph_impl { };
sl@0
   105
sl@0
   106
    template <> struct copy_graph_impl<0>
sl@0
   107
    {
sl@0
   108
      template <typename Graph, typename MutableGraph, 
sl@0
   109
        typename CopyVertex, typename CopyEdge, typename IndexMap,
sl@0
   110
        typename Orig2CopyVertexIndexMap>
sl@0
   111
      static void apply(const Graph& g_in, MutableGraph& g_out, 
sl@0
   112
                        CopyVertex copy_vertex, CopyEdge copy_edge,
sl@0
   113
                        Orig2CopyVertexIndexMap orig2copy, IndexMap)
sl@0
   114
      {
sl@0
   115
        typename graph_traits<Graph>::vertex_iterator vi, vi_end;
sl@0
   116
        for (tie(vi, vi_end) = vertices(g_in); vi != vi_end; ++vi) {
sl@0
   117
          typename graph_traits<MutableGraph>::vertex_descriptor
sl@0
   118
            new_v = add_vertex(g_out);
sl@0
   119
          put(orig2copy, *vi, new_v);
sl@0
   120
          copy_vertex(*vi, new_v);
sl@0
   121
        }
sl@0
   122
        typename graph_traits<Graph>::edge_iterator ei, ei_end;
sl@0
   123
        for (tie(ei, ei_end) = edges(g_in); ei != ei_end; ++ei) {
sl@0
   124
          typename graph_traits<MutableGraph>::edge_descriptor new_e;
sl@0
   125
          bool inserted;
sl@0
   126
          tie(new_e, inserted) = add_edge(get(orig2copy, source(*ei, g_in)), 
sl@0
   127
                                          get(orig2copy, target(*ei, g_in)),
sl@0
   128
                                          g_out);
sl@0
   129
          copy_edge(*ei, new_e);
sl@0
   130
        }
sl@0
   131
      }
sl@0
   132
    };
sl@0
   133
sl@0
   134
    // for directed graphs
sl@0
   135
    template <> struct copy_graph_impl<1>
sl@0
   136
    {
sl@0
   137
      template <typename Graph, typename MutableGraph, 
sl@0
   138
        typename CopyVertex, typename CopyEdge, typename IndexMap,
sl@0
   139
        typename Orig2CopyVertexIndexMap>
sl@0
   140
      static void apply(const Graph& g_in, MutableGraph& g_out, 
sl@0
   141
                        CopyVertex copy_vertex, CopyEdge copy_edge,
sl@0
   142
                        Orig2CopyVertexIndexMap orig2copy, IndexMap)
sl@0
   143
      {
sl@0
   144
        typename graph_traits<Graph>::vertex_iterator vi, vi_end;
sl@0
   145
        for (tie(vi, vi_end) = vertices(g_in); vi != vi_end; ++vi) {
sl@0
   146
          typename graph_traits<MutableGraph>::vertex_descriptor
sl@0
   147
            new_v = add_vertex(g_out);
sl@0
   148
          put(orig2copy, *vi, new_v);
sl@0
   149
          copy_vertex(*vi, new_v);
sl@0
   150
        }
sl@0
   151
        for (tie(vi, vi_end) = vertices(g_in); vi != vi_end; ++vi) {
sl@0
   152
          typename graph_traits<Graph>::out_edge_iterator ei, ei_end;
sl@0
   153
          for (tie(ei, ei_end) = out_edges(*vi, g_in); ei != ei_end; ++ei) {
sl@0
   154
            typename graph_traits<MutableGraph>::edge_descriptor new_e;
sl@0
   155
            bool inserted;
sl@0
   156
            tie(new_e, inserted) = add_edge(get(orig2copy, source(*ei, g_in)), 
sl@0
   157
                                            get(orig2copy, target(*ei, g_in)),
sl@0
   158
                                            g_out);
sl@0
   159
            copy_edge(*ei, new_e);
sl@0
   160
          }
sl@0
   161
        }
sl@0
   162
      }
sl@0
   163
    };
sl@0
   164
sl@0
   165
    // for undirected graphs
sl@0
   166
    template <> struct copy_graph_impl<2>
sl@0
   167
    {
sl@0
   168
      template <typename Graph, typename MutableGraph, 
sl@0
   169
        typename CopyVertex, typename CopyEdge, typename IndexMap,
sl@0
   170
        typename Orig2CopyVertexIndexMap>
sl@0
   171
      static void apply(const Graph& g_in, MutableGraph& g_out, 
sl@0
   172
                        CopyVertex copy_vertex, CopyEdge copy_edge,
sl@0
   173
                        Orig2CopyVertexIndexMap orig2copy,
sl@0
   174
                        IndexMap index_map)
sl@0
   175
      {
sl@0
   176
        typedef color_traits<default_color_type> Color;
sl@0
   177
        std::vector<default_color_type> 
sl@0
   178
          color(num_vertices(g_in), Color::white());
sl@0
   179
        typename graph_traits<Graph>::vertex_iterator vi, vi_end;
sl@0
   180
        for (tie(vi, vi_end) = vertices(g_in); vi != vi_end; ++vi) {
sl@0
   181
          typename graph_traits<MutableGraph>::vertex_descriptor
sl@0
   182
            new_v = add_vertex(g_out);
sl@0
   183
          put(orig2copy, *vi, new_v);
sl@0
   184
          copy_vertex(*vi, new_v);
sl@0
   185
        }
sl@0
   186
        for (tie(vi, vi_end) = vertices(g_in); vi != vi_end; ++vi) {
sl@0
   187
          typename graph_traits<Graph>::out_edge_iterator ei, ei_end;
sl@0
   188
          for (tie(ei, ei_end) = out_edges(*vi, g_in); ei != ei_end; ++ei) {
sl@0
   189
            typename graph_traits<MutableGraph>::edge_descriptor new_e;
sl@0
   190
            bool inserted;
sl@0
   191
            if (color[get(index_map, target(*ei, g_in))] == Color::white()) {
sl@0
   192
              tie(new_e, inserted) = add_edge(get(orig2copy, source(*ei,g_in)),
sl@0
   193
                                              get(orig2copy, target(*ei,g_in)),
sl@0
   194
                                              g_out);
sl@0
   195
              copy_edge(*ei, new_e);
sl@0
   196
            }
sl@0
   197
          }
sl@0
   198
          color[get(index_map, *vi)] = Color::black();
sl@0
   199
        }
sl@0
   200
      }
sl@0
   201
    };
sl@0
   202
sl@0
   203
    template <class Graph>
sl@0
   204
    struct choose_graph_copy {
sl@0
   205
      typedef typename Graph::traversal_category Trv;
sl@0
   206
      typedef typename Graph::directed_category Dr;
sl@0
   207
      enum { algo = 
sl@0
   208
             (is_convertible<Trv, vertex_list_graph_tag>::value
sl@0
   209
              && is_convertible<Trv, edge_list_graph_tag>::value)
sl@0
   210
             ? 0 : is_convertible<Dr, directed_tag>::value ? 1 : 2 };
sl@0
   211
      typedef copy_graph_impl<algo> type;
sl@0
   212
    };
sl@0
   213
sl@0
   214
    //-------------------------------------------------------------------------
sl@0
   215
    struct choose_copier_parameter {
sl@0
   216
      template <class P, class G1, class G2>
sl@0
   217
      struct bind_ {
sl@0
   218
        typedef const P& result_type;
sl@0
   219
        static result_type apply(const P& p, const G1&, G2&)
sl@0
   220
        { return p; }
sl@0
   221
      };
sl@0
   222
    };
sl@0
   223
    struct choose_default_edge_copier {
sl@0
   224
      template <class P, class G1, class G2>
sl@0
   225
      struct bind_ {
sl@0
   226
        typedef edge_copier<G1, G2> result_type;
sl@0
   227
        static result_type apply(const P&, const G1& g1, G2& g2) { 
sl@0
   228
          return result_type(g1, g2);
sl@0
   229
        }
sl@0
   230
      };
sl@0
   231
    };
sl@0
   232
    template <class Param>
sl@0
   233
    struct choose_edge_copy {
sl@0
   234
      typedef choose_copier_parameter type;
sl@0
   235
    };
sl@0
   236
    template <>
sl@0
   237
    struct choose_edge_copy<detail::error_property_not_found> {
sl@0
   238
      typedef choose_default_edge_copier type;
sl@0
   239
    };
sl@0
   240
    template <class Param, class G1, class G2>
sl@0
   241
    struct choose_edge_copier_helper {
sl@0
   242
      typedef typename choose_edge_copy<Param>::type Selector;
sl@0
   243
      typedef typename Selector:: template bind_<Param, G1, G2> Bind;
sl@0
   244
      typedef Bind type;
sl@0
   245
      typedef typename Bind::result_type result_type;
sl@0
   246
    };
sl@0
   247
    template <typename Param, typename G1, typename G2>
sl@0
   248
    typename detail::choose_edge_copier_helper<Param,G1,G2>::result_type
sl@0
   249
    choose_edge_copier(const Param& params, const G1& g_in, G2& g_out)
sl@0
   250
    {
sl@0
   251
      typedef typename 
sl@0
   252
        detail::choose_edge_copier_helper<Param,G1,G2>::type Choice;
sl@0
   253
      return Choice::apply(params, g_in, g_out);
sl@0
   254
    }
sl@0
   255
sl@0
   256
sl@0
   257
    struct choose_default_vertex_copier {
sl@0
   258
      template <class P, class G1, class G2>
sl@0
   259
      struct bind_ {
sl@0
   260
        typedef vertex_copier<G1, G2> result_type;
sl@0
   261
        static result_type apply(const P&, const G1& g1, G2& g2) { 
sl@0
   262
          return result_type(g1, g2);
sl@0
   263
        }
sl@0
   264
      };
sl@0
   265
    };
sl@0
   266
    template <class Param>
sl@0
   267
    struct choose_vertex_copy {
sl@0
   268
      typedef choose_copier_parameter type;
sl@0
   269
    };
sl@0
   270
    template <>
sl@0
   271
    struct choose_vertex_copy<detail::error_property_not_found> {
sl@0
   272
      typedef choose_default_vertex_copier type;
sl@0
   273
    };
sl@0
   274
    template <class Param, class G1, class G2>
sl@0
   275
    struct choose_vertex_copier_helper {
sl@0
   276
      typedef typename choose_vertex_copy<Param>::type Selector;
sl@0
   277
      typedef typename Selector:: template bind_<Param, G1, G2> Bind;
sl@0
   278
      typedef Bind type;
sl@0
   279
      typedef typename Bind::result_type result_type;
sl@0
   280
    };
sl@0
   281
    template <typename Param, typename G1, typename G2>
sl@0
   282
    typename detail::choose_vertex_copier_helper<Param,G1,G2>::result_type
sl@0
   283
    choose_vertex_copier(const Param& params, const G1& g_in, G2& g_out)
sl@0
   284
    {
sl@0
   285
      typedef typename 
sl@0
   286
        detail::choose_vertex_copier_helper<Param,G1,G2>::type Choice;
sl@0
   287
      return Choice::apply(params, g_in, g_out);
sl@0
   288
    }
sl@0
   289
sl@0
   290
  } // namespace detail
sl@0
   291
sl@0
   292
sl@0
   293
  template <typename VertexListGraph, typename MutableGraph>
sl@0
   294
  void copy_graph(const VertexListGraph& g_in, MutableGraph& g_out)
sl@0
   295
  {
sl@0
   296
    if (num_vertices(g_in) == 0)
sl@0
   297
      return;
sl@0
   298
    typedef typename graph_traits<MutableGraph>::vertex_descriptor vertex_t;
sl@0
   299
    std::vector<vertex_t> orig2copy(num_vertices(g_in));
sl@0
   300
    typedef typename detail::choose_graph_copy<VertexListGraph>::type 
sl@0
   301
      copy_impl;
sl@0
   302
    copy_impl::apply
sl@0
   303
      (g_in, g_out, 
sl@0
   304
       detail::make_vertex_copier(g_in, g_out), 
sl@0
   305
       detail::make_edge_copier(g_in, g_out), 
sl@0
   306
       make_iterator_property_map(orig2copy.begin(), 
sl@0
   307
                                  get(vertex_index, g_in), orig2copy[0]),
sl@0
   308
       get(vertex_index, g_in)
sl@0
   309
       );
sl@0
   310
  }
sl@0
   311
sl@0
   312
  template <typename VertexListGraph, typename MutableGraph, 
sl@0
   313
    class P, class T, class R>
sl@0
   314
  void copy_graph(const VertexListGraph& g_in, MutableGraph& g_out, 
sl@0
   315
                  const bgl_named_params<P, T, R>& params)
sl@0
   316
  {
sl@0
   317
    typename std::vector<T>::size_type n;
sl@0
   318
      n = is_default_param(get_param(params, orig_to_copy_t()))
sl@0
   319
        ? num_vertices(g_in) : 1;
sl@0
   320
    if (n == 0)
sl@0
   321
      return;
sl@0
   322
    std::vector<BOOST_DEDUCED_TYPENAME graph_traits<MutableGraph>::vertex_descriptor> 
sl@0
   323
      orig2copy(n);
sl@0
   324
sl@0
   325
    typedef typename detail::choose_graph_copy<VertexListGraph>::type 
sl@0
   326
      copy_impl;
sl@0
   327
    copy_impl::apply
sl@0
   328
      (g_in, g_out,
sl@0
   329
       detail::choose_vertex_copier(get_param(params, vertex_copy_t()), 
sl@0
   330
                                    g_in, g_out),
sl@0
   331
       detail::choose_edge_copier(get_param(params, edge_copy_t()), 
sl@0
   332
                                  g_in, g_out),
sl@0
   333
       choose_param(get_param(params, orig_to_copy_t()),
sl@0
   334
                    make_iterator_property_map
sl@0
   335
                    (orig2copy.begin(), 
sl@0
   336
                     choose_const_pmap(get_param(params, vertex_index), 
sl@0
   337
                                 g_in, vertex_index), orig2copy[0])),
sl@0
   338
       choose_const_pmap(get_param(params, vertex_index), g_in, vertex_index)
sl@0
   339
       );
sl@0
   340
  }
sl@0
   341
sl@0
   342
  namespace detail {
sl@0
   343
    
sl@0
   344
    template <class NewGraph, class Copy2OrigIndexMap, 
sl@0
   345
      class CopyVertex, class CopyEdge>
sl@0
   346
    struct graph_copy_visitor : public bfs_visitor<>
sl@0
   347
    {
sl@0
   348
      graph_copy_visitor(NewGraph& graph, Copy2OrigIndexMap c,
sl@0
   349
                         CopyVertex cv, CopyEdge ce)
sl@0
   350
        : g_out(graph), orig2copy(c), copy_vertex(cv), copy_edge(ce) { }
sl@0
   351
sl@0
   352
      template <class Vertex, class Graph>
sl@0
   353
      void examine_vertex(Vertex u, const Graph& g_in) const {
sl@0
   354
        typename graph_traits<NewGraph>::vertex_descriptor
sl@0
   355
          new_u = add_vertex(g_out);
sl@0
   356
        put(orig2copy, u, new_u);
sl@0
   357
        copy_vertex(u, new_u);
sl@0
   358
      }
sl@0
   359
      
sl@0
   360
      template <class Edge, class Graph>
sl@0
   361
      void examine_edge(Edge e, const Graph& g_in) const {
sl@0
   362
        typename graph_traits<NewGraph>::edge_descriptor new_e;
sl@0
   363
        bool inserted;
sl@0
   364
        tie(new_e, inserted) = add_edge(get(orig2copy, source(e, g_in)), 
sl@0
   365
                                        get(orig2copy, target(e, g_in)),
sl@0
   366
                                        g_out);
sl@0
   367
        copy_edge(e, new_e);
sl@0
   368
      }
sl@0
   369
    private:
sl@0
   370
      NewGraph& g_out;
sl@0
   371
      Copy2OrigIndexMap orig2copy;
sl@0
   372
      CopyVertex copy_vertex;
sl@0
   373
      CopyEdge copy_edge;
sl@0
   374
    };
sl@0
   375
sl@0
   376
    template <typename Graph, typename MutableGraph, 
sl@0
   377
              typename CopyVertex, typename CopyEdge, 
sl@0
   378
              typename Orig2CopyVertexIndexMap, typename Params>
sl@0
   379
    typename graph_traits<MutableGraph>::vertex_descriptor
sl@0
   380
    copy_component_impl
sl@0
   381
      (const Graph& g_in, 
sl@0
   382
       typename graph_traits<Graph>::vertex_descriptor src,
sl@0
   383
       MutableGraph& g_out, 
sl@0
   384
       CopyVertex copy_vertex, CopyEdge copy_edge,
sl@0
   385
       Orig2CopyVertexIndexMap orig2copy,
sl@0
   386
       const Params& params)
sl@0
   387
    {
sl@0
   388
      graph_copy_visitor<MutableGraph, Orig2CopyVertexIndexMap, 
sl@0
   389
        CopyVertex, CopyEdge> vis(g_out, orig2copy, copy_vertex, copy_edge);
sl@0
   390
      breadth_first_search(g_in, src, params.visitor(vis));
sl@0
   391
      return get(orig2copy, src);
sl@0
   392
    }
sl@0
   393
sl@0
   394
  } // namespace detail
sl@0
   395
  
sl@0
   396
  
sl@0
   397
  // Copy all the vertices and edges of graph g_in that are reachable
sl@0
   398
  // from the source vertex into graph g_out. Return the vertex
sl@0
   399
  // in g_out that matches the source vertex of g_in.
sl@0
   400
  template <typename IncidenceGraph, typename MutableGraph, 
sl@0
   401
           typename P, typename T, typename R>
sl@0
   402
  typename graph_traits<MutableGraph>::vertex_descriptor
sl@0
   403
  copy_component(IncidenceGraph& g_in, 
sl@0
   404
                 typename graph_traits<IncidenceGraph>::vertex_descriptor src,
sl@0
   405
                 MutableGraph& g_out, 
sl@0
   406
                 const bgl_named_params<P, T, R>& params)
sl@0
   407
  {
sl@0
   408
    typename std::vector<T>::size_type n;
sl@0
   409
      n = is_default_param(get_param(params, orig_to_copy_t()))
sl@0
   410
        ? num_vertices(g_in) : 1;
sl@0
   411
    std::vector<typename graph_traits<IncidenceGraph>::vertex_descriptor> 
sl@0
   412
      orig2copy(n);
sl@0
   413
    
sl@0
   414
    return detail::copy_component_impl
sl@0
   415
      (g_in, src, g_out,
sl@0
   416
       detail::choose_vertex_copier(get_param(params, vertex_copy_t()), 
sl@0
   417
                                    g_in, g_out),
sl@0
   418
       detail::choose_edge_copier(get_param(params, edge_copy_t()), 
sl@0
   419
                                  g_in, g_out),
sl@0
   420
       choose_param(get_param(params, orig_to_copy_t()),
sl@0
   421
                    make_iterator_property_map
sl@0
   422
                    (orig2copy.begin(), 
sl@0
   423
                     choose_pmap(get_param(params, vertex_index), 
sl@0
   424
                                 g_in, vertex_index), orig2copy[0])),
sl@0
   425
       params
sl@0
   426
       );
sl@0
   427
  }
sl@0
   428
sl@0
   429
  template <typename IncidenceGraph, typename MutableGraph>
sl@0
   430
  typename graph_traits<MutableGraph>::vertex_descriptor
sl@0
   431
  copy_component(IncidenceGraph& g_in, 
sl@0
   432
                 typename graph_traits<IncidenceGraph>::vertex_descriptor src,
sl@0
   433
                 MutableGraph& g_out)
sl@0
   434
  {
sl@0
   435
    std::vector<typename graph_traits<IncidenceGraph>::vertex_descriptor> 
sl@0
   436
      orig2copy(num_vertices(g_in));
sl@0
   437
    
sl@0
   438
    return detail::copy_component_impl
sl@0
   439
      (g_in, src, g_out,
sl@0
   440
       make_vertex_copier(g_in, g_out), 
sl@0
   441
       make_edge_copier(g_in, g_out), 
sl@0
   442
       make_iterator_property_map(orig2copy.begin(), 
sl@0
   443
                                  get(vertex_index, g_in), orig2copy[0]),
sl@0
   444
       bgl_named_params<char,char>('x') // dummy param object
sl@0
   445
       );
sl@0
   446
  }
sl@0
   447
sl@0
   448
} // namespace boost
sl@0
   449
sl@0
   450
#endif // BOOST_GRAPH_COPY_HPP