Create boost :: graph edge_weight property map

using boost :: graph with related properties. I want to be able to run a search using various possible border weighting schemes. I would like not to create an additional class for related properties, if possible, and to transfer different weight maps depending on the type of search without creating a new graph or changing all existing properties on the graph.

Is it possible to manually create property_map for edge_weight_t? Here is what I have so far:

typedef boost::property_map<SSPSGraph_t, boost::edge_weight_t>::type WeightMap;
typedef boost::property<boost::edge_weight_t, float> DistanceProperty;

And I would just do

WeightMap distances;
edge_descriptor_t e = some_edge_or_another;
float d=some_derived_distance_value;

And assign the distances [e] to the appropriate values ​​-

distances[e]= ?

Or do I just need to break down and create a new structure for the related properties - which I tried to avoid - and create a weight map? New for boost :: graph; not assuming that I am not doing anything stupid here.

+3
1

, . , :

boost:: property_map, WeightMap, , ( , DistanceProperty):

typedef boost::property<boost::edge_weight_t, float> DistanceProperty;

typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::undirS, boost::no_property, DistanceProperty> MyGraph;

, boost:: property_map .

, , .  - std:: map boost:: associative_property ( , )  - boost:: vector_property_map, ( std::vector), property_map, _map, ( 0 num_edges() - 1) . _map .

( ), , , !

+2

Source: https://habr.com/ru/post/1705882/


All Articles