Esempio n. 1
0
  inline void
  dijkstra_shortest_paths
    (const VertexListGraph& g,
     SourceInputIter s_begin, SourceInputIter s_end,
     PredecessorMap predecessor, DistanceMap distance, WeightMap weight,
     IndexMap index_map,
     Compare compare, Combine combine, DistInf inf, DistZero zero,
     DijkstraVisitor vis, ColorMap color)
  {
    typedef typename property_traits<ColorMap>::value_type ColorValue;
    typedef color_traits<ColorValue> Color;
    typename graph_traits<VertexListGraph>::vertex_iterator ui, ui_end;
    for (boost::tie(ui, ui_end) = vertices(g); ui != ui_end; ++ui) {
      vis.initialize_vertex(*ui, g);
      put(distance, *ui, inf);
      put(predecessor, *ui, *ui);
      put(color, *ui, Color::white());
    }
    for (SourceInputIter it = s_begin; it != s_end; ++it) {
      put(distance, *it, zero);
    }

    dijkstra_shortest_paths_no_init(g, s_begin, s_end, predecessor, distance,
                            weight, index_map, compare, combine, zero, vis,
                            color);
  }
  inline void
  parallel_dijkstra_shortest_paths
    (const VertexListGraph& g,
     RootVertexMap root_vertex_map,
     PredecessorMap predecessor_map, DistanceMap distance_map,
     WeightMap weight_map, IndexMap index_map,
     Compare compare, Combine combine, DistInf inf, DistZero zero,
     DijkstraVisitor vis, ColorMap color_map)
  {
    using boost::vertices;
    // TODO VertexList and IncidentGraph CenceptCheck
    typedef
      typename boost::property_traits<RootVertexMap>::value_type
      RootVertex;
    typedef
      typename boost::graph_traits<VertexListGraph>::vertex_descriptor
      Vertex;
    boost::function_requires< boost::Convertible<RootVertex, Vertex> >();

    typedef typename boost::property_traits<ColorMap>::value_type ColorValue;
    typedef boost::color_traits<ColorValue> Color;
    typename boost::graph_traits<VertexListGraph>::vertex_iterator vi, vi_end;
    for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) {
      vis.initialize_vertex(*vi, g);
      if (get(root_vertex_map, *vi) != false) {
        put(distance_map, *vi, zero);
      }
      else {
        put(distance_map, *vi, inf);
      }
      put(predecessor_map, *vi, *vi);
      put(color_map, *vi, Color::white());
    }

    parallel_dijkstra_shortest_paths_no_init
      (g, root_vertex_map, predecessor_map, distance_map,
       weight_map, index_map, compare, combine, zero, vis, color_map);
  }