Auteur ou autrice : Olivier Péault.
Mise en ligne le 10 avril 2024
Cet exemple illustre l’utilisation du package mptrees
présent sur le CTAN. Ce package propose des macros permettant de produire des arbres, dont notamment des arbres probabilistes et des graphes. Ici, un plan de métro.
Code
input mptrees;
beginfig(106);
u:=1.2cm;
nodewidth:=0.4cm;
defnodes((0,0.6u),(3u,0.6u),(5u,0),(8u,0),(10u,0.6u),(13u,0.6u),(0,-0.6u),
(3u,-0.6u),(10u,-0.6u),(13u,-0.6u));
nodeedgeoffset:=-0.2cm;
nodebgcolor:=0.8white;
edgelinewidth:=0.2cm;
vardef edgeshape (expr A,B)=A{dir 0}..{dir 0}B enddef;
drawedges((1,2))() withcolor red;
drawedges((5,6))() withcolor red;
drawedges((7,8))() withcolor blue;
drawedges((9,10))() withcolor blue;
endedgeshift:=0.1cm; drawedges((2,3))() withcolor red;
endedgeshift:=-0.1cm; drawedges((8,3))() withcolor blue;
endedgeshift:=0cm;
startedgeshift:=0.1cm; drawedges((4,5))() withcolor red;
startedgeshift:=-0.1cm;drawedges((4,9))() withcolor blue;
edgeshift:=0.1cm; drawedges((3,4))() withcolor red;
edgeshift:=-0.1cm; drawedges((3,4))() withcolor blue;
drawnode.bot(1,"C.H.U.");
drawnode.bot(2,"Berges de Maine");
drawnode.bot(5,"Hôtel de Ville");
drawnode.bot(6,"Foch - Maison bleue");
drawnode.bot(7,"Doutre");
drawnode.bot(8,"Place Molière");
drawnode.bot(9,"Conservatoire");
drawnode.bot(10,"Montaigne");
vardef nodeshape(expr p)=
(halfcircle shifted (0,0.5)--
halfcircle scaled -1 shifted (0,-0.5)--
cycle) scaled nodewidth
enddef;
drawnode.bot(3,"Saint-Serge");
drawnode.bot(4,"Centre de Congrès");
endfig;;
end.