34

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 ?

Stephane Rolland
  • 34,892
  • 31
  • 111
  • 159

3 Answers3

58

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;
}
Stephane Rolland
  • 34,892
  • 31
  • 111
  • 159
6

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;
}
cn123h
  • 2,182
  • 1
  • 19
  • 14
4

Mind that you also can specify default node shape (or any other attribute) on the dot tool command line using -N switch, e.g.:

dot -Nshape=box graph.dot -Tpng -o graph.png
pfalcon
  • 5,907
  • 4
  • 30
  • 40