Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set default node shape to box instead of oval?

Tags:

graphviz

dot

I have some long labels in my graph written in dot language. As a result, (the default shape being oval) I have some not very practical thin really long oval in my graph which take much space.

I would like to set the default shape to box for all my nodes, unless specified otherwise.

I have seen the node notation, but it requires to list any node impacted by the styles.

Is it possible in dot language ?

like image 375
Stephane Rolland Avatar asked Oct 24 '14 17:10

Stephane Rolland


People also ask

What is the default point shape size of a node?

If unset, they default to 4, 0.0 and 0.0, respectively. The point shape is special in that it is only affected by the peripheries , width and height attributes. Normally, the size of a node is determined by smallest width and height needed to contain its label and image, if any, with a margin specified by the margin attribute.

What are the node attributes that affect the geometry and style?

The geometry and style of all node shapes are affected by the node attributes fixedsize , fontname , fontsize , height , label , style and width. The possible polygon-based shapes are displayed below.

How do I restrict the size of a node?

See the fixedsize attribute for ways of restricting the node size. In particular, if fixedsize=shape, the node’s shape will be fixed by the width and height attributes, and the shape is used for edge termination, but both the shape and label sizes are used preventing node overlap. For example, the following graph:

What is the difference between diagonals and nodes?

Note that the node is still used in laying out the graph. The diagonals style causes small chords to be drawn near the vertices of the node’s polygon or, in case of circles and ellipses, two chords near the top and the bottom of the shape.


2 Answers

using the node notation without listing the impacted nodes make the node shape style applied by default.

digraph ExampleGraph {     node [shape="box"];      a -> b -> c -> d; } 
like image 154
Stephane Rolland Avatar answered Sep 18 '22 13:09

Stephane Rolland


Btw, if you only need to change part of the nodes, you can use a subgraph like this:

digraph ExampleGraph {   {     // only change a and d     node [shape="box"]; a; d;   }     a -> b -> c -> d; } 
like image 34
cn123h Avatar answered Sep 21 '22 13:09

cn123h