ejemplo bfs
DESCRIPTION
BFSTRANSCRIPT
![Page 1: Ejemplo bfs](https://reader035.vdocuments.co/reader035/viewer/2022081421/55894fddd8b42a08638b4580/html5/thumbnails/1.jpg)
1
búsqueda por anchura en un grafo (BFS)
s
2
5
4
7
8
3 6 9
o Dado un vértice fuente s, Breadth-first search sistemáticamente explora los vértices de G para “descubrir” todos los vértices alcanzables desde s.
o Calcula la distancia (menor número de vértices) desde s a todos los vértices alcanzables.o Después produce un árbol BF con raíz en s y que contiene a todos los vértices alcanzables.o El camino desde s a cada vértice en este recorrido contiene el mínimo número de vértices. Es el camino más
corto medido en número de vértices.o Su nombre se debe a que expande uniformemente la frontera entre lo descubierto y lo no descubierto. Llega a
los nodos de distancia k, sólo tras haber llegado a todos los nodos a distancia k-1.
PROCEDIMIENTO
![Page 2: Ejemplo bfs](https://reader035.vdocuments.co/reader035/viewer/2022081421/55894fddd8b42a08638b4580/html5/thumbnails/2.jpg)
búsqueda por anchura en un grafo (BFS)ALGORITMO
2
![Page 3: Ejemplo bfs](https://reader035.vdocuments.co/reader035/viewer/2022081421/55894fddd8b42a08638b4580/html5/thumbnails/3.jpg)
3
búsqueda por anchura en un grafo (BFS)
s
2
5
4
7
8
3 6 9
0
Undiscovered
Discovered
Finished
cola: s
Top of queue
2
1la ruta más corta
desde s
![Page 4: Ejemplo bfs](https://reader035.vdocuments.co/reader035/viewer/2022081421/55894fddd8b42a08638b4580/html5/thumbnails/4.jpg)
4
búsqueda por anchura en un grafo (BFS)
s
2
5
4
7
8
3 6 9
0
Undiscovered
Discovered
Finished
cola: s 2
Top of queue
3
1
1
![Page 5: Ejemplo bfs](https://reader035.vdocuments.co/reader035/viewer/2022081421/55894fddd8b42a08638b4580/html5/thumbnails/5.jpg)
5
búsqueda por anchura en un grafo (BFS)
s
2
5
4
7
8
3 6 9
0
Undiscovered
Discovered
Finished
cola: s 2 3
Top of queue
5
1
1
1
![Page 6: Ejemplo bfs](https://reader035.vdocuments.co/reader035/viewer/2022081421/55894fddd8b42a08638b4580/html5/thumbnails/6.jpg)
6
búsqueda por anchura en un grafo (BFS)
s
2
5
4
7
8
3 6 9
0
Undiscovered
Discovered
Finished
cola: 2 3 5
Top of queue
1
1
1
![Page 7: Ejemplo bfs](https://reader035.vdocuments.co/reader035/viewer/2022081421/55894fddd8b42a08638b4580/html5/thumbnails/7.jpg)
7
búsqueda por anchura en un grafo (BFS)
s
2
5
4
7
8
3 6 9
0
Undiscovered
Discovered
Finished
cola: 2 3 5
Top of queue
4
1
1
1
2
![Page 8: Ejemplo bfs](https://reader035.vdocuments.co/reader035/viewer/2022081421/55894fddd8b42a08638b4580/html5/thumbnails/8.jpg)
8
búsqueda por anchura en un grafo (BFS)
s
2
5
4
7
8
3 6 9
0
Undiscovered
Discovered
Finished
cola : 2 3 5 4
Top of queue
1
1
1
2
5 ya ha sido descubierto: no poner en cola
![Page 9: Ejemplo bfs](https://reader035.vdocuments.co/reader035/viewer/2022081421/55894fddd8b42a08638b4580/html5/thumbnails/9.jpg)
9
búsqueda por anchura en un grafo (BFS)
s
2
5
4
7
8
3 6 9
0
Undiscovered
Discovered
Finished
cola : 2 3 5 4
Top of queue
1
1
1
2
![Page 10: Ejemplo bfs](https://reader035.vdocuments.co/reader035/viewer/2022081421/55894fddd8b42a08638b4580/html5/thumbnails/10.jpg)
10
búsqueda por anchura en un grafo (BFS)
s
2
5
4
7
8
3 6 9
0
Undiscovered
Discovered
Finished
cola : 3 5 4
Top of queue
1
1
1
2
![Page 11: Ejemplo bfs](https://reader035.vdocuments.co/reader035/viewer/2022081421/55894fddd8b42a08638b4580/html5/thumbnails/11.jpg)
11
búsqueda por anchura en un grafo (BFS)
s
2
5
4
7
8
3 6 9
0
Undiscovered
Discovered
Finished
cola : 3 5 4
Top of queue
1
1
1
2
6
2
![Page 12: Ejemplo bfs](https://reader035.vdocuments.co/reader035/viewer/2022081421/55894fddd8b42a08638b4580/html5/thumbnails/12.jpg)
12
búsqueda por anchura en un grafo (BFS)
s
2
5
4
7
8
3 6 9
0
Undiscovered
Discovered
Finished
cola : 3 5 4 6
Top of queue
1
1
1
2
2
![Page 13: Ejemplo bfs](https://reader035.vdocuments.co/reader035/viewer/2022081421/55894fddd8b42a08638b4580/html5/thumbnails/13.jpg)
13
búsqueda por anchura en un grafo (BFS)
s
2
5
4
7
8
3 6 9
0
Undiscovered
Discovered
Finished
cola : 5 4 6
Top of queue
1
1
1
2
2
![Page 14: Ejemplo bfs](https://reader035.vdocuments.co/reader035/viewer/2022081421/55894fddd8b42a08638b4580/html5/thumbnails/14.jpg)
14
búsqueda por anchura en un grafo (BFS)
s
2
5
4
7
8
3 6 9
0
Undiscovered
Discovered
Finished
cola : 5 4 6
Top of queue
1
1
1
2
2
![Page 15: Ejemplo bfs](https://reader035.vdocuments.co/reader035/viewer/2022081421/55894fddd8b42a08638b4580/html5/thumbnails/15.jpg)
15
búsqueda por anchura en un grafo (BFS)
s
2
5
4
7
8
3 6 9
0
Undiscovered
Discovered
Finished
cola : 4 6
Top of queue
1
1
1
2
2
![Page 16: Ejemplo bfs](https://reader035.vdocuments.co/reader035/viewer/2022081421/55894fddd8b42a08638b4580/html5/thumbnails/16.jpg)
16
búsqueda por anchura en un grafo (BFS)
s
2
5
4
7
8
3 6 9
0
Undiscovered
Discovered
Finished
cola : 4 6
Top of queue
1
1
1
2
2
8
3
![Page 17: Ejemplo bfs](https://reader035.vdocuments.co/reader035/viewer/2022081421/55894fddd8b42a08638b4580/html5/thumbnails/17.jpg)
17
búsqueda por anchura en un grafo (BFS)
s
2
5
4
7
8
3 6 9
0
Undiscovered
Discovered
Finished
cola : 4 6 8
Top of queue
1
1
1
2
2
3
![Page 18: Ejemplo bfs](https://reader035.vdocuments.co/reader035/viewer/2022081421/55894fddd8b42a08638b4580/html5/thumbnails/18.jpg)
18
búsqueda por anchura en un grafo (BFS)
s
2
5
4
7
8
3 6 9
0
Undiscovered
Discovered
Finished
cola : 6 8
Top of queue
1
1
1
2
2
3
7
3
![Page 19: Ejemplo bfs](https://reader035.vdocuments.co/reader035/viewer/2022081421/55894fddd8b42a08638b4580/html5/thumbnails/19.jpg)
19
búsqueda por anchura en un grafo (BFS)
s
2
5
4
7
8
3 6 9
0
Undiscovered
Discovered
Finished
cola : 6 8 7
Top of queue
1
1
1
2
2
3
9
3
3
![Page 20: Ejemplo bfs](https://reader035.vdocuments.co/reader035/viewer/2022081421/55894fddd8b42a08638b4580/html5/thumbnails/20.jpg)
20
búsqueda por anchura en un grafo (BFS)
s
2
5
4
7
8
3 6 9
0
Undiscovered
Discovered
Finished
cola : 6 8 7 9
Top of queue
1
1
1
2
2
3
3
3
![Page 21: Ejemplo bfs](https://reader035.vdocuments.co/reader035/viewer/2022081421/55894fddd8b42a08638b4580/html5/thumbnails/21.jpg)
21
búsqueda por anchura en un grafo (BFS)
s
2
5
4
7
8
3 6 9
0
Undiscovered
Discovered
Finished
cola : 8 7 9
Top of queue
1
1
1
2
2
3
3
3
![Page 22: Ejemplo bfs](https://reader035.vdocuments.co/reader035/viewer/2022081421/55894fddd8b42a08638b4580/html5/thumbnails/22.jpg)
22
búsqueda por anchura en un grafo (BFS)
s
2
5
4
7
8
3 6 9
0
Undiscovered
Discovered
Finished
cola : 7 9
Top of queue
1
1
1
2
2
3
3
3
![Page 23: Ejemplo bfs](https://reader035.vdocuments.co/reader035/viewer/2022081421/55894fddd8b42a08638b4580/html5/thumbnails/23.jpg)
23
búsqueda por anchura en un grafo (BFS)
s
2
5
4
7
8
3 6 9
0
Undiscovered
Discovered
Finished
cola : 7 9
Top of queue
1
1
1
2
2
3
3
3
![Page 24: Ejemplo bfs](https://reader035.vdocuments.co/reader035/viewer/2022081421/55894fddd8b42a08638b4580/html5/thumbnails/24.jpg)
24
búsqueda por anchura en un grafo (BFS)
s
2
5
4
7
8
3 6 9
0
Undiscovered
Discovered
Finished
cola : 7 9
Top of queue
1
1
1
2
2
3
3
3
![Page 25: Ejemplo bfs](https://reader035.vdocuments.co/reader035/viewer/2022081421/55894fddd8b42a08638b4580/html5/thumbnails/25.jpg)
25
búsqueda por anchura en un grafo (BFS)
s
2
5
4
7
8
3 6 9
0
Undiscovered
Discovered
Finished
cola : 7 9
Top of queue
1
1
1
2
2
3
3
3
![Page 26: Ejemplo bfs](https://reader035.vdocuments.co/reader035/viewer/2022081421/55894fddd8b42a08638b4580/html5/thumbnails/26.jpg)
26
búsqueda por anchura en un grafo (BFS)
s
2
5
4
7
8
3 6 9
0
Undiscovered
Discovered
Finished
cola : 9
Top of queue
1
1
1
2
2
3
3
3
![Page 27: Ejemplo bfs](https://reader035.vdocuments.co/reader035/viewer/2022081421/55894fddd8b42a08638b4580/html5/thumbnails/27.jpg)
27
búsqueda por anchura en un grafo (BFS)
s
2
5
4
7
8
3 6 9
0
Undiscovered
Discovered
Finished
cola : 9
Top of queue
1
1
1
2
2
3
3
3
![Page 28: Ejemplo bfs](https://reader035.vdocuments.co/reader035/viewer/2022081421/55894fddd8b42a08638b4580/html5/thumbnails/28.jpg)
28
búsqueda por anchura en un grafo (BFS)
s
2
5
4
7
8
3 6 9
0
Undiscovered
Discovered
Finished
cola : 9
Top of queue
1
1
1
2
2
3
3
3
![Page 29: Ejemplo bfs](https://reader035.vdocuments.co/reader035/viewer/2022081421/55894fddd8b42a08638b4580/html5/thumbnails/29.jpg)
29
búsqueda por anchura en un grafo (BFS)
s
2
5
4
7
8
3 6 9
0
Undiscovered
Discovered
Finished
cola :
Top of queue
1
1
1
2
2
3
3
3
![Page 30: Ejemplo bfs](https://reader035.vdocuments.co/reader035/viewer/2022081421/55894fddd8b42a08638b4580/html5/thumbnails/30.jpg)
30
búsqueda por anchura en un grafo (BFS)
s
2
5
4
7
8
3 6 9
0
Nivel Gráfico
1
1
1
2
2
3
3
3