MetaPost Présentation des sources Retour à la page précédente Archive (source + images) Fichier au format texte pour télécharger Imprimer le document sans le menu !

prologues := 2 ;
defaultfont := "cmr10" ;

beginfig(1)

    diametre = 20 pt ;
    h = 50 pt ;
    v = 60 pt ;

    path demigauche,demidroit ;
    demidroit  = halfcircle scaled diametre rotated -90 -- cycle ;
    demigauche = demidroit xscaled -1 ;

    picture bb,bn,nb ;
    fill fullcircle scaled diametre withcolor white ;
    draw fullcircle scaled diametre ;
    bb := currentpicture ;

    currentpicture := nullpicture ;
    fill demidroit withcolor black ;
    fill demigauche withcolor white ;
    draw fullcircle scaled diametre ;
    bn := currentpicture ;

    currentpicture := nullpicture ;
    fill demigauche withcolor black ;
    fill demidroit withcolor white ;
    draw fullcircle scaled diametre ;
    nb := currentpicture ;

    currentpicture := nullpicture ;

% définition des coordonnées des sommets de l'arbre
    z0 = (0,0) ;
    y0 - y1 = y1 - y3 = y3 - y6 = y9 - y11 = v ; y1 = y2 ; y3 = y4 = y5 ; y6 = y7 = y8 = y9 = y10 ;
    x10 - x9 = x9 - x8 = x8 - x7 = x7 - x6 = x4 - x3 = h ;
    x4 = 1/2[x7,x8] ; x5 = 1/2[x9,x10] ; x1 = 1/2[x3,x4] ; x0 = 1/2[x1,x2] ;
    x5 - x2 = x9 - x11 = h/2 ;
% tracé des arètes
    draw z0 -- z1 -- z3 -- z6 ;
    draw z1 -- z4 -- z8 ;
    draw z4 -- z7 ;
    draw z0 -- z2 -- z5 -- z10 ;
    draw z5 -- z9 -- z11 ;
% tracé des sommets
    def sbb(text g)(expr a)(text d) =
        draw bb shifted a ;
        label(g,a - (14pt,0)) ; label(d,a + (14pt,0)) ;
    enddef ;

    def sbn(text g)(expr a)(text d) =
        draw bn shifted a ;
        label(g,a - (14pt,0)) ; label(d,a + (14pt,0)) ;
    enddef ;

    def snb(text g)(expr a)(text d) =
        draw nb shifted a ;
        label(g,a - (14pt,0)) ; label(d,a + (14pt,0)) ;
    enddef ;

    snb("6")(z0)("5") ; sbn("2")(z1)("3") ; sbn("0")(z2)("4") ; snb("1")(z3)("0") ;
    sbb("1")(z4)("1") ; snb("2")(z5)("1") ; sbb("0")(z6)("0") ; sbb("0")(z7)("0") ;
    sbb("0")(z8)("0") ; snb("1")(z9)("0") ; sbb("0")(z10)("0") ; sbb("0")(z11)("0") ;
endfig ;

end