admin管理员组文章数量:1516870
I have created a network diagram using python, networkx and pyvis. By default, the diagram changed visually each time I open / refresh it. So to stop that, I have added the following code
# Compute static positions for nodes
positions = nx.spring_layout(G, seed=42) # `seed` ensures reproducibility
# Add nodes to the PyVis network with fixed positions
for node, pos in positions.items():
x, y = pos[0] * 200, pos[1] * 200 # Scale positions to better fit the PyVis canvas
net.add_node(str(node), x=x, y=y, color="lightblue", size=10)
Also, I have below physics options because if I turn off physics it clutters and overlap the diagram and doesn't look good visually.
net.set_options("""
var options = {
"configure": {
"enabled": true,
"filter": ["physics"]
},
"physics": {
"enabled": true,
"solver": "barnesHut",
"barnesHut": {
"theta": 0.5,
"gravitationalConstant": -11500,
"centralGravity": 0,
"springLength": 300,
"springConstant": 0.04,
"damping": 0.1,
"avoidOverlap": 0
},
"stabilization": {
"enabled": true,
"iterations": 1000,
"fit": true
},
"minVelocity": 0.75,
"timestep": 1
}
}
""")
Now, the diagram remains the same visually no mater how many times I refresh or open it.
But, now the problem is whenever I select a node on the diagram it always quickly shrinks and expands just like something is dropped into the water. When it settles it is slightly changed (nodes and edges remain the same but appearance is little bit changed).
Has someone experienced a same situation I kindly seek a way to stop this effect.
Thank you!
本文标签: Issue with Network Diagram Generated with PythonnetworkXPyvisStack Overflow
版权声明:本文标题:Issue with Network Diagram Generated with Python, Networkx, Pyvis - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.betaflare.com/web/1736129936a1906157.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论