How to control node placement in graphviz (i.e. avoid edge crossings)
You could create an invisible constraint, to cause the red node to appear to the left of all other nodes. redNode -> leftmostNode [style=invis]; Before: After:
You could create an invisible constraint, to cause the red node to appear to the left of all other nodes. redNode -> leftmostNode [style=invis]; Before: After:
Putting the rank = same; … statements in braces, e.g.: digraph G { rankdir = TB; subgraph { A -> B A -> C C -> D X -> Y // note that rank is used in the subgraph {rank = same; A; X;} {rank = same; B; D; Y;} } /* closing subgraph */ … Read more
This works for me as documented: digraph { n[label=”two\nlines”] “on\nthree\nlines” } Either put in in a label attribute (my preference), or use it as the node’s name, but always enclose it with double quotes.
Use the dpi attribute. Example: graph G { graph [ dpi = 300 ]; /* The rest of your graph here. */ }
You can use pos attribute (https://www.graphviz.org/doc/info/attrs.html#d:pos), e.g.: xxx [ label = xxx pos = “0,0!” ] yyy [ label = yyy pos = “10,10!” ] You will also have to specify neato or fdp layout engine, so that dot command-line would be (for fdp): dot -Kfdp -n -Tpng -o sample.png sample.dot
To place captions outside the node, you may use xlabel: digraph g { forcelabels=true; a [label=”Birth of George Washington”, xlabel=”See also: American Revolution”]; b [label=”Main label”, xlabel=”Additional caption”]; a-> b; } forcelabels=true makes sure no xlabel is omitted. A second option is to use HTML-like labels: digraph g { a[label=<Birth of George Washington<BR /> <FONT … Read more
it’s very easy, as long as you stick to basic layout: place rankdir=”LR” near top definition. Something like digraph unix { size=”6,6″; rankdir=”LR”; … }
You’ll have to prefix the name of your subgraphs with cluster: subgraph clusterstep1 { and subgraph clusterstep2 { in order to get the style and label. From the graphiz documentation, section “Subgraphs and Clusters”: The third role for subgraphs directly involves how the graph will be laid out by certain layout engines. If the name … Read more
I wanted to supplement shuvalov’s answer. penwidth is indeed the correct command. Additionally, in shuvalov’s answer penwidth is both a node and an edge property–also correct. The distinction i wanted to make: penwidth, when used as a node property (e.g., “NodeA” [penwidth = 5]) affects the border line weight for that node penwidth, when used … Read more
You use the label property attached to the edge. digraph G { a -> b [ label=”a to b” ]; b -> c [ label=”another label”]; } The above generates a graph that looks something like this.