示例#1
0
    inline void
    dag_sp_dispatch1
      (const VertexListGraph& g,
       typename graph_traits<VertexListGraph>::vertex_descriptor s, 
       DistanceMap distance, WeightMap weight, ColorMap color, IndexMap id,
       DijkstraVisitor vis, const Params& params)
    {
      typedef typename property_traits<WeightMap>::value_type T;
      typename std::vector<T>::size_type n;
      n = is_default_param(distance) ? num_vertices(g) : 1;
      std::vector<T> distance_map(n);
      n = is_default_param(color) ? num_vertices(g) : 1;
      std::vector<default_color_type> color_map(n);

      dag_sp_dispatch2
        (g, s, 
         choose_param(distance, 
                      make_iterator_property_map(distance_map.begin(), id,
                                                 distance_map[0])),
         weight, 
         choose_param(color,
                      make_iterator_property_map(color_map.begin(), id, 
                                                 color_map[0])),
         id, vis, params);
    }
 inline OutputIterator
 kruskal_minimum_spanning_tree(const Graph& g,
                               OutputIterator spanning_tree_edges, 
                               const bgl_named_params<P, T, R>& params)
 {
   typedef typename graph_traits<Graph>::vertices_size_type size_type;
   typedef typename graph_traits<Graph>::vertex_descriptor vertex_t;
   if (num_vertices(g) == 0) return spanning_tree_edges; // Nothing to do in this case
   typename graph_traits<Graph>::vertices_size_type n;
   n = is_default_param(get_param(params, vertex_rank))
                                  ? num_vertices(g) : 1;
   std::vector<size_type> rank_map(n);
   n = is_default_param(get_param(params, vertex_predecessor))
                                  ? num_vertices(g) : 1;
   std::vector<vertex_t> pred_map(n);
   
   return detail::kruskal_mst_impl
     (g, spanning_tree_edges, 
      choose_param
      (get_param(params, vertex_rank), 
       make_iterator_property_map
       (rank_map.begin(), 
        choose_pmap(get_param(params, vertex_index), g, vertex_index), rank_map[0])),
      choose_param
      (get_param(params, vertex_predecessor), 
       make_iterator_property_map
       (pred_map.begin(), 
        choose_const_pmap(get_param(params, vertex_index), g, vertex_index), 
        pred_map[0])),
      choose_const_pmap(get_param(params, edge_weight), g, edge_weight));
 }
 static typename edge_capacity_value<Graph, P, T, R>::type
 apply
 (Graph& g,
  typename graph_traits<Graph>::vertex_descriptor src,
  typename graph_traits<Graph>::vertex_descriptor sink,
  PredMap pred,
  const bgl_named_params<P, T, R>& params,
  detail::error_property_not_found)
 {
   typedef typename graph_traits<Graph>::edge_descriptor edge_descriptor;
   typedef typename graph_traits<Graph>::vertices_size_type size_type;
   size_type n = is_default_param(get_param(params, vertex_color)) ?
     num_vertices(g) : 1;
   std::vector<default_color_type> color_vec(n);
   return edmunds_karp_max_flow
     (g, src, sink, 
      choose_const_pmap(get_param(params, edge_capacity), g, edge_capacity),
      choose_pmap(get_param(params, edge_residual_capacity), 
                  g, edge_residual_capacity),
      choose_const_pmap(get_param(params, edge_reverse), g, edge_reverse),
      make_iterator_property_map(color_vec.begin(), choose_const_pmap
                                 (get_param(params, vertex_index),
                                  g, vertex_index), color_vec[0]),
      pred);
 }
示例#4
0
    void transitive_closure_dispatch
      (const Graph & g, GraphTC & tc,
       G_to_TC_VertexMap g_to_tc_map, VertexIndexMap index_map)
    {
      typedef typename graph_traits < GraphTC >::vertex_descriptor tc_vertex;
      typename std::vector < tc_vertex >::size_type
        n = is_default_param(g_to_tc_map) ? num_vertices(g) : 1;
      std::vector < tc_vertex > to_tc_vec(n);

      transitive_closure
        (g, tc,
         choose_param(g_to_tc_map, make_iterator_property_map
                      (to_tc_vec.begin(), index_map, to_tc_vec[0])),
         index_map);
    }
    inline void
    dijkstra_dispatch1
      (const VertexListGraph& g,
       typename graph_traits<VertexListGraph>::vertex_descriptor s, 
       DistanceMap distance, WeightMap weight, IndexMap index_map,
       const Params& params)
    {
      // Default for distance map
      typedef typename property_traits<WeightMap>::value_type D;
      typename std::vector<D>::size_type 
        n = is_default_param(distance) ? num_vertices(g) : 1;
      std::vector<D> distance_map(n);

      detail::dijkstra_dispatch2
        (g, s, choose_param(distance, make_iterator_property_map
                            (distance_map.begin(), index_map, 
                             distance_map[0])),
         weight, index_map, params);
    }
 static typename edge_capacity_value<Graph, P, T, R>::type
 apply
 (Graph& g,
  typename graph_traits<Graph>::vertex_descriptor src,
  typename graph_traits<Graph>::vertex_descriptor sink,
  const bgl_named_params<P, T, R>& params,
  detail::error_property_not_found)
 {
   typedef typename graph_traits<Graph>::edge_descriptor edge_descriptor;
   typedef typename graph_traits<Graph>::vertices_size_type size_type;
   size_type n = is_default_param(get_param(params, vertex_predecessor)) ?
     num_vertices(g) : 1;
   std::vector<edge_descriptor> pred_vec(n);
   
   typedef typename property_value< bgl_named_params<P,T,R>, vertex_color_t>::type C;
   return edmunds_karp_dispatch2<C>::apply
     (g, src, sink, 
      make_iterator_property_map(pred_vec.begin(), choose_const_pmap
                                 (get_param(params, vertex_index),
                                  g, vertex_index), pred_vec[0]),
      params, 
      get_param(params, vertex_color));
 }