LaTeX - 在加权图的排序边列表上方添加节点标签
这看起来相当简单,但我无法在网上找到有关如何执行此操作的任何信息。我正在编写克鲁斯卡尔算法的步骤。我需要创建一个按权重排序的边列表,权重上方的标签引用边,如下所示:
a-b b-c c-e
1 3 5 ...
Anany Levitin 的算法设计与分析 在第 4 页上使用了类似的格式。 316. 如果没有其他选择,我想逐字记录可能会起作用,尽管我希望让它看起来更好一点。有什么建议吗?
This seems like it would be fairly simple, but I've been unable to find anything about how to do this on the web. I'm writing the steps for Kruskal's algorithm. I need to create a list of edges sorted by weight, with labels above the weight referencing the edges, something like this:
a-b b-c c-e
1 3 5 ...
Design and Analysis of Algorithms by Anany Levitin uses similar formatting on p. 316. If there are no other options, I suppose verbatim might work, though I was hoping to make it look a little nicer. Any recommendations?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
正如有人建议的那样,TikZ 可能有点矫枉过正,但它确实有效。
编辑:实际上,这可能更简单并且可以实现您想要的功能:
您可以自己比较: tikzedgeweights.pdf< /a>
As someone suggested, TikZ might be overkill, but it does work.
EDIT: Actually, this is probably simpler and does what you want:
You can compare for yourself: tikzedgeweights.pdf
怎么样:
or
or or
or
(在序言中使用
\usepackage{amsmath}
)您可以在这里找到更高级的数学技巧:http://en.wikibooks.org/wiki/LaTeX/Advanced_Mathematics
What about something like:
or
or
or
(with
\usepackage{amsmath}
in your preamble)You can find more advanced math techniques here: http://en.wikibooks.org/wiki/LaTeX/Advanced_Mathematics
为了获得更多技巧和更好的外观,
我在这里为您提供了两种外观不同的可能性 - 选择您更喜欢的。
通过将 Steve 的代码修改为,无需
amsmath
即可实现相同的效果For a bit more finesse and better looks use
I gave you two different-looking possibilities here -- pick what you like more.
You can achieve the same effect without
amsmath
by modifying Steve's code totikz 可能是您最好的选择,尽管它对于您所追求的东西来说有点重量级。也许 xypic 会提供更好的解决方案,而且不像 tikz 那样密集。我不确定你想要的东西是什么样子,但这会很接近吗:
或者类似的东西?
tikz is probably your best bet, though it is a little heavyweight for what you're after. Perhaps xypic would offer a better solution, and one that isn't quite as intensive as tikz. I'm not sure what you want the thing to look like, but would this be close:
Or something like that?