错误"参数没有价值' b'在方法调用"同时生成图形

时间:2016-04-26 12:40:46

标签: python graph

我必须生成一个欧拉图,然后打印出它的路径,我决定使用Python 3.x.但是,我无法让图形生成器工作。到目前为止我的代码:

from random import randint
def generateGraph(n,intensity):
    res=[[] for i in range(n)]
    for i in range(n):
        res[n][n]=0
    for i in range(n):
        for j in range(i):
            if (randint(100)<intensity):
                res[i][j],res[j][i]=1,1
    for i in range(n-1):
        deg=0
        for j in range(n-1):
            if (res[i][j]==1):
                deg+=1
        if(deg%2!=0):
            x=randint(n-i-1)+i+1
            if (res[i][x]>0):
                res[x][i],res[i][x]=0,0
            else:
                res[i][x],res[x][i]=1,1
    return res
result=['1',]
def Euler(v,g1):
    for y in range(len(g1)):
        if (g1[v][y]==1):
            g1[v][y],g1[y][v]=0,0
            Euler(y,g1)
            result.append(str(v+1))
    return result
graph=generateGraph(10,30)
Euler(0,graph)
print (result)

暂时忽略图表连接,我在标题中收到错误:

if (randint(100)<intensity)

x=randint(n-i-1)+i+1

我尝试在线查找解决方案但到目前为止我还没有找到解决方案。我赞成有关此主题的任何帮助。

0 个答案:

没有答案