1

I am trying to use boost::dynamic properties to multiple properties to the Graphviz output.

I am familiar with custom property writer (How to print a graph in graphviz with multiple properties displayed), but I am trying to do the same thing with dynamic properties. How do we write the above edge property writer using the dynamic properties in the following code? I want to write if else statements on the values of the weight and capacity as in if(weight <5 && capacity <5) then color = red and so on.

boost::dynamic_properties dp/*(ignore_other_properties)*/;
dp.property("node_id", get(&vert::name, g));
dp.property("color", get(??,g));
write_graphviz_dp(std::cout, g, dp);
  • Huh. What color do you want it to have? There is no mention of it in the linked answer. If anything, the trick would likely be exactly the same: `get(&edge::color, g)` (assuming that `edge` has a member named `color`) – sehe Jul 19 '19 at 08:33
  • I have edited the question to mention that part. Edge has weight and capacity as its members and I want to use these two properties to write an if-else block to assign colors in the output graph. In the linked answer, I can do that in the operator() function but how do we that using the dp.property()? – chester cheetah Jul 19 '19 at 16:37

1 Answers1

1

See some options here: map set/get requests into C++ class/structure changes

You can either transform the result of one property map, or you can use a functional property map altogether.

Transforming values:

An example of using dynamic properties to transform a color property is here: Manually colouring of boost's graphs

Functional map:

Note that you also have make_constant_property_map (e.g. Boost Dynamic Properties with Custom get property)

sehe
  • 374,641
  • 47
  • 450
  • 633