Connecting arcs between lines in Dot (GraphViz)

2019-08-03 01:41发布

问题:

I've got to do up a state space graph for my AI course, and I was hoping to use GraphViz to make it (so much faster than Dia). The one thing I can't seem to figure out how to do is how to do an "And" connection, which is basically an arc between two lines connecting to the same node. Is this possible?

回答1:

Yes. While there's no explicit dot syntax for this, here's the way it's nearly always done:

# just graph set-up
digraph new_graph {
ratio = "auto"
mincross = 2.0

# draw some nodes
"001" [shape=box, regular=1, style=filled, fillcolor="#FCD975"] ;
"017" [shape=circle  , regular=1,style=filled,fillcolor="#9ACEEB"   ] ;
"007" [shape=diamond  , regular=1,style=filled,fillcolor="#FCD975"   ] ;
# the key line--creating tiny node w/ no label, no color
# i use this style because it mimics the 'midpoint' style used in Omnigraffle et al.
"LN01" [shape=diamond,style=filled,label="",height=.1,width=.1] ;

# draw the edges
"001" -> "LN01" [dir=none,weight=1] ;
"007" -> "LN01" [dir=none,weight=1] ;
"LN01" -> "017" [dir=none, weight=2] ;
}

alt text http://img121.imageshack.us/img121/2547/dotgvziv.png