﻿import matplotlib.pyplot as plt
from math import sqrt

liste_noms = [chr(ord('A') + i) for i in range(15)]

coord = [(0 ,1), (1, 1), (1, 0), (2, 0), (2, 1), (3, 1), (3, 0), (4, 0), (4, 1),
        (5, 1), (5, 0), (6, 0), (0, 3), (6, 3), (6, 1)]

adj = [[1, 12], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8],
        [7, 9], [8, 10], [9, 11], [10, 14], [0, 13], [12, 14], [11, 13]]


def dist_eucli(P1: tuple, P2: tuple) -> float:
    """
    P1 et P2 sont deux couples de coordonnées correspondant à deux points du plan
    renovie la distance euclidienne entre les deux points repérés par ces coordonnées
    """
    assert type(P1) == tuple and len(P1)==2 , "P1 doit coorespondre à un couple de coordonnées"
    assert type(P2) == tuple and len(P2)==2 , "P1 doit coorespondre à un couple de coordonnées"
    return sqrt((P1[0]-P2[0])**2+(P1[1]-P2[1])**2)

for i in range(15):
    plt.text(coord[i][0],coord[i][1], liste_noms[i], size=25)
    plt.plot(coord[i][0],coord[i][1],  marker = 'o', markerfacecolor = 'blue', markersize = 8)
    for j in adj[i] :
        print(j)
        plt.plot([coord[i][0],coord[j][0]], [coord[i][1],coord[j][1]], 'r-', lw=2) # Red straight line
        plt.text((coord[i][0]+coord[j][0])/2, (coord[i][1]+coord[j][1])/2, round(dist_eucli(coord[i],coord[j]),3), size=10)

plt.show()
