A* Demo, with s = 0, goal = 6.
Insert all vertices into fringe PQ, storing vertices in order of d(source, v) + h(v, goal).
Repeat: Remove best vertex v from PQ, and relax all edges pointing from v.
1
2
3
4
5
6
0
s
# distTo edgeTo
0 0 -
1 ∞ -
2 ∞ -
3 ∞ -
4 ∞ -
5 ∞ -
6 ∞ -
5
2
1
15
3
2
11
5
1
1
Fringe: [(1: ∞), (2: ∞), (3: ∞), (4: ∞), (5: ∞), (6: ∞)]
4
0
∞
∞
∞
∞
∞
∞
1
h(v, goal)
1
3
15
1
1
∞
0
h(v, goal) is arbitrary. In this example, it’s the min weight edge out of each vertex.
A* Demo, with s = 0, goal = 6.
Insert all vertices into fringe PQ, storing vertices in order of d(source, v) + h(v, goal).
Repeat: Remove best vertex v from PQ, and relax all edges pointing from v.
1
2
3
4
5
6
0
s
# distTo edgeTo
0 0 -
1 2 0
2 1 0
3 ∞ -
4 ∞ -
5 ∞ -
6 ∞ -
5
2
1
15
3
2
11
5
1
1
Fringe: [(1: 5), (2: 16), (3: ∞), (4: ∞), (5: ∞), (6: ∞)]
4
0
∞
∞
∞
∞
∞
∞
1
2
1
h(v, goal)
1
3
15
1
1
∞
0
A* Demo, with s = 0, goal = 6.
Insert all vertices into fringe PQ, storing vertices in order of d(source, v) + h(v, goal).
Repeat: Remove best vertex v from PQ, and relax all edges pointing from v.
1
2
3
4
5
6
0
s
# distTo edgeTo
0 0 -
1 2 0
2 1 0
3 ∞ -
4 ∞ -
5 ∞ -
6 ∞ -
5
2
1
15
3
2
11
5
1
1
Fringe: [(2: 16), (3: ∞), (4: ∞), (5: ∞), (6: ∞)]
4
0
∞
∞
∞
∞
1
h(v, goal)
1
3
15
2
1
∞
0
1
2
A* Demo, with s = 0, goal = 6.
Insert all vertices into fringe PQ, storing vertices in order of d(source, v) + h(v, goal).
Repeat: Remove best vertex v from PQ, and relax all edges pointing from v.
1
2
3
4
5
6
0
s
# distTo edgeTo
0 0 -
1 2 0
2 1 0
3 13 1
4 5 1
5 ∞ -
6 ∞ -
5
2
1
15
3
2
11
5
1
1
Fringe: [(4: 6), (3: 15), (2: 16), (5: ∞), (6: ∞)]
4
0
∞
∞
∞
∞
1
h(v, goal)
1
3
15
2
1
∞
0
1
2
5
13
Which vertex is removed next?
A* Demo, with s = 0, goal = 6.
Insert all vertices into fringe PQ, storing vertices in order of d(source, v) + h(v, goal).
Repeat: Remove best vertex v from PQ, and relax all edges pointing from v.
1
2
3
4
5
6
0
s
# distTo edgeTo
0 0 -
1 2 0
2 1 0
3 13 1
4 5 1
5 ∞ -
6 ∞ -
5
2
1
15
3
2
11
5
1
1
Fringe: [(3: 15), (2: 16), (5: ∞), (6: ∞)]
4
0
∞
∞
1
h(v, goal)
1
3
15
2
1
∞
0
1
2
5
13
A* Demo, with s = 0, goal = 6.
Insert all vertices into fringe PQ, storing vertices in order of d(source, v) + h(v, goal).
Repeat: Remove best vertex v from PQ, and relax all edges pointing from v.
1
2
3
4
5
6
0
s
# distTo edgeTo
0 0 -
1 2 0
2 1 0
3 13 1
4 5 1
5 9 4
6 10 4
5
2
1
15
3
2
11
5
1
1
Fringe: [(6: 10), (3: 15), (2: 16), (5: ∞)]
4
0
∞
∞
1
h(v, goal)
1
3
15
2
1
∞
0
1
2
5
13
10
9
A* Demo, with s = 0, goal = 6.
Insert all vertices into fringe PQ, storing vertices in order of d(source, v) + h(v, goal).
Repeat: Remove best vertex v from PQ, and relax all edges pointing from v.
1
2
3
4
5
6
0
s
# distTo edgeTo
0 0 -
1 2 0
2 1 0
3 13 1
4 5 1
5 9 4
6 10 4
5
2
1
15
3
2
11
5
1
1
Fringe: [(6: 10), (3: 15), (2: 16), (5: ∞)]
4
0
1
h(v, goal)
1
3
15
2
1
∞
0
1
2
5
13
10
9
Next vertex to be dequeued is our target, so we’re done!
A* Demo, with s = 0, goal = 6.
Insert all vertices into fringe PQ, storing vertices in order of d(source, v) + h(v, goal).
Repeat: Remove best vertex v from PQ, and relax all edges pointing from v.
1
2
3
4
5
6
0
s
# distTo edgeTo
0 0 -
1 2 0
2 1 0
3 13 1
4 5 1
5 9 4
6 10 4
5
2
1
15
3
2
11
5
1
1
4
0
1
h(v, goal)
1
3
15
2
1
∞
0
1
2
5
13
10
9
Observations: