图自动布局算法

发布于 2024-10-17 20:16:13 字数 180 浏览 8 评论 0原文

为了简化问题,我有一个包含二维平面上的节点和边的图。

我想要做的是单击一个按钮,它会自动布局图表以使其看起来干净。我的意思是边的最小交叉,节点之间的良好空间,甚至可能代表图形比例(加权边)。

我知道这对于什么是干净的图表来说完全是主观的,但是有人知道一种算法可以开始,而不是重新发明轮子吗?

谢谢。

To simplify the problem, I have a graph that contains nodes and edges which are on a 2D plane.

What I want to be able to do is click a button and it make the automatically layout the graph to look clean. By that I mean minimal crossing of edges, nice space between nodes, maybe even represent the graph scale (weighted edges).

I know this is completely subjective of what is a clean looking graph, but does anyone know of an algorithm to start with, rather than reinventing the wheel?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

泪眸﹌ 2024-10-24 20:16:13

您将找到 http://graphdrawing.org/本教程,作者 罗伯特·塔马西亚,布朗大学教授,非常有帮助。

我喜欢很多力导向技术(教程中的第 66-72 页),例如 Spring Embedder

您假设任意两个相邻节点之间存在弹簧或其他力,并让自然(模拟)完成工作:)

You will find http://graphdrawing.org/ and this tutorial, by Roberto Tamassia, professor at Brown University, quite helpful.

I like a lot Force-Directed Techniques (pp. 66-72 in the tutorial) like the Spring Embedder.

You assume there is a spring or other force between any two adjacent nodes and let nature (simulation) do the work :)

因为看清所以看轻 2024-10-24 20:16:13

我建议您看一下 graphvizdot 程序可以获取图形规范并为您“干净”地生成网络图像。我已链接到“理论”页面,如果您对理论背景感兴趣,该页面将为您提供一些可能相关的链接。如果您只是想要解决所面临的布局问题,那么库和工具本身就足够成熟了。

I would suggest that you take a look at at graphviz. The dot program can take a specification of a graph and generate an image of the network for you somewhat "cleanly". I've linked to the "theory" page that gives you some links that might be relevant if you're interested in the theoretical background. The library and tools themselves are mature enough if you simply want a solution to a problem with layout that you're facing.

屋顶上的小猫咪 2024-10-24 20:16:13

我想说的是 Noufal Ibrahim,但您也可以更精确地查看 graphviz 的 C API项目。它包含一个用于构建包含所有节点的图形的库 (libgraph.pdf)和边,以及一个用于布局图形的库(libgvc.pdf)(只是计算每个节点的位置),这样您就可以将其显示在您自己的 UI 中。

I would say as Noufal Ibrahim, but you could also look more precisely at the C API of the graphviz project. It includes a lib to build your graph (libgraph.pdf) with all the nodes and edges, and a lib to layout the graph (libgvc.pdf) (just compute each nodes position), so you can then display it in your own UI for example.

如果您想要 Java 中的布局(我在该项目上工作),也可以使用 JGraph

Also JGraph if you want the layouts in Java (I work on the project).

小女人ら 2024-10-24 20:16:13

一个很好的视觉指南,介绍了最流行的布局的实际外观:点击链接

A good visual guide how the most popular layouts actually look: follow the link

ゞ花落谁相伴 2024-10-24 20:16:13

对于 javascript,我推荐 Microsoft 的这个库: https://microsoft.github.io/msagljs/

For javascript I recommend this library from Microsoft: https://microsoft.github.io/msagljs/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文