开发者

How can I get bended edges in a TikZ graph?

开发者 https://www.devze.com 2023-01-24 01:14 出处:网络
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 edg

I'm using TikZ to show Prim's algorithm, like in this example on texample.net.

How can I get bended edges in a TikZ graph?

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 ;)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号