Contenido del Curso
Breadth First Search
Breadth First Search
Restoring Shortest Path
BFS searching shortest path
That was hard! But now let's implement a method to find the shortest path between two vertices, not only length.
To do that, you have to know for each node where did it come from. So, let's add list pred
that contains predcessor for i
node. At the beginning, pred
contains only -1
.
Tarea
Modify bfs(start, end)
so it returns a list of vertices between start
and end
nodes (both inclusive). If there is no path, return an empty list.
Do not forget to keep the path.
Tarea
Modify bfs(start, end)
so it returns a list of vertices between start
and end
nodes (both inclusive). If there is no path, return an empty list.
Do not forget to keep the path.
¿Todo estuvo claro?
Restoring Shortest Path
BFS searching shortest path
That was hard! But now let's implement a method to find the shortest path between two vertices, not only length.
To do that, you have to know for each node where did it come from. So, let's add list pred
that contains predcessor for i
node. At the beginning, pred
contains only -1
.
Tarea
Modify bfs(start, end)
so it returns a list of vertices between start
and end
nodes (both inclusive). If there is no path, return an empty list.
Do not forget to keep the path.
Tarea
Modify bfs(start, end)
so it returns a list of vertices between start
and end
nodes (both inclusive). If there is no path, return an empty list.
Do not forget to keep the path.
¿Todo estuvo claro?
Restoring Shortest Path
BFS searching shortest path
That was hard! But now let's implement a method to find the shortest path between two vertices, not only length.
To do that, you have to know for each node where did it come from. So, let's add list pred
that contains predcessor for i
node. At the beginning, pred
contains only -1
.
Tarea
Modify bfs(start, end)
so it returns a list of vertices between start
and end
nodes (both inclusive). If there is no path, return an empty list.
Do not forget to keep the path.
Tarea
Modify bfs(start, end)
so it returns a list of vertices between start
and end
nodes (both inclusive). If there is no path, return an empty list.
Do not forget to keep the path.
¿Todo estuvo claro?
BFS searching shortest path
That was hard! But now let's implement a method to find the shortest path between two vertices, not only length.
To do that, you have to know for each node where did it come from. So, let's add list pred
that contains predcessor for i
node. At the beginning, pred
contains only -1
.
Tarea
Modify bfs(start, end)
so it returns a list of vertices between start
and end
nodes (both inclusive). If there is no path, return an empty list.
Do not forget to keep the path.