I'm using TikZ to show Prim's algorithm, like in this example on texample.net.
How can I get TikZ to create bended edges instead开发者_开发问答 of the straight ones here?
The problem with bent edges, is that it takes some knowledge of the angle that the line makes with the two nodes. When you know this you can use the in
and out
directives in the to
form of the path or draw command. Since you are doing these connections in a loop over nodes, you were hoping to ignore explicitly calculating these angles and letting TikZ take care of drawing the lines. If you need to though, those are the commands you are most likely going to need to utilize. Good luck.
You can use the bend <direction>
option to bend arrows in some arbitrary direction. Like this: \path[edge] (\source) to[bend right] node[weight] {$\weight$} (\dest);
(from your example)
There are additional options you can use to change the arc and stuff of the bend but you will have to check the manual for that ;)
精彩评论