Skip to content

Instantly share code, notes, and snippets.

@Marceeaax
Last active September 16, 2021 01:18
Show Gist options
  • Save Marceeaax/3ee961ecbd38b3ad8eceb5acaa57d8c1 to your computer and use it in GitHub Desktop.
Save Marceeaax/3ee961ecbd38b3ad8eceb5acaa57d8c1 to your computer and use it in GitHub Desktop.
This program shows all the operations performed when calculating the transitivity of a fuzzy relation
C = [[1, 0.8,0.9], [0.8, 1,0.9],[0.9, 0.9,1]]
def operations(i,j,k,X):
print("X[" + str(j) + "]" + "[" + str(k) + "] >= max(X[" + str(j) + "]" + "[" + str(k) + "],min(X[" + str(j) + "]" + "[" + str(i) + "],X[" + str(i) + "]" + "[" + str(k) + "]))")
print(str(X[j][k]) + " >= max(" + str(X[j][k]) + ",min(" + str(X[j][i]) + "," + str(X[i][k]) + "))")
print(str(X[j][k]) + " >= max(" + str(X[j][k]) + "," + str(min(X[j][i],X[i][k])) + ")")
print(str(X[j][k]) + " >= " + str(max(X[j][k],min(X[j][i],X[i][k]))))
print("----------------")
def transitive(X):
for i in range(len(X)):
for j in range(len(X)):
for k in range(len(X)):
if (X[j][k] < max(X[j][k],min(X[j][i],X[i][k]))):
print("Intransividad detectada: ")
operations(i,j,k,X)
#return False
else:
print("Se cumple la transitividad:")
operations(i,j,k,X)
#return True
transitive(C)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment