【问题标题】:Changing node color OGDF Library更改节点颜色 OGDF 库
【发布时间】:2013-09-24 18:59:51
【问题描述】:

我正在尝试使用以下代码更改节点颜色,但出现分段错误。

我正在使用最新的 OGDF 快照。

Graph G;
GraphAttributes GA(G, GraphAttributes::nodeGraphics |   
         GraphAttributes::edgeGraphics );

node left = G.newNode();
GA.strokeColor (left) = Color("red"); 

【问题讨论】:

    标签: c++ ogdf


    【解决方案1】:

    属性GraphAttributes::nodeGraphics 仅启用节点的坐标和形状,但不启用其颜色。对于描边和填充样式,您需要在构造函数中启用GraphAttributes::nodeStyle

    Graph G;
    GraphAttributes GA(G,
            GraphAttributes::nodeGraphics |   
            GraphAttributes::nodeStyle |      // <-- Enables node stroke and filling
            GraphAttributes::edgeGraphics );
    
    node left = G.newNode();
    GA.strokeColor(left) = Color("red"); 
    

    有关您可以使用的属性映射以及您需要在构造函数(或更高版本)中启用的枚举值,请参阅documentation of the enumeration

    【讨论】:

      猜你喜欢
      • 2023-03-12
      • 2012-11-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多