networkx/igraph (Python) 上指定的边长度
我想用我拥有的数据可视化一个网络,并想用特定的边长度来绘制它们。我使用Python,并且尝试过networkx和igraph来绘图,但似乎都分配了固定的边长度。
a.)我想知道我是否写错了代码或者这些软件包实际上没有能力。如何正确实现 networkx 或 igraph 的指定边长?
b.) 如果networkx 和igraph 不能做到这一点,您可以建议什么包? (最好是能承载8万个以上节点的。)
谢谢!
I wanted to visualize a network with the data I have and would like to graph them with specific edge lengths. I use Python, and I've tried networkx and igraph to plot but all seem to assign fixed edge lengths.
a.) I wonder if I did the codes wrong or the packages aren't really capable. How do you properly implement specified edge lengths for networkx or igraph?
b.) If networkx and igraph can't do it, what package could you possibly suggest? (Preferably one that can carry over 80 thousand nodes.)
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这应该可行:
大多数图形绘制算法都使用某些版本的 SMACOF,这当然会改变边长;然而,graphviz 布局引擎“neato”(作为上面“draw”的第二个参数提供)应该尽可能保留用户设置的边长。
我在这里使用的库确实足够坚固,可以处理 80,000 个节点。
This should work:
Most graph drawing algorithms use some version of SMACOF, which of course varies the edge length; however, the graphviz layout engine 'neato' (supplied as the 2nd argument to 'draw' above) ought to preserve, if at all possible, user-set edge lengths.
The library i used here is certainly sturdy enough to handle 80,000 nodes.
AFAIK、networkx 和 igraph 没有根据给定的一组边长度推断节点位置的布局函数。
然而, netgraph 是一个用于实现更好的网络可视化的 Python 库,它确实实现了所需的功能几何节点布局。在下面的示例中,我使用边列表来表示网络,但 netgraph 也接受 networkx、igraph 和 graph-tool Graph 对象。
但不想使用 netgraph 进行绘图,则可以使用
get_geometric_layout
函数计算节点位置:但是< /strong>,netgraph 使用非线性优化从边长推断节点位置。该计算与节点数量的平方成正比。对于可以合理表示为链路图(即最多几百个节点)的网络,计算时间相当短(<2 秒),但我从未尝试过在 80k 节点上运行该过程,我怀疑需要几天时间才能完成。
AFAIK, networkx and igraph do not have a layout functions that infers node positions based on a given set of edge lengths.
However, netgraph, which is a python library for making better network visualisations, does implement the desired functionality in the geometric node layout. In the example below, I am using an edge list to represent the network, but netgraph also accepts networkx, igraph, and graph-tool Graph objects.
If you only want the node positions but you don't want to use netgraph for plotting, you can compute the node positions using the
get_geometric_layout
function:However, netgraph uses a non-linear optimisation to infer the node positions from the edge lengths. This computation scales with the square of the number of nodes. For networks that can reasonably represented as link diagrams (i.e. up to a few hundred nodes) the computation time is reasonably short (<2 seconds) but I have never tried running the procedure on 80k nodes and I suspect it would take days to finish.