如何获得 TikZ 图中的弯曲边?
我使用 TikZ 来展示 Prim 的算法,就像 texample 上的这个示例一样。网。
如何让 TikZ 在此处创建弯曲边缘而不是直边缘?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
弯曲边缘的问题在于,它需要了解线与两个节点所成的角度。了解这一点后,您可以在路径或绘制命令的
to
形式中使用in
和out
指令。由于您是在节点上的循环中进行这些连接,因此您希望忽略显式计算这些角度并让 TikZ 负责绘制线条。如果您需要,这些是您最有可能需要使用的命令。祝你好运。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
andout
directives in theto
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.您可以使用
bend
选项将箭头向任意方向弯曲。像这样:\path[edge] (\source) to[bend right] node[weight] {$\weight$} (\dest);
(来自您的示例)还有其他选项可以用于更改弯曲的弧度和材料,但您必须检查手册;)
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 ;)