1. The shortest-paths problem

  • Distance δ(s, v) : The length of the shortest path from s to v. For example δ(s, c)=2.
  • The problem:
    • Input: A graph G = (V, E) and a source vertex s∈V
    • Question: A shortest path from s to each vertex v ∈V and the distance δ(s, v) .

2. Algorithm

Breadth-First Search 广度优先搜索

  • Some details:

    • White:represented “undiscovered” vertices
    • Gray:represented “discovered” but not “processed” vertices
    • Black:represented “processed” vertices
  • Given a graph G = <V,E>, the BFS return:

    • d[v]:proved to be the shortest distance from s to v
    • π[v]:the predecessor of v in the search, which can be used to derive a shortest path from s to vertex v
    • BFS acturally returns a shortest path tree in which the unique simple path from s to node v is a shortest path from s to v in the original graph.

3. Example of Breadth-First Search

  • vertex s and a graph G
    Breadth-First Search 广度优先搜索

  • step 1: initialization
    Breadth-First Search 广度优先搜索

  • step 2
    Breadth-First Search 广度优先搜索

  • step 3
    Breadth-First Search 广度优先搜索

  • step 4
    Breadth-First Search 广度优先搜索

  • step 5
    Breadth-First Search 广度优先搜索

  • step 6
    Breadth-First Search 广度优先搜索

  • step 7
    Breadth-First Search 广度优先搜索

  • step 8
    Breadth-First Search 广度优先搜索

  • step 9
    Breadth-First Search 广度优先搜索

4. What does BFS produce

Breadth-First Search 广度优先搜索

5. Our goal

Breadth-First Search 广度优先搜索

  • δ(s,v) = d[v]

相关文章:

  • 2021-04-22
  • 2021-04-08
  • 2021-06-08
  • 2022-03-04
  • 2022-12-23
  • 2022-12-23
  • 2022-01-03
猜你喜欢
  • 2022-12-23
  • 2021-10-26
  • 2022-12-23
  • 2021-05-11
  • 2021-10-13
  • 2022-12-23
  • 2021-11-17
相关资源
相似解决方案