0

I need to plot a DOT graph as SVG/PDF but would like to include the node attributes for each node. For example, on the plot:

strict digraph G {

  start -> a0;
  a0 -> a3;
  j0[name=asd, weight=2];
  a3 -> j0;
  j0 -> end;
}

how to include name and weight values under j0, like (e.g.):

strict digraph G {

  start -> a0;
  a0 -> a3;
  a3 -> "j0\nname=asd\nweight=2";
  "j0\nname=asd\nweight=2" -> end;
}
2
  • 1
    Both your graphs are valid Graphviz. Not clear what you are looking for different from the second graph. Commented Aug 23, 2023 at 13:18
  • I'd like to plot something like the second graph (with all the node attribs showed) but from the first, where the attibs are just specified normally (instead of in the node name with is a bit cumbersome and error-prone). Commented Aug 25, 2023 at 6:56

1 Answer 1

1

Insert all the node attributes and values into the label attribute (https://graphviz.org/docs/attrs/label/), instead of the node name.

strict digraph G {

  start -> a0;
  a0 -> a3;
  a3 -> j0
  j0 [label="j0\nname=asd\nweight=2"]
  j0-> end;
}

Giving:
enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.