我有以下代码可以使用 ipycytoscape 生成和绘制图形:
from ipycytoscape import CytoscapeWidget
import networkx as nx
cyto = CytoscapeWidget()
nodes = [1,2,3,4,5,6,7,8]
children = [[2],[3,4],[5,6],[6,7],[8],[],[8],[]]
G2 = nx.Graph()
G2.add_nodes_from(nodes)
for i,child in enumerate(children):
for c in child:
G2.add_edge(i+1, c)
cyto.graph.add_graph_from_networkx(G2, directed=True)
cyto.set_layout(name='dagre', nodeSpacing=10, edgeLengthVal=10)
display(cyto)
现在如果我添加一个布局,不管它是什么
cyto_style = [{ 'selector' : 'node',
'style': {'font-family': 'arial',
'font-size': '10px',
'label': 'data(id)'}}]
cyto.set_style(cyto_style)
display(cyto)
箭头消失了!!!没有方向性绘图。我应该怎么做才能使箭头在添加样式之前保持原样?