15.082 and 6.855j
DESCRIPTION
15.082 and 6.855J. Breadth First Search. 4. 4. 2. 2. 8. 8. 1. 1. 5. 5. 7. 7. 9. 9. 3. 3. 6. 6. 1. 1. next. Initialize. 1. 1. Unmark all nodes in N; Mark node s. pred(1) = 0 next := 1 order(next) = 1 LIST:= {1}. LIST. 4. 2. 8. 1. 5. 7. 9. 3. 6. 1. - PowerPoint PPT PresentationTRANSCRIPT
Breadth first search animation
2
Initialize
LIST
Unmark all nodes in N;
Mark node s
1
2 4
5
3 6 9
7
8
1
pred(1) = 0
next := 1order(next) = 1
LIST:= {1}
next 1
1
2 4
5
3 6 9
7
8
11
Breadth first search animation
3
Select a node i in LIST
LIST
In breadth first search, i is the first node in LIST
1
2 4
5
3 6 9
7
8
1
1
next 1
1 1
Breadth first search animation
4
If node i is incident to an admissible arc…
LIST
Select an admissible arc (i,j)
1
2 4
5
3 6 9
7
8
1
1
next 12
1 1
Mark Node j
pred(j) := i
2
Next := Next + 1
order(j) := next
add j to LIST
2
2
Breadth first search animation
5
If node i is incident to an admissible arc…
LIST
Select an admissible arc (i,j)
1
2 4
5
3 6 9
7
8
31
1
next 23
1 1
Mark Node j
pred(j) := i
2
Next := Next + 1
order(j) := next
add j to LIST
2
2 5
5
Breadth first search animation
6
4
If node i is incident to an admissible arc…
LIST
Select an admissible arc (i,j)
1
2 4
5
3 6 9
7
8
31
1
next 23
1 1
Mark Node j
pred(j) := i
2
Next := Next + 1
order(j) := next
add j to LIST
2
2 5
5
3
4
3
Breadth first search animation
7
4
If node i is not incident to an admissible arc…
LIST
Delete node i from LIST
1
2 4
5
3 6 9
7
8
31
1
next 23
1 1
22
2 5
5
3
4
3
1
Breadth first search animation
8
4
Select Node i
LIST
The first node on LIST becomes node i
1
2 4
5
3 6 9
7
8
31
1
next 23
1 1
22
2 5
5
3
4
3
1
2
Breadth first search animation
9
5
4
If node i is incident to an admissible arc…
LIST
1
2 4
5
3 6 9
7
8
31
1
next 23
1
22
2 5
5
3
4
3
2
Select an admissible arc (i,j)
Mark Node j
pred(j) := i
Next := Next + 1
order(j) := next
add j to LIST
4
5
4
Breadth first search animation
10
5
4
If node i is not incident to an admissible arc…
LIST
1
2 4
5
3 6 9
7
8
31
1
next 23
1
22
2 5
5
3
4
3
2
Delete node i from LIST
4
5
4
2
Breadth first search animation
11
5
4
Select a node
LIST
1
2 4
5
3 6 9
7
8
31
1
next 23
1
22
2 5
5
3
4
3
2 4
5
4
The first node on LIST becomes node i
5
Breadth first search animation
12
6
5
4
If node i is incident to an admissible arc…
LIST
1
2 4
5
3 6 9
7
8
31
1
next 23
1
22
2 5
5
3
4
3
2 4
5
4
5
Select an admissible arc (i,j)
Mark Node j
pred(j) := i
Next := Next + 1
order(j) := next
add j to LIST
6
6
6
Breadth first search animation
13
6
5
4
If node i is not incident to an admissible arc…
LIST
1
2 4
5
3 6 9
7
8
31
1
next 23
1
22
2 5
5
3
4
3
2 4
5
4
5
6
6
6
Delete node i from LIST
5
Breadth first search animation
14
6
5
4
Select node 3
LIST
1
2 4
5
3 6 9
7
8
31
1
next 23
1
22
2 5
5
3
4
3
2 4
5
4
5
6
6
6
node 3 is not incident to any admissible arcs
5
3delete node 3 from LIST 3
Breadth first search animation
15
6
5
4
Select a node
LIST
1
2 4
5
3 6 9
7
8
31
1
next 23
1
22
2 5
5
3
4
3
4
5
4
6
6
6
i : = 4
4
Breadth first search animation
16
7
6
5
4
If node i is incident to an admissible arc…
LIST
1
2 4
5
3 6 9
7
8
31
1
next 23
1
22
2 5
5
3
4
3
4
5
4
6
6
6
4
Select an admissible arc (i,j)
Mark Node j
pred(j) := i
Next := Next + 1
order(j) := next
add j to LIST
8
7
8
Breadth first search animation
17
7
6
5
4
If node i is not incident to an admissible arc…
LIST
1
2 4
5
3 6 9
7
8
31
1
next 23
1
22
2 5
5
3
4
3
4
5
4
6
6
6
4
Delete node i from LIST
8
7
8
4
Breadth first search animation
18
7
6
5
4
Select node i
LIST
1
2 4
5
3 6 9
7
8
31
1
next 23
1
22
2 5
5
3
4
3
4
5
4
6
6
6
i := 6
8
7
8
6
Breadth first search animation
19
8
7
6
5
4
If node i is incident to an admissible arc…
LIST
1
2 4
5
3 6 9
7
8
31
1
next 23
1
22
2 5
5
3
4
3
4
5
4
6
6
6
8
7
8
6Select an admissible arc (i,j)
Mark Node j
pred(j) := i
Next := Next + 1
order(j) := next
add j to LIST
7
8
7
Breadth first search animation
20
9
8
7
6
5
4
If node i is incident to an admissible arc…
LIST
1
2 4
5
3 6 9
7
8
31
1
next 23
1
22
2 5
5
3
4
3
4
5
4
6
6
6
8
7
8
6Select an admissible arc (i,j)
Mark Node j
pred(j) := i
Next := Next + 1
order(j) := next
add j to LIST
7
8
7
9
9
9
Breadth first search animation
21
9
8
7
6
5
4
If node i is not incident to an admissible arc…
LIST
1
2 4
5
3 6 9
7
8
31
1
next 23
1
22
2 5
5
3
4
3
4
5
4
6
6
6
8
7
8
6Delete node i from LIST
7
8
7
9
9
6
9
Breadth first search animation
22
9
8
7
6
5
4
Select node 8
LIST
1
2 4
5
3 6 9
7
8
31
1
next 23
1
22
2 5
5
3
4
3
4
5
4
6
6
6
8
7
8
6node 8 is not incident to an admissible arc; delete it from LIST
7
8
7
9
9
6
9
88
Breadth first search animation
23
9
8
7
6
5
4
Select node 7
LIST
1
2 4
5
3 6 9
7
8
31
1
next 23
1
22
2 5
5
3
4
3
4
5
4
6
6
6
8
7
8
6node 7 is not incident to an admissible arc; delete it from LIST
7
8
7
9
9
6
9
77
Breadth first search animation
24
9
8
7
6
5
4
Select node 9
LIST
1
2 4
5
3 6 9
7
8
31
1
next 23
1
22
2 5
5
3
4
3
4
5
4
6
6
6
8
7
8
6node 9 is not incident to an admissible arc; delete it from LIST
7
8
7
9
9
6
9
99