Skip to content
Snippets Groups Projects
Verified Commit 6b1983d0 authored by orestis.malaspin's avatar orestis.malaspin
Browse files

ajout début liste d'adjacence

parent 3b23eb2a
No related branches found
No related tags found
No related merge requests found
......@@ -336,13 +336,193 @@ graph LR;
:::: column
## Quelle est la matrice d'adjacence (1min)?
\footnotesize
## Quelle matrice d'adjacence?
. . .
```
|| 1 | 2 | 3 | 4 | 5
===||===|===|===|===|===
1 || 0 | 1 | 0 | 1 | 0
---||---|---|---|---|---
2 || 1 | 0 | 0 | 0 | 1
---||---|---|---|---|---
3 || 0 | 0 | 0 | 0 | 1
---||---|---|---|---|---
4 || 1 | 0 | 0 | 0 | 1
---||---|---|---|---|---
5 || 0 | 1 | 1 | 1 | 0
```
::::
:::
# Matrice d'adjacence
## Remarques
* Zéro sur la diagonale.
* La matrice d'un graphe non-orienté est symétrique
$$
A_{ij}=A_{ji}, \forall i,j\in[1,n]
$$.
::: columns
:::: column
```{.mermaid format=pdf width=400 loc=figs/}
graph LR;
1---2;
1---4;
2---5;
4---5;
5---3;
```
::::
:::: column
\footnotesize
```
|| 1 | 2 | 3 | 4 | 5
===||===|===|===|===|===
1 || 0 | 1 | 0 | 1 | 0
---||---|---|---|---|---
2 || 1 | 0 | 0 | 0 | 1
---||---|---|---|---|---
3 || 0 | 0 | 0 | 0 | 1
---||---|---|---|---|---
4 || 1 | 0 | 0 | 0 | 1
---||---|---|---|---|---
5 || 0 | 1 | 1 | 1 | 0
```
::::
:::
# Matrice d'adjacence
* Pour un graphe orienté (digraphe)
::: columns
:::: column
## Exemple
```{.mermaid format=pdf width=400 loc=figs/}
graph LR;
2-->1;
1-->4;
2-->5;
5-->2;
4-->5;
5-->3;
```
::::
:::: column
\footnotesize
## Quelle matrice d'adjacence?
. . .
```
|| 1 | 2 | 3 | 4 | 5
===||===|===|===|===|===
1 || 0 | 0 | 0 | 1 | 0
---||---|---|---|---|---
2 || 1 | 0 | 0 | 0 | 1
---||---|---|---|---|---
3 || 0 | 0 | 0 | 0 | 0
---||---|---|---|---|---
4 || 0 | 0 | 0 | 0 | 1
---||---|---|---|---|---
5 || 0 | 1 | 1 | 0 | 0
```
::::
:::
* La matrice d'adjacence n'est plus forcément diagonale
$$
A_{ij}\neq A_{ji}.
$$
# Stockage
* Quel est l'espace nécessaire pour stocker une matrice d'adjacence pour un graphe orienté?
. . .
* $\mathcal{O}(|V|^2)$.
* Quel est l'espace nécessaire pour stocker une matrice d'adjacence pour un graphe non-orienté?
. . .
* $\mathcal{O}(|V|-1)|V|/2$.
# Considérations d'efficacité
* Dans quel type de graphes la matrice d'adjacence est utile?
. . .
* Dans les graphes denses.
* Pourquoi?
. . .
* Dans les graphes peu denses, la matrice d'adjacence est essentiellement composée de `0`.
## Remarque
* Dans la majorité des cas, les grands graphes sont peu denses.
* Comment représenter un graphe autrement?
# La liste d'adjacence
* Pour chaque sommet $v\in V$, stocker les sommets adjacents à $v$-
* Quelle structure de données pour la liste d'adjacence?
. . .
* Tableau de liste chaînée, vecteur (tableau dynamique), etc.
::: columns
:::: column
## Exemple
![Un graphe non-orienté.](figs/ex_graph_adj.pdf){width=80%}
::::
:::: column
## Quelle liste d'adjacence?
. . .
![La liste d'adjacence.](figs/ex_graph_list_adj.pdf)
::::
:::
File added
File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment