在两个随机节点之间使用pytjon脚本在Gephi中绘制一条路径

2024-04-29 07:52:59 发布

您现在位置:Python中文网/ 问答频道 /正文

我想在Gephi中的两个随机节点之间画一条路径。我写我的sudo代码请帮我。你知道吗

import random

i = random.sample(g.nodes,1) #[v76]  head of path
j = random.sample(g.nodes,1) #[v71]  end of path
# i = random.randint(n)      #first node, head of path
# j = random.randint(n)      #second node, end of path
for u in g.nodes:
    head = i
    for v in g.nodes:
        g.addUndirectedEdge(head,v);
        head = v;
        if v==j: break

结果:

>>> Traceback (most recent call last):   
File "<input>", line 1, in <module>   
TypeError: addDirectedEdge(): 1st arg can't be coerced to org.gephi.scripting.wrappers.GyNode

Tags: ofsamplepathin路径nodefor节点