Professional Documents
Culture Documents
Implementation of Vector Clock
Implementation of Vector Clock
CLOCK
E1 = int(input("Enter the no of event at Side 1:"))
L1 = []
L2 = []
rec = []
for i in range(E1):
L1.append([i+1,0]);
for j in range(E2):
L2.append([0,j+1])
for i in range(E1):
temp = list(map(int,input().split()))
rec.append(temp)
for i in range(E1):
for j in range(E2):
if(rec[i][j] == -1):
A,B = L1[i][1],L2[j][1]
L1[i][1] = max((L1[i][1]),(L2[j][1]))
if(A< B):
for k in range(i+1,E1):
L1[k][1] = L1[k-1][1]
elif(rec[i][j] == 1):
A,B = L1[i][0],L2[j][0]
L2[j][0] = max((L2[j][0]),L1[i][0])
for k in range(j+1,E2):
L2[k][0] = L2[k-1][0]
print(*L1)
print(*L2)
OUTPUT: