简体   繁体   English

使用自定义获取属性提升动态属性

[英]Boost Dynamic Properties with Custom get property

I am trying to use boost::dynamic properties to multiple properties to the Graphviz output.我正在尝试将 boost::dynamic 属性用于 Graphviz 输出的多个属性。

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.我熟悉自定义属性编写器( 如何在显示多个属性的 graphviz 中打印图形),但我正在尝试对动态属性执行相同的操作。 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.我想在重量和容量的值上编写 if else 语句,如 if(weight <5 && capacity <5) then color = red 等等。

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);

See some options here: map set/get requests into C++ class/structure changes在此处查看一些选项: 将设置/获取请求映射到 C++ 类/结构更改

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使用动态属性转换颜色属性的示例如下: Manually coloring of boost's graphs

Functional map:功能图:

Note that you also have make_constant_property_map (eg Boost Dynamic Properties with Custom get property )请注意,您还有make_constant_property_map (例如, 使用自定义获取属性提升动态属性

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM