From 9e87482a5254121d0d1e62c45b330b1e3bf2c0fa Mon Sep 17 00:00:00 2001 From: antograb Date: Sat, 18 Nov 2017 17:58:37 +0100 Subject: [PATCH] =?UTF-8?q?Ajout=20parcours=20DFS=20et=20marquer-examiner?= =?UTF-8?q?=20cas=20orient=C3=A9s=20(Issue=20#5)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fiche_inf101.tex | 55 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/fiche_inf101.tex b/fiche_inf101.tex index 981c56a..b3f1644 100755 --- a/fiche_inf101.tex +++ b/fiche_inf101.tex @@ -619,6 +619,61 @@ $\Rightarrow$ Algorithme de \textsc{Bellman} : \end{axis} \end{tikzpicture} +\section*{Parcours de graphes} + +\subsection*{Parcours en largeur} + +Soit \GXA et $r\in X$. + +\begin{algorithm}[H] +Aucun sommet n'est examiné\; +Aucun sommet n'est marqué\; +Marquer $r$\; +Aucun arc n'est traversé\; +\While{$\exists$ un sommet $x$ marqué et un arc $(x,y)$ non traversé} +{ + \If{$x$ non examiné}{Examiner $x$}\; + traverser $(x,y)$\; + \If{$y$ non marqué} + { + marquer $y$\; + père$(y) \longleftarrow x$\; + } +} +\caption{\enquote{Moule} d'un parcours de graphe orientés en largeur} +\end{algorithm} + +Gestion des objets \emph{marqués} selon une file : +\begin{itemize} +\item On ajoute les nouveaux sommets marqués à la fin de la file +\item On retire le sommet du début de la file une fois qu'il est examiné +\end{itemize} + +\subsection*{Parcours en profondeur DFS} + +Soit \GXA et $r\in X$. +\begin{flushright} +{\footnotesize +{\color{blue} cas préfixe} \\ +{\color{red} cas postfixe} +} +\end{flushright} +\begin{algorithm}[H] +marquer $x$\; +{\color{blue} attribuer à $x$ le numéro préfixe courant}\; +\For{$(x,y)\in A$} +{ + traverser $(x,y)$\; + \If{$y$ non marqué} + { + père($y$) $\longleftarrow x$\; + appliquer DFS à $x$\; + } +} +{\color{red} attribuer à $x$ le numéro postfixe courant}\; +\caption{DFS($x$)} +\end{algorithm} + \section*{Flux et flots} \newcommand{\Sb}{\overline{S}}