gpt4 book ai didi

graph - d3.js 中的网络多路由正交图

转载 作者:数据小太阳 更新时间:2023-10-29 05:33:47 25 4
gpt4 key购买 nike

我们想用d3画一个网络路由图,起始节点和结束节点是固定的,但中间的路径不同,可能共享一些节点,例如: enter image description here

我阅读了来自 Configure fixed-layout static graph in d3.js 的评论并成功创建了一个简单的图形,如:

enter image description here

但是当我向图中添加更多节点时,它变得随机(刷新后不是静态的)并且不再是正交的:

enter image description here

所以我的问题是:

  • 是否可以使用 d3.js 来绘制接近所需的东西图形?
  • 或者有没有我应该在我的工作中使用的算法图实现?

最佳答案

在这里看我的演示。

http://jsfiddle.net/doraeimo/JEcdS/

主要思想是基于树建立连接。

    //1)temporarily convert a connectivity to a tree        
var tree = conv2tree(data);

//2)calculate for nodes' coords with <code>cluster.nodes(tree);</code>
var nodes = buildNodes(tree);

//3)append all the edges(links) of the connectivity
var links = buildLinks(data);

关于graph - d3.js 中的网络多路由正交图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16424533/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com