Boost logo

Boost Users :

Subject: Re: [Boost-users] [Graph] initialize_vertex change vertex color (visitor)
From: The Maschine (justthemaschine_at_[hidden])
Date: 2014-01-21 06:06:31


Thanks Alex,

Yes the m_distance in the visitor is the result of a previous search (not
the current working one).

A couple of questions.
If I use my own colour map as you describe, Could I also colour it
beforehand and not in the visitor? (the ones that are outside the cutoff
will always be outside, this will not change during search)
>From your link seem that I am in the same category of 'no_init' search so
the colour map that I provide is used directly and its not 're-initialised'.

What Im trying to achieve is to colour some vertices black so that the
search will consider them "disconnected" and leave them with 'inf' distance.
This also means that these vertices won't be part of any later computation
inside the visitor, no relaxation etc (as an extension of what I have here:
in a 'special brandes betweenness' visitor I could, theoretically at the
moment, exclude them for the extra 'delta' calculations inside the visitor
steps).
Right? If Im missing something please let me know.

Now the code. Im having treble building the correct 'no_init' call.
Googling around helped but not much.
Any ideas? Thanks

            std::vector<Vertex> predecessors(boost::num_vertices(m_ugraph));
            std::vector<Weight> distances(boost::num_vertices(m_ugraph),
std::numeric_limits<double>::max() );
            IndexMap indexMap = boost::get(boost::vertex_index, m_ugraph);
            PredecessorMap predecessorMap(&predecessors[0], indexMap);
            DistanceMap distanceMap(&distances[0], indexMap);

// What is the definition of the ColorMap if you use it outside a visitor?
            typedef typename boost::property_traits<ColorMap>::value_type
color_type;
            typedef typename boost::color_traits<color_type> color_traits;

            std::vector<boost::default_color_type>
colors(boost::num_vertices(m_ugraph));
            boost::default_bfs_visitor vis;

            boost::graph_traits<unGraph>::vertex_iterator vertex_begin,
vertex_end;
            for ( boost::tie(vertex_begin, vertex_end) =
vertices(m_ugraph); vertex_begin != vertex_end; ++vertex_begin)
            {
// color_traits::black() complains because of the problem above.
                if(old_distances[*vertex_begin] > radius1)
boost::put(colors, *vertex_begin, color_traits::black());
            }

            // My current call
            //boost::dijkstra_shortest_paths(m_ugraph, s_vertex,
boost::weight_map(boost::get(&EdgeProperties::m_metric_distance_weight,
m_ugraph)).predecessor_map(predecessorMap).distance_map(distanceMap));

// this is probably a mess! Im not at all sure
            dijkstra_shortest_paths_no_init(m_ugraph, s_vertex,
predecessorMap, distanceMap,
boost::weight_map(boost::get(&EdgeProperties::m_metric_distance_weight,
m_ugraph)) , indexMap, std::less<Weight> , boost::closed_plus<Weight>,
Weight(), vis, colors);



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net