Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
aleber02
LaTeX Agreg
Commits
6286b92c
Commit
6286b92c
authored
Oct 12, 2022
by
aleber02
Browse files
algo
parent
a7a7cd22
Changes
2
Hide whitespace changes
Inline
Side-by-side
Algos.pdf
View file @
6286b92c
No preview for this file type
Algos.tex
View file @
6286b92c
...
...
@@ -493,5 +493,84 @@
\subsection
{
Programmation dynamique
}
\begin{definition}
Se ramener à des sous-problèmes en sauvegardant à chaque fois le résultat pour des réutilisations ultérieures
\end{definition}
\subsection
{
Algorithmes de graphes
}
\begin{algo}
[Kosaraju]
Calcul de composantes fortement connexes :
\begin{enumerate}
\item
Parcours en profondeur avec marquage de
$
G
$
\item
Parcours en profondeur avec marquage de
$
G
^
T
$
en commençant par les noeuds de
\texttt
{
post
}
maximal
\end{enumerate}
\end{algo}
\begin{algo}
[Dijkstra]
Plus court chemin depuis une source vers tous les sommets
\end{algo}
\begin{algo}
[Bellman-Ford]
Plus court chemin depuis une source vers tous les sommets
\end{algo}
\begin{algo}
[Floyd-Warshall]
Tous les plus courts chemins entre toutes les paires
Programmation dynamique, par récurrence sur la taille du chemin.
Version naïve :
\begin{algorithmic}
\For
{$
k
=
1
$
to
$
|V|
$}
\For
{$
u
\in
V
$}
\For
{$
w
\rightarrow
v
\in
E
$}
\State
$
\text
{
dist
}^{
k
}
\gets
\min
\begin
{
cases
}
\text
{
dist
}^{
k
-
1
}
(
u, v
)
\\\text
{
dist
}^{
k
-
1
}
(
u, w
)
+
p
(
w, v
)
\end
{
cases
}$
\EndFor
\EndFor
\EndFor
\end{algorithmic}
Variante :
\begin{algorithmic}
\State
$
\text
{
dist
}_
2
^
1
(
u, v
)
=
\begin
{
cases
}
0
&
\textit
{
si
$
u = v
$}
\\
p
(
u, v
)
&
\text
{
si
$
u
\rightarrow
v
\in
E
$}
\\
+
\infty
&
\text
{
sinon
}
\end
{
cases
}$
\For
{$
k
=
2
$
to
$
|V|
$}
\For
{$
u, v
\in
V
$}
\State
$
\text
{
dist
}_
2
^
k
(
u, v
)
=
\min
_{
w
\in
V
}
\begin
{
cases
}
\text
{
dist
}_
2
^{
k
-
1
}
(
u, v
)
\\
\text
{
dist
}_
2
^{
k
-
1
}
(
u, w
)
+
\text
{
dist
}_
2
^{
k
-
1
}
(
w, v
)
\end
{
cases
}$
\EndFor
\EndFor
\end{algorithmic}
Floyd-Warshall : on numérote les sommets de
$
1
$
à
$
n
=
|V|
$
, et pour tout
$
k
\in
\llbracket
0
, n
\rrbracket
$
, on définit :
\begin{align*}
d
^
k(u, v) =
\begin{cases}
\begin{cases}
p(u, v)
&
\text
{
si
$
u
\rightarrow
v
\in
E
$}
\\
+
\infty
&
\text
{
sinon
}
\end{cases}
&
\text
{
si
$
k
=
0
$}
\\
\min
\begin{cases}
d
^{
k-1
}
(u, v)
\\
d
^{
k-1
}
(u, k) + d
^{
k-1
}
(k, v)
\end{cases}
&
\text
{
sinon
}
\end{cases}
\end{align*}
Complexité :
$
O
(
|V|
^
3
)
$
\end{algo}
\begin{algo}
[
$
A
^
*
$
]
\end{algo}
\end{document}
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment