Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rawFile = open("example.txt", "r")
- fileCon = [lines.replace("\n","").split(" ") for lines in rawFile]
- rawFile.close()
- V = int(fileCon[0][0])
- E = int(fileCon[0][1])
- R = int(fileCon[0][2])
- C = int(fileCon[0][3])
- X = int(fileCon[0][4])
- Vs = [int(x) for x in fileCon[1]]
- Ess = []
- start = 2
- for i in range(E):
- temp = int(fileCon[start][1])
- temp2 = [0 for x in range(temp)]
- temp3 = (int(fileCon[start][0]))
- for x in range(temp):
- start += 1
- temp2[int(fileCon[start][0])] = int(fileCon[start][1])
- Ess.append((temp3,temp2))
- start += 1
- Rs = [[-1 for x in range(E)] for y in range(V)]
- ARs = []
- counter = 0
- tempA = []
- for k in range(start,len(fileCon)):
- temp4 = [int(i) for i in fileCon[k]]
- Rs[temp4[0]][temp4[1]] = temp4[2]
- tempA.append([temp4[2],Vs[counter],temp4[1],temp4[0]])
- counter += 1
- tempA.sort()
- tempA.reverse()
- for x in range(len(tempA)):
- tempA[x].reverse()
- tempC = []
- key = tempA[0][3]
- tempB = tempA[0]
- for y in range(1,len(tempA)):
- if tempA[y][3] == key:
- tempB.append([tempA[2],tempA[3],tempA[1],tempA[0]])
- print (tempB,"here")
- else:
- print (tempB,"there")
- tempB.sort()
- tempC.append(tempB)
- tempB = []
- key = tempA[y][3]
- tempC.reverse()
- tempD = [
- print (tempC)
- print (V,E,R,C,X)
- print (Vs)
- print (Ess)
- print (Rs)
- print (tempA)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement