red-rule blue-rule demo prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04demoms… ·...

74
Lecture slides by Kevin Wayne Copyright © 2005 Pearson-Addison Wesley http://www.cs.princeton.edu/~wayne/kleinberg-tardos Last updated on 2/26/18 4:51 PM 4. G REEDY A LGORITHMS II red-rule blue-rule demo Prim’s algorithm demo Kruskal’s algorithm demo reverse-delete algorithm demo Boruvka’s algorithm demo

Upload: vonhu

Post on 05-Oct-2018

223 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

Lecture slides by Kevin WayneCopyright © 2005 Pearson-Addison Wesley

http://www.cs.princeton.edu/~wayne/kleinberg-tardos

Last updated on 2/26/18 4:51 PM

4. GREEDY ALGORITHMS II

‣ red-rule blue-rule demo

‣ Prim’s algorithm demo

‣ Kruskal’s algorithm demo

‣ reverse-delete algorithm demo

‣ Boruvka’s algorithm demo

Page 2: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

4. GREEDY ALGORITHMS II

‣ red-rule blue-rule demo

‣ Prim’s algorithm demo

‣ Kruskal’s algorithm demo

‣ reverse-delete algorithm demo

‣ Boruvka’s algorithm demo

SECTION 6.1

Page 3: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

Red-rule blue-rule demo

Red rule. Let C be a cycle with no red edges. Select an uncolored edge of Cof max weight and color it red.

Blue rule. Let D be a cutset with no blue edges. Select an uncolored edge in

D of min weight and color it blue.

3

1 5

3

9 2

47 6

8

the input graph

Page 4: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

Red-rule blue-rule demo

Red rule. Let C be a cycle with no red edges. Select an uncolored edge of Cof max weight and color it red.

4

3

9 2

4

8

apply the red rule to the cycle

1

Page 5: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

Red-rule blue-rule demo

5

current set of red and blue edges

Page 6: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

Red-rule blue-rule demo

Red rule. Let C be a cycle with no red edges. Select an uncolored edge of Cof max weight and color it red.

6

2

47

8

apply the red rule to the cycle

Page 7: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

Red-rule blue-rule demo

Red rule. Let C be a cycle with no red edges. Select an uncolored edge of Cof max weight and color it red.

7

current set of red and blue edges

Page 8: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

Red-rule blue-rule demo

Blue rule. Let D be a cutset with no blue edges. Select an uncolored edge in

D of min weight and color it blue.

8

1 5 47 6

apply the blue rule to the cutset

Page 9: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

Red-rule blue-rule demo

9

current set of red and blue edges

Page 10: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

Red-rule blue-rule demo

Blue rule. Let D be a cutset with no blue edges. Select an uncolored edge in

D of min weight and color it blue.

10

5

3

9

apply the blue rule to the cutset

Page 11: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

Red-rule blue-rule demo

11

current set of red and blue edges

Page 12: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

Red-rule blue-rule demo

Red rule. Let C be a cycle with no red edges. Select an uncolored edge of Cof max weight and color it red.

12

2

46

apply the red rule to the cycle

Page 13: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

Red-rule blue-rule demo

13

current set of red and blue edges

Page 14: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

Red-rule blue-rule demo

Blue rule. Let D be a cutset with no blue edges. Select an uncolored edge in

D of min weight and color it blue.

14

9 2

4

8

apply the blue rule to the cutset

7

Page 15: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

Red-rule blue-rule demo

15

current set of red and blue edges

Page 16: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

Red-rule blue-rule demo

Blue rule. Let D be a cutset with no blue edges. Select an uncolored edge in

D of min weight and color it blue.

16

46

8

apply the blue rule to the cutset

Page 17: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

Red-rule blue-rule demo

17

current set of red and blue edges

Page 18: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

Red-rule blue-rule demo

Blue rule. Let D be a cutset with no blue edges. Select an uncolored edge in

D of min weight and color it blue.

18

9

7

8

apply the blue rule to the cutset

Page 19: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

Red-rule blue-rule demo

19

current set of red and blue edges

Page 20: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

Red-rule blue-rule demo

Blue rule. Let D be a cutset with no blue edges. Select an uncolored edge in

D of min weight and color it blue.

20

1 5

3

apply the red rule to the cycle

Page 21: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

Red-rule blue-rule demo

21

current set of red and blue edges

Page 22: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

Red-rule blue-rule demo

Greedy algorithm. Upon termination, the blue edges form a MST.

22

1

3

2

47

a minimum spanning tree

Page 23: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

4. GREEDY ALGORITHMS II

‣ red-rule blue-rule demo

‣ Prim’s algorithm demo

‣ Kruskal’s algorithm demo

‣ reverse-delete algorithm demo

‣ Boruvka’s algorithm demo

SECTION 4.5

Page 24: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

Prim’s algorithm demo

Initialize S = any node, T = ∅.

Repeat n – 1 times:

・Add to T a min-weight edge with one endpoint in S.

・Add new node to S.

24

1 6

4

7 3

9

2

10

11

58 12

13

Page 25: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

Prim’s algorithm demo

Initialize S = any node, T = ∅.

Repeat n – 1 times:

・Add to T a min-weight edge with one endpoint in S.

・Add new node to S.

25

3 11

5

Page 26: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

Prim’s algorithm demo

Initialize S = any node, T = ∅.

Repeat n – 1 times:

・Add to T a min-weight edge with one endpoint in S.

・Add new node to S.

26

3

Page 27: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

Prim’s algorithm demo

Initialize S = any node, T = ∅.

Repeat n – 1 times:

・Add to T a min-weight edge with one endpoint in S.

・Add new node to S.

27

7 11

58 12

Page 28: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

Prim’s algorithm demo

Initialize S = any node, T = ∅.

Repeat n – 1 times:

・Add to T a min-weight edge with one endpoint in S.

・Add new node to S.

28

5

Page 29: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

Prim’s algorithm demo

Initialize S = any node, T = ∅.

Repeat n – 1 times:

・Add to T a min-weight edge with one endpoint in S.

・Add new node to S.

29

7 11

8

13 2

10

Page 30: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

Prim’s algorithm demo

Initialize S = any node, T = ∅.

Repeat n – 1 times:

・Add to T a min-weight edge with one endpoint in S.

・Add new node to S.

30

2

Page 31: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

Prim’s algorithm demo

Initialize S = any node, T = ∅.

Repeat n – 1 times:

・Add to T a min-weight edge with one endpoint in S.

・Add new node to S.

31

7

9

10

11

8

13

Page 32: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

Prim’s algorithm demo

Initialize S = any node, T = ∅.

Repeat n – 1 times:

・Add to T a min-weight edge with one endpoint in S.

・Add new node to S.

32

7

Page 33: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

Prim’s algorithm demo

Initialize S = any node, T = ∅.

Repeat n – 1 times:

・Add to T a min-weight edge with one endpoint in S.

・Add new node to S.

33

1 6 9

11

8

13

10

Page 34: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

Prim’s algorithm demo

Initialize S = any node, T = ∅.

Repeat n – 1 times:

・Add to T a min-weight edge with one endpoint in S.

・Add new node to S.

34

1

Page 35: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

Prim’s algorithm demo

Initialize S = any node, T = ∅.

Repeat n – 1 times:

・Add to T a min-weight edge with one endpoint in S.

・Add new node to S.

35

6

4

9

11

8

13

10

Page 36: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

Prim’s algorithm demo

Initialize S = any node, T = ∅.

Repeat n – 1 times:

・Add to T a min-weight edge with one endpoint in S.

・Add new node to S.

36

4

Page 37: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

Prim’s algorithm demo

Initialize S = any node, T = ∅.

Repeat n – 1 times:

・Add to T a min-weight edge with one endpoint in S.

・Add new node to S.

37

9

11

10

Page 38: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

Prim’s algorithm demo

Initialize S = any node, T = ∅.

Repeat n – 1 times:

・Add to T a min-weight edge with one endpoint in S.

・Add new node to S.

38

9

Page 39: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

Prim’s algorithm demo

Initialize S = any node, T = ∅.

Repeat n – 1 times:

・Add to T a min-weight edge with one endpoint in S.

・Add new node to S.

39

Page 40: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

Prim’s algorithm demo

Initialize S = any node, T = ∅.

Repeat n – 1 times:

・Add to T a min-weight edge with one endpoint in S.

・Add new node to S.

40

1

4

3

9

2

5

7

Page 41: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

4. GREEDY ALGORITHMS II

‣ red-rule blue-rule demo

‣ Prim’s algorithm demo

‣ Kruskal’s algorithm demo

‣ reverse-delete algorithm demo

‣ Boruvka’s algorithm demo

SECTION 4.5

Page 42: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

Kruskal’s algorithm demo

Consider edges in ascending order of weight:

・Add to T unless it would create a cycle.

42

1 5

3

9 2

47 6

8

Page 43: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

Kruskal’s algorithm demo

Consider edges in ascending order of weight:

・Add to T unless it would create a cycle.

43

1

Page 44: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

Kruskal’s algorithm demo

Consider edges in ascending order of weight:

・Add to T unless it would create a cycle.

44

2

Page 45: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

Kruskal’s algorithm demo

Consider edges in ascending order of weight:

・Add to T unless it would create a cycle.

45

3

Page 46: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

Kruskal’s algorithm demo

Consider edges in ascending order of weight:

・Add to T unless it would create a cycle.

46

4

Page 47: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

Kruskal’s algorithm demo

Consider edges in ascending order of weight:

・Add to T unless it would create a cycle.

47

5

Page 48: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

Kruskal’s algorithm demo

Consider edges in ascending order of weight:

・Add to T unless it would create a cycle.

48

6

Page 49: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

Kruskal’s algorithm demo

Consider edges in ascending order of weight:

・Add to T unless it would create a cycle.

49

7

Page 50: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

Kruskal’s algorithm demo

Consider edges in ascending order of weight:

・Add to T unless it would create a cycle.

50

8

Page 51: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

Kruskal’s algorithm demo

Consider edges in ascending order of weight:

・Add to T unless it would create a cycle.

51

9

Page 52: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

Kruskal’s algorithm demo

Consider edges in ascending order of weight:

・Add to T unless it would create a cycle.

52

Page 53: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

Kruskal’s algorithm demo

Consider edges in ascending order of weight:

・Add to T unless it would create a cycle.

53

1

3

2

47

Page 54: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

4. GREEDY ALGORITHMS II

‣ red-rule blue-rule demo

‣ Prim’s algorithm demo

‣ Kruskal’s algorithm demo

‣ reverse-delete algorithm demo

‣ Boruvka’s algorithm demo

SECTION 4.5

Page 55: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

Reverse-delete algorithm demo

Start with all edges in T and consider them in descending order of weight:

・Delete edge from T unless it would disconnect T.

55

1 5

3

9 2

47 6

8

Page 56: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

Reverse-delete algorithm

Start with all edges in T and consider them in descending order of weight:

・Delete edge from T unless it would disconnect T.

56

9

Page 57: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

Reverse-delete algorithm

Start with all edges in T and consider them in descending order of weight:

・Delete edge from T unless it would disconnect T.

57

8

Page 58: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

Reverse-delete algorithm

Start with all edges in T and consider them in descending order of weight:

・Delete edge from T unless it would disconnect T.

58

7

Page 59: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

Reverse-delete algorithm

Start with all edges in T and consider them in descending order of weight:

・Delete edge from T unless it would disconnect T.

59

6

Page 60: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

Reverse-delete algorithm

Start with all edges in T and consider them in descending order of weight:

・Delete edge from T unless it would disconnect T.

60

5

Page 61: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

Reverse-delete algorithm

Start with all edges in T and consider them in descending order of weight:

・Delete edge from T unless it would disconnect T.

61

4

Page 62: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

Reverse-delete algorithm

Start with all edges in T and consider them in descending order of weight:

・Delete edge from T unless it would disconnect T.

62

3

Page 63: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

Reverse-delete algorithm

Start with all edges in T and consider them in descending order of weight:

・Delete edge from T unless it would disconnect T.

63

2

Page 64: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

Reverse-delete algorithm

Start with all edges in T and consider them in descending order of weight:

・Delete edge from T unless it would disconnect T.

64

1

Page 65: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

Reverse-delete algorithm

Start with all edges in T and consider them in descending order of weight:

・Delete edge from T unless it would disconnect T.

65

Page 66: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

Reverse-delete algorithm

Start with all edges in T and consider them in descending order of weight:

・Delete edge from T unless it would disconnect T.

66

1

3

2

47

Page 67: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

4. GREEDY ALGORITHMS II

‣ red-rule blue-rule demo

‣ Prim’s algorithm demo

‣ Kruskal’s algorithm demo

‣ reverse-delete algorithm demo

‣ Boruvka’s algorithm demo

SECTION 6.2

Page 68: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

Borůvka’s algorithm demo

Repeat until only one tree.

・Apply blue rule to cutset corresponding to each blue tree.

・Color all selected edges blue.

68

1 6

4

7 3

9

2

10

11

58 12

13

Page 69: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

Borůvka’s algorithm demo

Repeat until only one tree.

・Apply blue rule to cutset corresponding to each blue tree.

・Color all selected edges blue.

69

1 6

4

7 3

9

2

10

11

58 12

13

Page 70: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

Borůvka’s algorithm demo

Repeat until only one tree.

・Apply blue rule to cutset corresponding to each blue tree.

・Color all selected edges blue.

70

1 6

4

7 3

9

2

10

11

58 12

13

Page 71: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

Borůvka’s algorithm demo

Repeat until only one tree.

・Apply blue rule to cutset corresponding to each blue tree.

・Color all selected edges blue.

71

7 11

58 12

13

Page 72: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

Borůvka’s algorithm demo

Repeat until only one tree.

・Apply blue rule to cutset corresponding to each blue tree.

・Color all selected edges blue.

72

7 11

58 12

13

Page 73: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

Borůvka’s algorithm demo

Repeat until only one tree.

・Apply blue rule to cutset corresponding to each blue tree.

・Color all selected edges blue.

73

Page 74: red-rule blue-rule demo Prim’s algorithm demo …wayne/kleinberg-tardos/pdf/04DemoMS… · Red-rule blue-rule demo Red rule. Let C be a cycle with no red edges. Select an uncolored

Borůvka’s algorithm demo

Repeat until only one tree.

・Apply blue rule to cutset corresponding to each blue tree.

・Color all selected edges blue.

74

1

4

3

9

2

5

7