SVG / Raphael,如何在 JavaScript 中实现 DOT 算法? (图组织)

发布于 2024-12-06 16:38:07 字数 569 浏览 0 评论 0原文

我的小提琴: http://jsfiddle.net/G5mTx/10/

如您所见,当前我组织节点的方式没有平衡,并且当父节点有超过 1 个子节点时存在一些重叠。

对于那些不熟悉 DOT 算法的人,可以在这里找到简短、模糊的解释:http://www.ece.uci.edu/~jhahn/pdf/dot.pdf

基本上,DOT 组织节点使得图形是最佳的,这意味着它是简洁的,具有最小的线交叉,并且是平衡的。

我听说有些人在将 DOT 算法发送到客户端之前运行服务器端...这会始终更快...但我需要每个节点都具有悬停和单击状态,因为我计划允许用户重新指定箭头/线条指向的位置。

我的意思是,我可以在服务器端生成 SVG。但是,我如何将悬停/单击事件连接到节点,并告诉服务器节点在重新分配行时代表哪个模型?

注意:我的服务器运行 Ruby on Rails 2.3.8

My fiddle: http://jsfiddle.net/G5mTx/10/

As you can see, the current way I'm organizing the nodes does no balancing, and there is some overlap when parent nodes have more than 1 child node.

For those not familiar with the DOT algorithm, a brief, vague explanation can be found here: http://www.ece.uci.edu/~jhahn/pdf/dot.pdf

Basically, DOT organizes the nodes such that the graph is optimal, which means that it is concise, has minimal line crossing, and is balanced.

I've heard of some people running the DOT algorithm server side before sending it to the client... which would be consistantly faster... but I need each of the nodes to have hover and click states, as I plan on allowing the user to re-assign where the arrows / lines point.

I mean, I COULD do the SVG generation server-side.. but then how would I hook up hover / click events to the nodes, and have the tell the server which Model the node represents upon line re-assignment?

Note: My server runs Ruby on Rails 2.3.8

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

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

发布评论

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

评论(1

初心未许 2024-12-13 16:38:07

我在这种情况下苦苦挣扎,并在我的服务器上运行 DOT 算法,仅将节点的新坐标发送回浏览器。最终我发现这个设置并不令人满意。

我改用 D3 的强制布局算法,它是用 Javascript 实现的,看起来比 DOT 更现代,现在我高兴多了。

I struggled with exactly this situation and ran the DOT algorithm on my server, sending only the new coordinates for the nodes back to the browser. Ultimately I found the setup unsatisfactory.

I switched to using D3's force layout algorithm, which is implemented in Javascript and appears to be more modern than DOT's, and now I'm much happier.

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