Source: http://perso.utinam.cnrs.fr/~viennot/doc/TP_EM2.pdf