# Exemples de graphes avec Metapost

Les exemples suivants utilisent des fichiers de configuration disponibles ici :
– dlf_tex.mp
– dlf_boxes.mp

## Exemple 6

Voici les sources :

input geometriesyr16.mp ;
input dlf_tex.mp;
input dlf_boxes;

%------------------------------------------------------------------------
% Exercice 1
%------------------------------------------------------------------------

u:=1cm;
figure (-20u,-20u,20u,20u);

circleit.bb(TEX("{\large $B$}"));  %définition des noeuds
circleit.dd(TEX("{\large $D$}"));
circleit.ff(TEX("{\large $F$}"));
circleit.hh(TEX("{\large $H$}"));
circleit.kk(TEX("{\large $K$}"));
circleit.mm(TEX("{\large $M$}"));
circleit.nn(TEX("{\large $N$}"));
circleit.ss(TEX("{\large $S$}"));

mm.c-ss.c=(4u,-2u);                % positionnement relatif des noeuds
kk.c-ss.c=(-3u,-u);
ff.c-kk.c=(0,3u);
dd.c-ff.c=(-2u,2u);
bb.c-dd.c=(10u,0);
bb.c-nn.c=(-u,4u);
hh.c-ss.c=(0,7u);

drawboxed(bb,dd,ff,hh,kk,mm,nn,ss) ;  %dessin des noeuds.

label(TEX("\colorbox{white}{230}"), aretec(ss,mm,0,0.5)) ;  %dessin des arêtes
label(TEX("\colorbox{white}{210}"), aretec(ss,nn,20,0.5)) ;
label(TEX("\colorbox{white}{630}"), aretec(ss,bb,60,0.35)) ;
label(TEX("\colorbox{white}{650}"), aretec(ss,hh,110,0.5)) ;

label(TEX("\colorbox{white}{580}"), aretec(mm,bb,80,0.5)) ;
label(TEX("\colorbox{white}{780}"), aretec(mm,hh,130,0.5)) ;
label(TEX("\colorbox{white}{600}"), aretec(mm,dd,160,0.6)) ;

label(TEX("\colorbox{white}{600}"), aretec(nn,hh,140,0.5)) ;

label(TEX("\colorbox{white}{490}"), aretec(bb,dd,220,0.75)) ;

label(TEX("\colorbox{white}{490}"), aretec(ff,hh,90,0.5)) ;
label(TEX("\colorbox{white}{120}"), aretec(ff,kk,300,0.5)) ;

fin;
%-----------------------------------------------------------------------

%------------------------------------------------------------------------
% Exercice 2
%------------------------------------------------------------------------

u:=1cm;
figure (-20u,-20u,20u,20u);

circleit.gg(TEX("{\large $G$}"));  %définition des noeuds
circleit.aa(TEX("{\large $A$}"));
circleit.kk(TEX("{\large $P$}"));
circleit.rr(TEX("{\large $R$}"));
circleit.cc(TEX("{\large $C$}"));
circleit.qq(TEX("{\large $Q$}"));
circleit.ee(TEX("{\large $E$}"));

kk.c-rr.c=(0,6u);                % positionnement relatif des noeuds
gg.c-rr.c=(-4u,-u);
aa.c-gg.c=(0,6u);
cc.c-aa.c=(9u,0);
qq.c-cc.c=(2u,-2u);
qq.c-ee.c=(u,3u);

drawboxed(gg,aa,kk,rr,cc,qq,ee) ;  %dessin des noeuds.

label(TEX(""), aretec(gg,aa,30,0.5)) ;  %dessin des arêtes
label(TEX(""), aretec(aa,kk,350,0.5)) ;
label(TEX(""), aretec(kk,qq,280,0.5)) ;
label(TEX(""), aretec(kk,ee,270,0.5)) ;
label(TEX(""), aretec(gg,rr,70,0.5)) ;
label(TEX(""), aretec(rr,cc,80,0.5)) ;
label(TEX(""), aretec(aa,cc,50,0.5)) ;
label(TEX(""), aretec(aa,qq,40,0.5)) ;
label(TEX(""), aretec(ee,cc,120,0.5)) ;
label(TEX(""), aretec(ee,qq,120,0.5)) ;

fin;
%-----------------------------------------------------------------------

%------------------------------------------------------------------------
% Exercice 3
%------------------------------------------------------------------------

u:=1cm;
figure (-20u,-20u,20u,20u);

circleit.aa(TEX("{\large $A$}"));  %définition des noeuds
circleit.bb(TEX("{\large $B$}"));
circleit.cc(TEX("{\large $C$}"));
circleit.dd(TEX("{\large $D$}"));
circleit.ee(TEX("{\large $E$}"));
circleit.ff(TEX("{\large $F$}"));

aa.c-ee.c=(0,6u);                % positionnement relatif des noeuds
ff.c-aa.c=(-2u,-u);
bb.c-ff.c=(8u,0);
cc.c-bb.c=(2u,-2u);
dd.c-ee.c=(5u,0);

drawboxed(aa,bb,cc,dd,ee,ff) ;  %dessin des noeuds.

label(TEX(""), areted(ee,aa,0.5)) ;  %dessin des arêtes
label(TEX(""), areted(ee,bb,0.5)) ;
label(TEX(""), areted(ee,cc,0.5)) ;
label(TEX(""), areted(ee,dd,0.5)) ;

label(TEX(""), areted(dd,aa,0.5)) ;
label(TEX(""), areted(dd,ff,0.5)) ;
label(TEX(""), areted(dd,bb,0.5)) ;

label(TEX(""), areted(cc,bb,0.5)) ;
label(TEX(""), areted(ff,bb,0.5)) ;
label(TEX(""), areted(ff,aa,0.5)) ;

fin;
%-----------------------------------------------------------------------

%------------------------------------------------------------------------
% Exercice 4
%------------------------------------------------------------------------

u:=1cm;
figure (-20u,-20u,20u,20u);

circleit.aa(TEX("{\large $A$}"));  %définition des noeuds
circleit.bb(TEX("{\large $B$}"));
circleit.cc(TEX("{\large $C$}"));
circleit.dd(TEX("{\large $D$}"));
circleit.ee(TEX("{\large $E$}"));
circleit.ss(TEX("{\large $S$}"));
circleit.gg(TEX("{\large $G$}"));

aa.c-bb.c=(0,6u);                % positionnement relatif des noeuds
cc.c-bb.c=(6u,0);
dd.c-aa.c=(6u,0);
ee.c-bb.c=(-3u,3u);
gg.c-cc.c=(3u,u);
ss.c-dd.c=(3u,-u);

drawboxed(aa,bb,cc,dd,ee,ss,gg) ;  %dessin des noeuds.

label(TEX("\colorbox{white}{7}"), areted(bb,ee,0.5)) ;  %dessin des arêtes
label(TEX("\colorbox{white}{2}"), areted(bb,aa,0.5)) ;
label(TEX("\colorbox{white}{6}"), areted(bb,dd,0.4)) ;
label(TEX("\colorbox{white}{5}"), areted(bb,cc,0.5)) ;

label(TEX("\colorbox{white}{8}"), areted(cc,aa,0.6)) ;
label(TEX("\colorbox{white}{3}"), areted(cc,dd,0.5)) ;
label(TEX("\colorbox{white}{8}"), areted(cc,ss,0.5)) ;
label(TEX("\colorbox{white}{4}"), areted(cc,gg,0.5)) ;

label(TEX("\colorbox{white}{4}"), areted(aa,ee,0.5)) ;
label(TEX("\colorbox{white}{9}"), areted(aa,dd,0.5)) ;

label(TEX("\colorbox{white}{8}"), areted(dd,ss,0.5)) ;
label(TEX("\colorbox{white}{5}"), areted(dd,gg,0.5)) ;

label(TEX("\colorbox{white}{5}"), areted(ss,gg,0.5)) ;

fin;
%-----------------------------------------------------------------------

%------------------------------------------------------------------------
% Exercice 5
%------------------------------------------------------------------------

u:=1cm;
figure (-20u,-20u,20u,20u);

circleit.aa(TEX("{\large $A$}"));  %définition des noeuds
circleit.bb(TEX("{\large $B$}"));
circleit.cc(TEX("{\large $C$}"));
circleit.dd(TEX("{\large $D$}"));
circleit.ee(TEX("{\large $E$}"));
circleit.ff(TEX("{\large $F$}"));
circleit.gg(TEX("{\large $G$}"));

ee.c-dd.c=(-3u,2u);                % positionnement relatif des noeuds
aa.c-dd.c=(-u,5u);
ff.c-dd.c=(2u,3u);
bb.c-aa.c=(5u,u);
cc.c-dd.c=(4u,u);

drawboxed(aa,bb,cc,dd,ee,ff) ;  %dessin des noeuds.

label(TEX("\colorbox{white}{4}"), flechec(aa,ee,240,0.5)) ;  %dessin des arêtes

label(TEX("\colorbox{white}{2}"), flechec(bb,aa,200,0.5)) ;
label(TEX("\colorbox{white}{3}"), flechec(bb,ff,200,0.5)) ;

label(TEX("\colorbox{white}{9}"), flechec(cc,bb,120,0.5)) ;
label(TEX("\colorbox{white}{6}"), flechec(cc,ff,100,0.5)) ;
label(TEX("\colorbox{white}{2}"), flechec(cc,dd,170,0.5)) ;

label(TEX("\colorbox{white}{9}"), flechec(dd,aa,90,0.5)) ;
label(TEX("\colorbox{white}{2}"), flechec(dd,cc,0,0.5)) ;
label(TEX("\colorbox{white}{3}"), flechec(dd,ff,30,0.5)) ;

label(TEX("\colorbox{white}{4}"), flechec(ee,dd,0,0.5)) ;

label(TEX("\colorbox{white}{6}"), flechec(ff,aa,130,0.5)) ;
label(TEX("\colorbox{white}{3}"), flechec(ff,bb,50,0.5)) ;
label(TEX("\colorbox{white}{6}"), flechec(ff,cc,280,0.5)) ;

fin;
%-----------------------------------------------------------------------

%------------------------------------------------------------------------
% Exercice 6
%------------------------------------------------------------------------

u:=1cm;
figure (-20u,-20u,20u,20u);

circleit.bb(TEX("{\large $B$}"));  %définition des noeuds
circleit.cc(TEX("{\large $C$}"));
circleit.dd(TEX("{\large $D$}"));
circleit.ll(TEX("{\large $L$}"));
circleit.mm(TEX("{\large $M$}"));
circleit.kk(TEX("{\large $P$}"));

kk.c-mm.c=(-3u,2u);                % positionnement relatif des noeuds
bb.c-mm.c=(u,6u);
dd.c-bb.c=(4u,2u);
cc.c-mm.c=(3u,3u);
ll.c-mm.c=(5u,u);

drawboxed(bb,cc,dd,ll,mm,kk) ;  %dessin des noeuds.

label(TEX("\colorbox{white}{4}"), doubleflechec(mm,kk,160,0.5)) ;  %dessin des arêtes
label(TEX("\colorbox{white}{5}"), doubleflechec(mm,bb,100,0.5)) ;
label(TEX("\colorbox{white}{9}"), doubleflechec(mm,cc,50,0.5)) ;

label(TEX("\colorbox{white}{10}"), flechec(ll,mm,180,0.5)) ;
label(TEX("\colorbox{white}{4}"), doubleflechec(ll,cc,130,0.5)) ;
label(TEX("\colorbox{white}{11}"), doubleflechec(ll,dd,100,0.5)) ;

label(TEX("\colorbox{white}{3}"), flechec(cc,bb,120,0.5)) ;

label(TEX("\colorbox{white}{5}"), flechec(dd,cc,250,0.5)) ;
label(TEX("\colorbox{white}{9}"), flechec(dd,bb,190,0.5)) ;

label(TEX("\colorbox{white}{10}"), flechec(bb,kk,210,0.5)) ;

fin;
%-----------------------------------------------------------------------

%-----------------------------------------------------------------------
end ;