48
A Batch Algorithm for Maintaining a Topological Order David J. Pearce and Paul H.J. Kelly Victoria University of Wellington, New Zealand & Imperial College, London

A Batch Algorithm for Maintaining a Topological Order David J. Pearce and Paul H.J. Kelly Victoria University of Wellington, New Zealand & Imperial College,

Embed Size (px)

Citation preview

Page 1: A Batch Algorithm for Maintaining a Topological Order David J. Pearce and Paul H.J. Kelly Victoria University of Wellington, New Zealand & Imperial College,

A Batch Algorithm for Maintaining a Topological Order

David J. Pearce and Paul H.J. Kelly

Victoria University of Wellington,New Zealand

& Imperial College, London

Page 2: A Batch Algorithm for Maintaining a Topological Order David J. Pearce and Paul H.J. Kelly Victoria University of Wellington, New Zealand & Imperial College,

Topological Orders

1

23

4

76

8

5

9

Page 3: A Batch Algorithm for Maintaining a Topological Order David J. Pearce and Paul H.J. Kelly Victoria University of Wellington, New Zealand & Imperial College,

Topological Orders

2 3 4 5 6 7 81 9

1

23

4

76

8

5

9

Page 4: A Batch Algorithm for Maintaining a Topological Order David J. Pearce and Paul H.J. Kelly Victoria University of Wellington, New Zealand & Imperial College,

Updating Topological Orders

1

23

4

76

8

5

9

2 3 4 5 6 7 81 9

Page 5: A Batch Algorithm for Maintaining a Topological Order David J. Pearce and Paul H.J. Kelly Victoria University of Wellington, New Zealand & Imperial College,

Updating Topological Orders

2 3 4 5 6 7 81 9

Affected Region

1

23

4

76

8

5

9

Page 6: A Batch Algorithm for Maintaining a Topological Order David J. Pearce and Paul H.J. Kelly Victoria University of Wellington, New Zealand & Imperial College,

Updating Topological Orders

2 3 4 5 6 7 81 9

Affected Region

Page 7: A Batch Algorithm for Maintaining a Topological Order David J. Pearce and Paul H.J. Kelly Victoria University of Wellington, New Zealand & Imperial College,

Updating Topological Orders

Unit Change Problem

2 3 4 5 6 7 81 92004: Pearce, et al.

1990: Alpern, et al.

1996: Marchetti-Spaccamela, et al.

2006: Ajwani, et al.

2009: Bender, et al.

2008: Haeupler, et al.

2005: Katriel, et al.

2007: Liu, et al.

Page 8: A Batch Algorithm for Maintaining a Topological Order David J. Pearce and Paul H.J. Kelly Victoria University of Wellington, New Zealand & Imperial College,

1

23

4

76

8

5

9

1 2 3 4 5 6 7 8 9

Page 9: A Batch Algorithm for Maintaining a Topological Order David J. Pearce and Paul H.J. Kelly Victoria University of Wellington, New Zealand & Imperial College,

1

23

4

76

8

5

9

1 2 3 4 5 6 7 8 9

Page 10: A Batch Algorithm for Maintaining a Topological Order David J. Pearce and Paul H.J. Kelly Victoria University of Wellington, New Zealand & Imperial College,

1

23

4

76

8

5

9

1 2 3 45 6 7 8 9

1 2 3 4 5 6 7 8 9

Page 11: A Batch Algorithm for Maintaining a Topological Order David J. Pearce and Paul H.J. Kelly Victoria University of Wellington, New Zealand & Imperial College,

1

23

4

76

8

5

9

1 2 3 45 6 7 8 9

1 2 3 4 5 6 7 8 9

1 2 3 45 6 7 89

Page 12: A Batch Algorithm for Maintaining a Topological Order David J. Pearce and Paul H.J. Kelly Victoria University of Wellington, New Zealand & Imperial College,

Batch Problem

Definition: Given a batch of edge insertions, update the topological order

Q) Can we do better than by processing them one at a time?

Page 13: A Batch Algorithm for Maintaining a Topological Order David J. Pearce and Paul H.J. Kelly Victoria University of Wellington, New Zealand & Imperial College,

Batch Problem

Definition: Given a batch of edge insertions, update the topological order

Q) Can we do better than by processing them one at a time?

A) Yes!

Page 14: A Batch Algorithm for Maintaining a Topological Order David J. Pearce and Paul H.J. Kelly Victoria University of Wellington, New Zealand & Imperial College,

Previous MNR Algorithm

2 3 4 5 6 7 81 9

Discovery – DFS to identify nodes reachable from tail in affected region

Page 15: A Batch Algorithm for Maintaining a Topological Order David J. Pearce and Paul H.J. Kelly Victoria University of Wellington, New Zealand & Imperial College,

Previous MNR Algorithm

2 3 4 5 6 7 81 9

Discovery – DFS to identify nodes reachable from tail in affected region

Page 16: A Batch Algorithm for Maintaining a Topological Order David J. Pearce and Paul H.J. Kelly Victoria University of Wellington, New Zealand & Imperial College,

Previous MNR Algorithm

2 3 4 5 6 7 81 9

Discovery – DFS to identify nodes reachable from tail in affected region

Page 17: A Batch Algorithm for Maintaining a Topological Order David J. Pearce and Paul H.J. Kelly Victoria University of Wellington, New Zealand & Imperial College,

Previous MNR Algorithm

2 3 4 5 6 7 81 9

Discovery – DFS to identify nodes reachable from tail in affected region

Page 18: A Batch Algorithm for Maintaining a Topological Order David J. Pearce and Paul H.J. Kelly Victoria University of Wellington, New Zealand & Imperial College,

Previous MNR Algorithm

2 3 4 5 6 7 81 9

Discovery – DFS to identify nodes reachable from tail in affected region

Page 19: A Batch Algorithm for Maintaining a Topological Order David J. Pearce and Paul H.J. Kelly Victoria University of Wellington, New Zealand & Imperial College,

Previous MNR Algorithm

2 3 4 5 6 7 81

9

Shift – marked nodes up the order, unmarked nodes down the order (in affected region)

Page 20: A Batch Algorithm for Maintaining a Topological Order David J. Pearce and Paul H.J. Kelly Victoria University of Wellington, New Zealand & Imperial College,

Previous MNR Algorithm

2 3 4 5 6 7 81

9

Shift – marked nodes up the order, unmarked nodes down the order (in affected region)

Page 21: A Batch Algorithm for Maintaining a Topological Order David J. Pearce and Paul H.J. Kelly Victoria University of Wellington, New Zealand & Imperial College,

Previous MNR Algorithm

2 3 4 5 6 7 81

9

Shift – marked nodes up the order, unmarked nodes down the order (in affected region)

Page 22: A Batch Algorithm for Maintaining a Topological Order David J. Pearce and Paul H.J. Kelly Victoria University of Wellington, New Zealand & Imperial College,

Previous MNR Algorithm

2 3 4 5 6 7 81

9

Shift – marked nodes up the order, unmarked nodes down the order (in affected region)

Page 23: A Batch Algorithm for Maintaining a Topological Order David J. Pearce and Paul H.J. Kelly Victoria University of Wellington, New Zealand & Imperial College,

Previous MNR Algorithm

2 3 45 6 7 81

9

Shift – marked nodes up the order, unmarked nodes down the order (in affected region)

Page 24: A Batch Algorithm for Maintaining a Topological Order David J. Pearce and Paul H.J. Kelly Victoria University of Wellington, New Zealand & Imperial College,

Previous MNR Algorithm

2 3 45 6 7 81

9

Shift – marked nodes up the order, unmarked nodes down the order (in affected region)

Page 25: A Batch Algorithm for Maintaining a Topological Order David J. Pearce and Paul H.J. Kelly Victoria University of Wellington, New Zealand & Imperial College,

MNR Algorithm

2 3 45 6 7 81 9

Shift – marked nodes up the order, unmarked nodes down the order (in affected region)

Page 26: A Batch Algorithm for Maintaining a Topological Order David J. Pearce and Paul H.J. Kelly Victoria University of Wellington, New Zealand & Imperial College,

Our Novel Batch Algorithm

Observation – edge insertions which overlap can be processed independently of others

Page 27: A Batch Algorithm for Maintaining a Topological Order David J. Pearce and Paul H.J. Kelly Victoria University of Wellington, New Zealand & Imperial College,

Our Novel Batch Algorithm

Observation – edge insertions which overlap can be processed independently of others

Affected Region Affected Region

Page 28: A Batch Algorithm for Maintaining a Topological Order David J. Pearce and Paul H.J. Kelly Victoria University of Wellington, New Zealand & Imperial College,

Our Novel Batch Algorithm

Discovery – identify “target node” for each node reachable from an insertion in affected region

45 67 2 13

Page 29: A Batch Algorithm for Maintaining a Topological Order David J. Pearce and Paul H.J. Kelly Victoria University of Wellington, New Zealand & Imperial College,

Our Novel Batch Algorithm

Discovery – identify “root node” for each node reachable from an insertion in affected region

45 67 2 13

Page 30: A Batch Algorithm for Maintaining a Topological Order David J. Pearce and Paul H.J. Kelly Victoria University of Wellington, New Zealand & Imperial College,

Our Novel Batch Algorithm

Discovery – identify “root node” for each node reachable from an insertion in affected region

45 67 2 13

Page 31: A Batch Algorithm for Maintaining a Topological Order David J. Pearce and Paul H.J. Kelly Victoria University of Wellington, New Zealand & Imperial College,

Our Novel Batch Algorithm

Discovery – identify “root node” for each node reachable from an insertion in affected region

45 67 2 134 44

Page 32: A Batch Algorithm for Maintaining a Topological Order David J. Pearce and Paul H.J. Kelly Victoria University of Wellington, New Zealand & Imperial College,

Our Novel Batch Algorithm

Discovery – identify “root node” for each node reachable from an insertion in affected region

45 67 2 134 44 1 1

Page 33: A Batch Algorithm for Maintaining a Topological Order David J. Pearce and Paul H.J. Kelly Victoria University of Wellington, New Zealand & Imperial College,

Our Novel Batch Algorithm

Shift – marked nodes up order and unmarked nodes down order; marked nodes moved just past their target

45 67 2 134 44 1 1

Page 34: A Batch Algorithm for Maintaining a Topological Order David J. Pearce and Paul H.J. Kelly Victoria University of Wellington, New Zealand & Imperial College,

Our Novel Batch Algorithm

Shift – marked nodes up order and unmarked nodes down order; marked nodes moved just past their target

45 6

7

2 134 4

4

1 1

Page 35: A Batch Algorithm for Maintaining a Topological Order David J. Pearce and Paul H.J. Kelly Victoria University of Wellington, New Zealand & Imperial College,

Our Novel Batch Algorithm

Shift – marked nodes up order and unmarked nodes down order; marked nodes moved just past their target

45 6

7

2 134 4

4

1 1

Page 36: A Batch Algorithm for Maintaining a Topological Order David J. Pearce and Paul H.J. Kelly Victoria University of Wellington, New Zealand & Imperial College,

Our Novel Batch Algorithm

Shift – marked nodes up order and unmarked nodes down order; marked nodes moved just past their target

45 6

7 2

134 4

4 1

1

Page 37: A Batch Algorithm for Maintaining a Topological Order David J. Pearce and Paul H.J. Kelly Victoria University of Wellington, New Zealand & Imperial College,

Our Novel Batch Algorithm

Shift – marked nodes up order and unmarked nodes down order; marked nodes moved just past their target

45 6

7 2

134 4

4 1

1

Page 38: A Batch Algorithm for Maintaining a Topological Order David J. Pearce and Paul H.J. Kelly Victoria University of Wellington, New Zealand & Imperial College,

Our Novel Batch Algorithm

Shift – marked nodes up order and unmarked nodes down order; marked nodes moved just past their target

45 6

7 2

1

3

4 4

4 1 1

Page 39: A Batch Algorithm for Maintaining a Topological Order David J. Pearce and Paul H.J. Kelly Victoria University of Wellington, New Zealand & Imperial College,

Our Novel Batch Algorithm

Shift – marked nodes up order and unmarked nodes down order; marked nodes moved just past their target

45 6

7 2

1

3

4 4

4 1 1

Page 40: A Batch Algorithm for Maintaining a Topological Order David J. Pearce and Paul H.J. Kelly Victoria University of Wellington, New Zealand & Imperial College,

Our Novel Batch Algorithm

Shift – marked nodes up order and unmarked nodes down order; marked nodes moved just past their target

45 6

7

21

3

4 4

4 1

Page 41: A Batch Algorithm for Maintaining a Topological Order David J. Pearce and Paul H.J. Kelly Victoria University of Wellington, New Zealand & Imperial College,

Our Novel Batch Algorithm

Shift – marked nodes up order and unmarked nodes down order; marked nodes moved just past their target

45 6

7

21 34 4

4

Page 42: A Batch Algorithm for Maintaining a Topological Order David J. Pearce and Paul H.J. Kelly Victoria University of Wellington, New Zealand & Imperial College,

Our Novel Batch Algorithm

Shift – marked nodes up order and unmarked nodes down order; marked nodes moved just past their target

4 5 6 721 3

Page 43: A Batch Algorithm for Maintaining a Topological Order David J. Pearce and Paul H.J. Kelly Victoria University of Wellington, New Zealand & Imperial College,

Results on Sparse Random Graphs

Page 44: A Batch Algorithm for Maintaining a Topological Order David J. Pearce and Paul H.J. Kelly Victoria University of Wellington, New Zealand & Imperial College,

Results on Sparse Random Graphs

Page 45: A Batch Algorithm for Maintaining a Topological Order David J. Pearce and Paul H.J. Kelly Victoria University of Wellington, New Zealand & Imperial College,

Results on Denser Random Graphs

Page 46: A Batch Algorithm for Maintaining a Topological Order David J. Pearce and Paul H.J. Kelly Victoria University of Wellington, New Zealand & Imperial College,

Results on Denser Random Graphs

Page 47: A Batch Algorithm for Maintaining a Topological Order David J. Pearce and Paul H.J. Kelly Victoria University of Wellington, New Zealand & Imperial College,

Applications

• Extensions:– Incremental Cycle Detection

• Applications:– Pointer Analysis– Software Model Checking– Constraint-based Local Search

Algorithms– Dead-lock Detection– Machine Learning– Multiple Sequence Alignment

Page 48: A Batch Algorithm for Maintaining a Topological Order David J. Pearce and Paul H.J. Kelly Victoria University of Wellington, New Zealand & Imperial College,

Conclusion

That’s all folks!