13.04.2013 Views

Algoritmos e complexidade Notas de aula - Arquivo Escolar

Algoritmos e complexidade Notas de aula - Arquivo Escolar

Algoritmos e complexidade Notas de aula - Arquivo Escolar

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

7.2. Branch-and-bound<br />

Para um vértice v ∈ V , vamos <strong>de</strong>finir o conjunto <strong>de</strong> cores adjacentes<br />

C(v) := {c(u) | {u, v} ∈ A}.<br />

1 return bt − coloring(1, 1)<br />

2<br />

3 boolean bt − coloring(v, cv) :=<br />

4 i f v > n<br />

5 return true<br />

6<br />

7 i f c ∈ C(v) then { v colorível com cv? }<br />

8 c(v) := cv<br />

9 for cu ∈ [1, 4] do<br />

10 i f bt − coloring(v + 1, cu)<br />

11 return true<br />

12 end for<br />

13 else<br />

14 return f a l s e<br />

15 end i f<br />

16 end<br />

De quantas cores precisamos?<br />

De quantas cores precisamos?<br />

a<br />

b<br />

d<br />

c<br />

e<br />

171

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!