Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
281 views
in Technique[技术] by (71.8m points)

dot - Graphviz, changing the size of edge

How to change the size of edge in dot (graphviz)? I would like to make some edges "bolded".

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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 as a edge property affects the line weight of the edge (default value is "1", specifying penwidth=2 will make the edge appear in bold type

  • if you want to change the line weight of an edge, you do not need to change penwidth for the two nodes connected by that edge (as shuvalev's answer might suggest)

  • for a directed graph (the edges have a direction) you might also wish to change the size/weight of the arrowhead and arrowtail, along with the edge weight, so that all three remain proportional

  • the length of an edge can be changed by setting the weight property, as elsewhere, the default value is 1.0; increasing that value increases the cost of stretching this edge during rendering (i.e., the drawing algorithm applies a higher penalty to solutions in which this edge is longer); notice that the edge from 1 to 4 is shorter than the edge from 1 to 2.

The following code should illustrate all of this. The rendered graph is shown below the code.

digraph {
    /* declare the node & style them */
    "Node 1" [shape=diamond, penwidth=3, style=filled, fillcolor="#FCD975"];
    "Node 2" [style=filled,fillcolor="#9ACEEB" ];
    "Node 3" [shape=diamond, style=filled, fillcolor="#FCD975" ];
    "Node 4" [style=filled, fillcolor="#9ACEEB" ]

    /* declare the edges & style them */
    "Node 1" -> "Node 2" [dir=none, weight=1, penwidth=3] ;
    "Node 1" -> "Node 3" [dir=none, color="#9ACEEB"] ;
    "Node 1" -> "Node 4" [arrowsize=.5, weight=2.]
}

enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.9k users

...