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.