生成图表的图片/图形
在研究跨网络的最短路径算法时,我想生成网络的图片。 我想表示节点(圆)、链接(线)、遍历链接的成本(链接线中间的数字)和链接的容量(链接线上其代表的节点旁边的数字)图片中。 是否有任何库/软件可以帮助自动创建这张图片?
我可以在 Visio 中或使用某些绘图应用程序手动执行此操作,但我想在更改/调整网络时从代码生成它们。
In working on a shortest path algorithm across a network I would like to generate a picture of the network. I'd like to represent nodes (circles), links (lines), cost to traverse the link (number in the middle of the link line), and capacity of the link (number on the link line next to the node it represents) in the picture. Is there any library/software out there that would help to automate creating this picture?
I can do this manually in Visio or with some drawing application but I'd like to generate them from code as I change/tweak the network.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
听起来像是 GraphViz 的工作,它从简短的文本描述文件生成图表。 我已经用它来生成连接的节点图,并且我相信应该可以根据需要添加链接标签。
Sounds like a job for GraphViz , it generates graphs from a short text description file. I've used it to produce connected node graphs and I believe it should be possible to add link labels, as you require.
如果您使用 python,Nodebox 会绘制漂亮的图表。
If you're using python, Nodebox draws pretty graphs.
显示此类网络的一大问题是确定将节点放置在显示屏上的位置。 如果给定您的网络,安排节点在逻辑上很简单,那么现成的产品可能会满足您的需求。
如果安排要复杂得多,您可能必须接受一定量的手动干预才能使其与现成的东西一起工作,或者硬着头皮自己对整个事情进行编程。
.NET 是一种选择,一旦您掌握了 Graphics 类,它就很容易使用,并且对于类似的事情来说速度很快。 然而,对于像这样面向图形的东西来说,可能有比 .NET 更好的语言/平台。
更新:.NET 对于 2D 图形的表现比我想象的要好得多。 关键是找到一种快速解决方法来解决 Bitmap 类中慢得可怜的 GetPixel() 和 SetPixel() 方法。 一旦您可以轻松快速地读取和写入单个像素,您就可以作为程序员做任何您想做的事情。
One of the big problems in displaying networks like this is figuring out where to put the nodes on the display screen. If arranging nodes is logically simple given your network, then an off-the-shelf product is likely to suit your needs.
If the arrangements are much more complicated, you may have to accept a certain amount of manual intervention to get this to work with off-the-shelf stuff, or byte the bullet and program the whole thing yourself.
.NET is one choice, and once you've mastered the Graphics class it's easy to use and plenty fast for something like this. However, there are probably better languages/platforms than .NET for something graphics-oriented like this.
Update: .NET is much better for 2D graphics than I knew. The key is finding a fast workaround to the pitifully slow GetPixel() and SetPixel() methods in the Bitmap class. Once you can read and write individual pixels easily and quickly, you can do whatever you want as a programmer.
您是否偶然查看过 R 编程语言? 我并不乐观,但我相信你可以用图表制作图像等。 r-project.org
Did you by chance check out the R programming language? I'm not positive but I believe that you can make images and such out of graphs. r-project.org
这里有一堆各种算法的可视化:算法动画工作室
There are a bunch of visualizations of various algorithms here: Algorithmics Animation Workshop