简体   繁体   English

我可以在 Python igraph 中有一些弯曲的边缘和其他直的边缘吗?

[英]Can I have some edges curved and other straight in Python igraph?

I am trying to create the graph as shown in Python igraph and I am having trouble displaying some edge straight and others curved.我正在尝试创建 Python igraph 中所示的图形,但我无法显示一些直线边缘和弯曲边缘。 Is this possible, the edge_curved function appears to only take one argument.这可能吗,edge_curved function 似乎只接受一个参数。

在此处输入图像描述

在此处输入图像描述

# Construct the graph
g = ig.Graph(n=9,
    edges = [(6,7),(6,8),(6,3),(6,0),
             (7,8),(7,4),(7,3),
             (8,2),(8,5), 
             (3,4),(3,0),(4,1),(4,5), (5,2), (5,1),
             (0,1),(0,2), (1,2)])

#g.es["weight"] = [2, 1, 5, 4, 7, 3, 2]
g.es["label"]= ["a","b","c","d", "e", "g", "f", "e", "h", "j","k","m", "l", "o", "n", "p", "q", "r" ]
g.vs["name"] = ["G","H","X","D","E","F","A","B","C"]

print("Is simple ", g.is_simple())
print("Degree ", g.vs.degree())
print(g)

# Plot graph
g.es['width'] = 0.5

fig, ax = plt.subplots()
ig.plot(
    g,
    target=ax,
    layout='grid',
    vertex_color='steelblue',
    vertex_label=g.vs["name"], 
    autocurve=True,
    #vertex_label=range(g.vcount()),
    edge_label=g.es['label'],
    edge_width=g.es['width'],
    edge_curved="0.2",
    #edge_label=g.es["weight"],
    edge_color='#666',
    edge_align_label=False,
    edge_background='white'
)

python-igraph dev here. python-igraph 开发在这里。

autocurve is designed as a global option at present. autocurve目前被设计为一个全局选项。 Per-edge setting would be a little difficult to handle if there are several parallel edges between the same two nodes.如果在相同的两个节点之间有多个平行边,则按边设置会有点难以处理。

Of course, you could split the graph into two, one with the curved and one with the straight edges, and plot twice.当然,您可以将图形一分为二,一是曲线,一是直边,plot 两次。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM