fall 2006ee 5301 - vlsi design automation i 1 depth-first search algorithm acdeb b · c · d · e ·...

45
Fall 2006 EE 5301 - VLSI Design Automat ion I 1 Depth-First Search Algorithm a c d e b b · c · d · e · a · b · d · c · a · d · a · e · b · b · a · d · dfs(“a”) .... a dfs ( a ) a.marked 1 print a for each (a, u) E if (u.mark != 1) dfs (u)

Post on 20-Dec-2015

214 views

Category:

Documents


0 download

TRANSCRIPT

Fall 2006 EE 5301 - VLSI Design Automation I 1

Depth-First Search Algorithm

a

c

de b

b ·

c ·

d ·

e ·

a · b · d · c ·

a · d ·

a ·

e · b ·

b ·

a ·

d ·

dfs(“a”) ....dfs(“a”) ....

a

dfs ( a ) a.marked 1 print a for each (a, u) E if (u.mark != 1) dfs (u)

Fall 2006 EE 5301 - VLSI Design Automation I 2

Depth-First Search Algorithm

dfs ( a ) a.marked 1 print a for each (a, u) E if (b.mark != 1) dfs (b)

a

c

de b

b ·

c ·

d ·

e ·

a · b · d · c ·

a · d ·

a ·

e · b ·

b ·

a ·

d ·

dfs(“a”) ....dfs(“a”) ....

a

dfs(“b”) ....

dfs(“b”) ....u=b

Fall 2006 EE 5301 - VLSI Design Automation I 3

Depth-First Search Algorithm

dfs ( b ) b.marked 1 print b for each (b, u) E if (u.mark != 1) dfs (u)

a

c

de b

b ·

c ·

d ·

e ·

a · b · d · c ·

a · d ·

a ·

e · b ·

b ·

a ·

d ·

a b

dfs(“a”) ....dfs(“a”) ....

dfs(“b”) ....

dfs(“b”) ....

Fall 2006 EE 5301 - VLSI Design Automation I 4

Depth-First Search Algorithm

dfs ( b ) b.marked 1 print b for each (b, u) E if (a.mark != 1) dfs (a)

a

c

de b

b ·

c ·

d ·

e ·

a · b · d · c ·

a · d ·

a ·

e · b ·

b ·

a ·

d ·

a b

dfs(“a”) ....dfs(“a”) ....

dfs(“b”) ....

dfs(“b”) ....u=a

Fall 2006 EE 5301 - VLSI Design Automation I 5

Depth-First Search Algorithm

dfs ( b ) b.marked 1 print b for each (b, u) E if (d.mark != 1) dfs (d)

a

c

de b

b ·

c ·

d ·

e ·

a · b · d · c ·

a · d ·

a ·

e · b ·

b ·

a ·

d ·

a b

dfs(“a”) ....dfs(“a”) ....

dfs(“b”) ....

dfs(“b”) ....

dfs(“d”) ....

dfs(“d”) ....

u=d

Fall 2006 EE 5301 - VLSI Design Automation I 6

Depth-First Search Algorithm

dfs ( d ) d.marked 1 print d for each (d, u) E if (u.mark != 1) dfs (u)

a

c

de b

b ·

c ·

d ·

e ·

a · b · d · c ·

a · d ·

a ·

e · b ·

b ·

a ·

d ·

a b d

dfs(“a”) ....dfs(“a”) ....

dfs(“b”) ....

dfs(“b”) ....

dfs(“d”) ....

dfs(“d”) ....

Fall 2006 EE 5301 - VLSI Design Automation I 7

Depth-First Search Algorithm

dfs ( d ) d.marked 1 print d for each (d, u) E if (e.mark != 1) dfs (e)

a

c

de b

b ·

c ·

d ·

e ·

a · b · d · c ·

a · d ·

a ·

e · b ·

b ·

a ·

d ·

a b d

dfs(“a”) ....dfs(“a”) ....

dfs(“b”) ....

dfs(“b”) ....

dfs(“d”) ....

dfs(“d”) ....

dfs(“e”) ....

dfs(“e”) ....

u=e

Fall 2006 EE 5301 - VLSI Design Automation I 8

Depth-First Search Algorithm

dfs ( e ) e.marked 1 print e for each (e, u) E if (u.mark != 1) dfs (u)

a

c

de b

b ·

c ·

d ·

e ·

a · b · d · c ·

a · d ·

a ·

e · b ·

b ·

a ·

d ·

a b d e

dfs(“a”) ....dfs(“a”) ....

dfs(“b”) ....

dfs(“b”) ....

dfs(“d”) ....

dfs(“d”) ....

dfs(“e”) ....

dfs(“e”) ....

Fall 2006 EE 5301 - VLSI Design Automation I 9

Depth-First Search Algorithm

dfs ( e ) e.marked 1 print e for each (e, u) E if (d.mark != 1) dfs (u)

a

c

de b

b ·

c ·

d ·

e ·

a · b · d · c ·

a · d ·

a ·

e · b ·

b ·

a ·

d ·

a b d e

dfs(“a”) ....dfs(“a”) ....

dfs(“b”) ....

dfs(“b”) ....

dfs(“d”) ....

dfs(“d”) ....

dfs(“e”) ....

dfs(“e”) ....

u=d

Fall 2006 EE 5301 - VLSI Design Automation I 10

Depth-First Search Algorithm

dfs ( e ) e.marked 1 print e for each (e, u) E if (u.mark != 1) dfs (u)

a

c

de b

b ·

c ·

d ·

e ·

a · b · d · c ·

a · d ·

a ·

e · b ·

b ·

a ·

d ·

a b d e

dfs(“a”) ....dfs(“a”) ....

dfs(“b”) ....

dfs(“b”) ....

dfs(“d”) ....

dfs(“d”) ....

dfs(“e”) ....

dfs(“e”) ....

Fall 2006 EE 5301 - VLSI Design Automation I 11

Depth-First Search Algorithm

dfs ( d ) d.marked 1 print d for each (d, u) E if (b.mark != 1) dfs (b)

a

c

de b

b ·

c ·

d ·

e ·

a · b · d · c ·

a · d ·

a ·

e · b ·

b ·

a ·

d ·

a b d e

dfs(“a”) ....dfs(“a”) ....

dfs(“b”) ....

dfs(“b”) ....

dfs(“d”) ....

dfs(“d”) ....

u=b,a

Fall 2006 EE 5301 - VLSI Design Automation I 12

Depth-First Search Algorithm

dfs ( d ) d.marked 1 print d for each (d, u) E if (u.mark != 1) dfs (u)

a

c

de b

b ·

c ·

d ·

e ·

a · b · d · c ·

a · d ·

a ·

e · b ·

b ·

a ·

d ·

a b d e

dfs(“a”) ....dfs(“a”) ....

dfs(“b”) ....

dfs(“b”) ....

dfs(“d”) ....

dfs(“d”) ....

Fall 2006 EE 5301 - VLSI Design Automation I 13

Depth-First Search Algorithm

dfs ( b ) b.marked 1 print b for each (b, u) E if (u.mark != 1) dfs (u)

a

c

de b

b ·

c ·

d ·

e ·

a · b · d · c ·

a · d ·

a ·

e · b ·

b ·

a ·

d ·

a b d e

dfs(“a”) ....dfs(“a”) ....

dfs(“b”) ....

dfs(“b”) ....

Fall 2006 EE 5301 - VLSI Design Automation I 14

Depth-First Search Algorithm

dfs ( a ) a.marked 1 print a for each (a, u) E if (d.mark != 1) dfs (d)

a

c

de b

b ·

c ·

d ·

e ·

a · b · d · c ·

a · d ·

a ·

e · b ·

b ·

a ·

d ·

a b d e

dfs(“a”) ....dfs(“a”) ....

u=d

Fall 2006 EE 5301 - VLSI Design Automation I 15

Depth-First Search Algorithm

dfs ( a ) a.marked 1 print a for each (a, u) E if (c.mark != 1) dfs (c)

a

c

de b

b ·

c ·

d ·

e ·

a · b · d · c ·

a · d ·

a ·

e · b ·

b ·

a ·

d ·

a b d e

dfs(“a”) ....dfs(“a”) ....

u=cdfs(“c”) ....

dfs(“c”) ....

Fall 2006 EE 5301 - VLSI Design Automation I 16

Depth-First Search Algorithm

dfs ( c ) c.marked 1 print c for each (c, u) E if (u.mark != 1) dfs (u)

a

c

de b

b ·

c ·

d ·

e ·

a · b · d · c ·

a · d ·

a ·

e · b ·

b ·

a ·

d ·

a b d e c

dfs(“a”) ....dfs(“a”) ....

dfs(“c”) ....

dfs(“c”) ....

Fall 2006 EE 5301 - VLSI Design Automation I 17

Depth-First Search Algorithm

dfs ( c ) c.marked 1 print c for each (c, u) E if (a.mark != 1) dfs (a)

a

c

de b

b ·

c ·

d ·

e ·

a · b · d · c ·

a · d ·

a ·

e · b ·

b ·

a ·

d ·

a b d e c

dfs(“a”) ....dfs(“a”) ....

dfs(“c”) ....

dfs(“c”) ....u=a

Fall 2006 EE 5301 - VLSI Design Automation I 18

Depth-First Search Algorithm

dfs ( c ) c.marked 1 print c for each (c, u) E if (u.mark != 1) dfs (u)

a

c

de b

b ·

c ·

d ·

e ·

a · b · d · c ·

a · d ·

a ·

e · b ·

b ·

a ·

d ·

a b d e c

dfs(“a”) ....dfs(“a”) ....

dfs(“c”) ....

dfs(“c”) ....

Fall 2006 EE 5301 - VLSI Design Automation I 19

Depth-First Search Algorithm

dfs ( a ) a.marked 1 print a for each (a, u) E if (u.mark != 1) dfs (u)

a

c

de b

b ·

c ·

d ·

e ·

a · b · d · c ·

a · d ·

a ·

e · b ·

b ·

a ·

d ·

a b d e c

dfs(“a”) ....dfs(“a”) ....

Fall 2006 EE 5301 - VLSI Design Automation I 20

Dijkstra’s Algorithm - an example

0

v1

v6

v2

v3

v4

v7

v5

u0 8

1613

10

6

11

14

17

5

7

9

Edges examined

Fall 2006 EE 5301 - VLSI Design Automation I 21

Dijkstra’s Algorithm - an example

0

13

16

8v1

v6

v2

v3

v4

v7

v5

u0 8

1613

10

6

11

14

17

5

7

9

updated, min picked

Fall 2006 EE 5301 - VLSI Design Automation I 22

Dijkstra’s Algorithm - an example

0

13

16

8v1

v6

v2

v3

v4

v7

v5

u0 8

1613

10

6

11

14

17

5

7

9

S Augmented

Fall 2006 EE 5301 - VLSI Design Automation I 23

Dijkstra’s Algorithm - an example

0

13

16

8v1

v6

v2

v3

v4

v7

v5

u0 8

1613

10

6

11

14

17

5

7

9

Edges examined

Fall 2006 EE 5301 - VLSI Design Automation I 24

Dijkstra’s Algorithm - an example

0

18

13

25

15

8v1

v6

v2

v3

v4

v7

v5

u0 8

1613

10

6

11

14

17

5

7

9

updated, min picked

Fall 2006 EE 5301 - VLSI Design Automation I 25

Dijkstra’s Algorithm - an example

0

18

13

25

15

8v1

v6

v2

v3

v4

v7

v5

u0 8

1613

10

6

11

14

17

5

7

9

S Augmented

Fall 2006 EE 5301 - VLSI Design Automation I 26

Dijkstra’s Algorithm - an example

0

18

13

25

15

8v1

v6

v2

v3

v4

v7

v5

u0 8

1613

10

6

11

14

17

5

7

9

Edges examined

Fall 2006 EE 5301 - VLSI Design Automation I 27

Dijkstra’s Algorithm - an example

0

18

13

25

15

8v1

v6

v2

v3

v4

v7

v5

u0 8

1613

10

6

11

14

17

5

7

9

updated, min picked

Fall 2006 EE 5301 - VLSI Design Automation I 28

Dijkstra’s Algorithm - an example

0

18

13

25

15

8v1

v6

v2

v3

v4

v7

v5

u0 8

1613

10

6

11

14

17

5

7

9

S augmented

Fall 2006 EE 5301 - VLSI Design Automation I 29

Dijkstra’s Algorithm - an example

0

18

13

25

15

8v1

v6

v2

v3

v4

v7

v5

u0 8

1613

10

6

11

14

17

5

7

9

Edges examined

Fall 2006 EE 5301 - VLSI Design Automation I 30

Dijkstra’s Algorithm - an example

0

18

13

20

15

8v1

v6

v2

v3

v4

v7

v5

u0 8

1613

10

6

11

14

17

5

7

9

updated, min picked

Fall 2006 EE 5301 - VLSI Design Automation I 31

Dijkstra’s Algorithm - an example

0

18

13

20

15

8v1

v6

v2

v3

v4

v7

v5

u0 8

1613

10

6

11

14

17

5

7

9

S augmented

Fall 2006 EE 5301 - VLSI Design Automation I 32

Dijkstra’s Algorithm - an example

0

18

13

20

15

8v1

v6

v2

v3

v4

v7

v5

u0 8

1613

10

6

11

14

17

5

7

9

Edges examined

Fall 2006 EE 5301 - VLSI Design Automation I 33

Dijkstra’s Algorithm - an example

0

18

13

20

15

8v1

v6

v2

v3

v4

v7

v5

u0 8

1613

10

6

11

14

17

5

7

9

updated, min picked

Fall 2006 EE 5301 - VLSI Design Automation I 34

Dijkstra’s Algorithm - an example

0

18

13

20

15

8v1

v6

v2

v3

v4

v7

v5

u0 8

1613

10

6

11

14

17

5

7

9

S augmented

Fall 2006 EE 5301 - VLSI Design Automation I 35

Prim’s Algorithm Example

v1

v2

v3

v4

v5

S = {v1}

Node v1 v2 v3 v4 v5 - 2 4 3 - v1 v1 v1 -

2

4

31

1

2

3

25

Fall 2006 EE 5301 - VLSI Design Automation I 36

Prim’s Algorithm Example

v1

v2

v3

v4

v5

S = {v1}

Node v1 v2 v3 v4 v5 - 2 4 3 - v1 v1 v1 -

2

4

31

1

2

3

25

Fall 2006 EE 5301 - VLSI Design Automation I 37

Prim’s Algorithm Example

v1

v2

v3

v4

v5

S = {v1, v2}

Node v1 v2 v3 v4 v5 - 2 4 3 - v1 v1 v1 -

2

4

31

1

2

3

25

Fall 2006 EE 5301 - VLSI Design Automation I 38

Prim’s Algorithm Example

v1

v2

v3

v4

v5

S = {v1, v2}

Node v1 v2 v3 v4 v5 - 2 1 2 5

- v1 v2 v2 v2

2

4

31

1

2

3

25

Fall 2006 EE 5301 - VLSI Design Automation I 39

Prim’s Algorithm Example

v1

v2

v3

v4

v5

S = {v1, v2}

Node v1 v2 v3 v4 v5 - 2 1 2 5

- v1 v2 v2 v2

2

4

31

1

2

3

25

Fall 2006 EE 5301 - VLSI Design Automation I 40

Prim’s Algorithm Example

v1

v2

v3

v4

v5

S = {v1, v2, v3}

Node v1 v2 v3 v4 v5 - 2 1 2 5

- v1 v2 v2 v2

2

4

31

1

2

3

25

Fall 2006 EE 5301 - VLSI Design Automation I 41

Prim’s Algorithm Example

v1

v2

v3

v4

v5

S = {v1, v2, v3}

Node v1 v2 v3 v4 v5 - 2 1 1 2

- v1 v2 v3 v3

2

4

31

1

2

3

25

Fall 2006 EE 5301 - VLSI Design Automation I 42

Prim’s Algorithm Example

v1

v2

v3

v4

v5

S = {v1, v2, v3}

Node v1 v2 v3 v4 v5 - 2 1 1 2

- v1 v2 v3 v3

2

4

31

1

2

3

25

Fall 2006 EE 5301 - VLSI Design Automation I 43

Prim’s Algorithm Example

v1

v2

v3

v4

v5

S = {v1, v2, v3, v4}

Node v1 v2 v3 v4 v5 - 2 1 1 2

- v1 v2 v3 v3

2

4

31

1

2

3

25

Fall 2006 EE 5301 - VLSI Design Automation I 44

Prim’s Algorithm Example

v1

v2

v3

v4

v5

S = {v1, v2, v3, v4}

Node v1 v2 v3 v4 v5 - 2 1 1 2

- v1 v2 v3 v3

2

4

31

1

2

3

25

Fall 2006 EE 5301 - VLSI Design Automation I 45

Prim’s Algorithm Example

v1

v2

v3

v4

v5

S = {v1, v2, v3, v4, v5}

Node v1 v2 v3 v4 v5 - 2 1 1 2

- v1 v2 v3 v3

2

4

31

1

2

3

25