“Arrows Directions, 两个单独的箭头,双向但不是双向箭头,通过一个箭头表示”

huangapple go评论55阅读模式
英文:

Arrows Directions, 2 separate arrows both ways but not bidirectional depicted via 1 arrow

问题

我正在尝试生成一个图,其中有一条从'A'到'B'的箭头,一条从'B'到'A'的箭头,以及一条从'A'到'C'的箭头。我尝试使用bidirectional=True选项,但这并非对所有节点都适用,所以我不能这样做。一直在尝试不同的方法,但似乎找不到我想要的。

英文:

I have the following code that I've been working on:

import networkx as nx
from pyvis.network import Network
import webbrowser

# Initialize a MultiDiGraph
G = nx.MultiDiGraph()

# Add the edges and nodes
G.add_edges_from([('A', 'B'), ('B', 'A'), ('A', 'C')])

# Create a pyvis network
nt = Network(height="800px", width="1600px", notebook=True)

# Add the nodes to the network
nt.add_nodes(G.nodes())

# Add the edges to the network with arrows in both directions
for source, target in G.edges():
    nt.add_edge(source, target, arrows='to')

# Show the network
nt.show("graph.html")

# Open the HTML file in the browser
webbrowser.open("graph.html")

I am trying to generate a graph that has a edge that has an arrow going from 'A' to 'B', an arrow going from 'B' to 'A', and an arrow going from 'A' to 'C'.

I have tried using the bidirectional=True option, but this is not always the case for all the nodes, so I cannot have that. Been playing around with it to see what I can do, but I cannot seem to find what I am looking for.

答案1

得分: 0

如果在初始化网络时设置了 directed=True,您应该会得到您想要的结果 nt = Network(height="800px", width="1600px", notebook=True, directed=True)

英文:

If you set directed=True while initiating your network you should get the result you want nt = Network(height="800px", width="1600px", notebook=True,directed=True)

“Arrows Directions, 两个单独的箭头,双向但不是双向箭头,通过一个箭头表示”

huangapple
  • 本文由 发表于 2023年5月22日 04:54:18
  • 转载请务必保留本文链接:https://go.coder-hub.com/76301887.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定