# sommets A, B, C, E, F
d = [[0, 18, 22, 0, 0],
     [18, 0, 31, 26, 0],
     [22, 31, 0, 0, 17],
     [0, 26, 0, 0, 12],
     [0, 0, 17, 12, 0]]
l = [0, 1000, 1000, 1000, 1000]
m = [False,False,False,False,False]

def choix():
    mini,imini = 1000, -1
    for i in range(5):
        if not m[i] and l[i]<mini:
            mini,imini = l[i],i
    return(imini)

def traite(i):
    for j in range(5):
        if i!= j and not m[j] and d[i][j] != 0 and l[i]+d[i][j]<l[j]:
            l[j] = l[i]+d[i][j]
    m[i] = True
