输入图的边
input a graph's edges
import sys
import itertools
nodes=input("enter the number of nodes")
q=[]
q.append(x)
r=0
vertices=[]
a=0
for i in xrange(0,nodes):
vertices.append(a)
a=a+1
def inputgraph():
cordinates=[]
cor1=input("enter x or -1 to exit: ")
while cor1!=-1:
cor2= input("enter y")
cordinates.append((cor1,cor2))
cor1= input("enter x or -1 to exit: ")
return cordinates
def main():
cordinates=inputgraph()
if __name__ == '__main__':
main()
这是我的 python 代码,用于将图形的边输入到列表中。这里我们必须将边 (x,y) 作为两个单独的输入输入。有什么方法可以把它作为一个输入吗??
cor1, cor2 = [int(x) for x in raw_input("enter x y: ").split()]
import sys
import itertools
nodes=input("enter the number of nodes")
q=[]
q.append(x)
r=0
vertices=[]
a=0
for i in xrange(0,nodes):
vertices.append(a)
a=a+1
def inputgraph():
cordinates=[]
cor1=input("enter x or -1 to exit: ")
while cor1!=-1:
cor2= input("enter y")
cordinates.append((cor1,cor2))
cor1= input("enter x or -1 to exit: ")
return cordinates
def main():
cordinates=inputgraph()
if __name__ == '__main__':
main()
这是我的 python 代码,用于将图形的边输入到列表中。这里我们必须将边 (x,y) 作为两个单独的输入输入。有什么方法可以把它作为一个输入吗??
cor1, cor2 = [int(x) for x in raw_input("enter x y: ").split()]