문제

I am trying to change the node color using the following code but getting Segmentation fault.

I am using the latest OGDF snapshot.

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

node left = G.newNode();
GA.strokeColor (left) = Color("red"); 
도움이 되었습니까?

해결책

The attribute GraphAttributes::nodeGraphics only enables coordinates and shapes of the node but not its color. For the stroke and fill styling, you need to enable GraphAttributes::nodeStyle in the constructor:

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

For a mapping of attributes you can use and the enum values you need to enable in the constructor (or later), see the documentation of the enumeration.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top