Space-Efficient Basic Graph Algorithms

0. $. Output: Write only. 0. 1. 0. 1 word size w: constant-time operations on w bits. input consists of n words ⇒ w = Θ(log n). Frank Kammer. Universität Augsburg.
5MB Größe 1 Downloads 280 Ansichten
Space-Efficient Basic Graph Algorithms A. Elmasry, T. Hagerup, and F. Kammer Universit¨ at Augsburg

March 2015

Frank Kammer

Universit¨ at Augsburg

Big Data – Restrictions in Read/Write

Several new algorithms for different models: streaming restore read-only input Frank Kammer

Universit¨ at Augsburg

1 / 10

Big Data – Restrictions in Read/Write

TM, RAM Several new algorithms for different models: streaming restore read-only input Frank Kammer

Universit¨ at Augsburg

1 / 10

Frederickson’s Model (1987) Input: Read only

CPU

1 0 1 1 1 0 $ $ $ $ $ $

Working space

Output: Write only

0 1

0

1

word size w : constant-time operations on w bits. input consists of n words ⇒ w = Θ(log n) Frank Kammer

Universit¨ at Augsburg

2 / 10

Space Efficient Algorithms – Related Results Pagter and Rauhe [FOCS’98]: comparison-based sorting n items time: O(n log n + n2 /t(n))

bits: O(log n + t(n))

Beame [J. Comput.’91]: Ω(n2 ) in the branching-program model Darwish and Elmasry [ESA’14]: Convex Hull for n points time: O(n2 /t(n) + n log t(n))

bits: O(log n + t(n))

Barnes et al. [J. Comput.’98]: s-t-connectivity on n-vertex g. √

bits: n/2Θ(

time: nO(1)

log n)

≈ Θ(n)

Edmonds et al. [J. Comput.’99]: almost matching lower bound (NNJAG model) ⇒ Little hope for efficient graph algorithms using fewer bits. Frank Kammer

Universit¨ at Augsburg

3 / 10

Representation of a Given Graph Given an n-vertex, m-edge graph O(n + m) time allows to transform between the representations, compute auxiliary information. But we must store the new representation! representation/extra info

bits

adj.\lists

O(m log n)

adj.\arrays

O(m log n)

in/out adj.\array

O(m log n)

vertex degree

deg

O(m) (rank-select datas.)

cross pointers

x y

O(m log n)

Given representation & the extra info is more essential as usual. Frank Kammer

Universit¨ at Augsburg

4 / 10

Representation of a Given Graph Given an n-vertex, m-edge graph O(n + m) time allows to transform between the representations, compute auxiliary information. But we must store the new representation! a cross pointer of an edge {u, v } : representation/extra info bits adj. lists/adj. arrays: adj.\lists O(m log n) u : .................v ...... adj.\arrays O(m log n) v : .......u.................... in/out adj.\array

O(m log n)

vertex degree

deg

O(m) (rank-select datas.)

cross pointers

x y

O(m log n)

Given representation & the extra info is more essential as usual. Frank Kammer

Universit¨ at Augsburg

4 / 10

Representation of a Given Graph Given an n-vertex, m-edge graph O(n + m) time allows to transform between the representations, compute auxiliary information. But we must store the new representation! representation/extra info

bits

adj.\lists

O(m log n)

adj.\arrays

O(m log n)

in/out adj.\array

O(m log n)

vertex degree

deg

O(m) (rank-select datas.)

cross pointers

x y

O(m log n)

Given representation & the extra info is more essential as usual. Frank Kammer

Universit¨ at Augsburg

4 / 10

Our Results repres.

time

bits (working space)

DFS

O((n + m)t(n))

O(n+n(log log n)/t(n))

DFS

O(n + m)

O(n log log n)

BFS

O(n + m)

O(n)

CC

O(n + m)

O(n)

O(n + m log n)

O(n)

O(m + n log n)

O(n log(2 + m/n))

MST SSSP

x y

n 2 x y O(m+n log n+n( log ) ) O(n(log(2+ mn )+t(n))) t(n)

: adj. arrays : in/out adj. array x y: cross-pointer n : number of vertices m : number of edges t(n) : N → N, sufficient easily computable Frank Kammer

Universit¨ at Augsburg

5 / 10

Our Results repres.

time

bits (working space)

DFS

O((n + m)t(n))

O(n+n(log log n)/t(n))

DFS

O(n + m)

O(n log log n)

BFS

O(n + m)

O(n)

CC MST SSSP

x y

Topological Sorting O(n + m) Strongly Conn. O(n + m log n)Comp. O(m + n log n)

O(n) O(n) O(n log(2 + m/n))

n 2 x y O(m+n log n+n( log ) ) O(n(log(2+ mn )+t(n))) t(n)

: adj. arrays : in/out adj. array x y: cross-pointer n : number of vertices m : number of edges t(n) : N → N, sufficient easily computable Frank Kammer

Universit¨ at Augsburg

5 / 10

Our Results repres.

time

bits (working space)

DFS

O((n + m)t(n))

O(n+n(log log n)/t(n))

DFS

O(n + m)

O(n log log n)

BFS

O(n + m)

O(n)

CC

O(n + m)

O(n)

O(n + m log n)

O(n)

O(m + n log n)

O(n log(2 + m/n))

MST SSSP

x y

n 2 x y O(m+n log n+n( log ) ) O(n(log(2+ mn )+t(n))) t(n)

: adj. arrays : in/out adj. array x y: cross-pointer n : number of vertices m : number of edges t(n) : N → N, sufficient easily computable Frank Kammer

Universit¨ at Augsburg

5 / 10

DFS with O(n) bits? Requirement on the working space for a DFS?

0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

6.1 / 10

DFS with O(n) bits? Requirement on the working space for a DFS?

1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

6.2 / 10

DFS with O(n) bits? Requirement on the working space for a DFS?

2 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

6.3 / 10

DFS with O(n) bits? Requirement on the working space for a DFS?

1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

6.4 / 10

DFS with O(n) bits? Requirement on the working space for a DFS?

3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

6.5 / 10

DFS with O(n) bits? Requirement on the working space for a DFS?

4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

6.6 / 10

DFS with O(n) bits? Requirement on the working space for a DFS?

4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

6.7 / 10

DFS with O(n) bits? Requirement on the working space for a DFS?

5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

6.8 / 10

DFS with O(n) bits? Requirement on the working space for a DFS?

5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

6.9 / 10

DFS with O(n) bits? Requirement on the working space for a DFS?

6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

6.10 / 10

DFS with O(n) bits? Requirement on the working space for a DFS?

7 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

6.11 / 10

DFS with O(n) bits? Requirement on the working space for a DFS?

6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

6.12 / 10

DFS with O(n) bits? Requirement on the working space for a DFS?

8 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

6.13 / 10

DFS with O(n) bits? Requirement on the working space for a DFS?

9 8 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

6.14 / 10

DFS with O(n) bits? Requirement on the working space for a DFS?

10 9 8 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

6.15 / 10

DFS with O(n) bits? Requirement on the working space for a DFS?

11 10 9 8 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

6.16 / 10

DFS with O(n) bits? Requirement on the working space for a DFS?

12 11 10 9 8 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

6.17 / 10

DFS with O(n) bits? Requirement on the working space for a DFS?

11 10 9 8 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

6.18 / 10

DFS with O(n) bits? Requirement on the working space for a DFS?

10 9 8 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

6.19 / 10

DFS with O(n) bits? Requirement on the working space for a DFS?

9 8 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

6.20 / 10

DFS with O(n) bits? Requirement on the working space for a DFS? O(n) bits to store the colors.

8 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

6.21 / 10

DFS with O(n) bits? Requirement on the working space for a DFS? O(n) bits to store the colors.

6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

6.22 / 10

DFS with O(n) bits? Requirement on the working space for a DFS? O(n) bits to store the colors.

13 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

6.23 / 10

DFS with O(n) bits? Requirement on the working space for a DFS? O(n) bits to store the colors.

13 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

6.24 / 10

DFS with O(n) bits? Requirement on the working space for a DFS? O(n) bits to store the colors.

14 13 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

6.25 / 10

DFS with O(n) bits? Requirement on the working space for a DFS? O(n) bits to store the colors.

15 14 13 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

6.26 / 10

DFS with O(n) bits? Requirement on the working space for a DFS? O(n) bits to store the colors.

15 14 13 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

6.27 / 10

DFS with O(n) bits? Requirement on the working space for a DFS? O(n) bits to store the colors.

15 14 13 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

6.28 / 10

DFS with O(n) bits? Requirement on the working space for a DFS? O(n) bits to store the colors.

15 14 13 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

6.29 / 10

DFS with O(n) bits? Requirement on the working space for a DFS? O(n) bits to store the colors.

16 15 14 13 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

6.30 / 10

DFS with O(n) bits? Requirement on the working space for a DFS? O(n) bits to store the colors.

17 16 15 14 13 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

6.31 / 10

DFS with O(n) bits? Requirement on the working space for a DFS? O(n) bits to store the colors.

17 16 15 14 13 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

6.32 / 10

DFS with O(n) bits? Requirement on the working space for a DFS? O(n) bits to store the colors. 18 17 16 15 14 13 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

6.33 / 10

DFS with O(n) bits? Requirement on the working space for a DFS? O(n) bits to store the colors. 19 18 17 16 15 14 13 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

6.34 / 10

DFS with O(n) bits? 20 19 18 17 16 15 14 13 6 5 4 3 1 0

Requirement on the working space for a DFS? O(n) bits to store the colors.

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

6.35 / 10

DFS with O(n) bits? 20 19 18 17 16 15 14 13 6 5 4 3 1 0

Requirement on the working space for a DFS? O(n) bits to store the colors.

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

6.36 / 10

DFS with O(n) bits? 20 19 18 17 16 15 14 13 6 5 4 3 1 0

Requirement on the working space for a DFS? O(n) bits to store the colors.

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

6.37 / 10

DFS with O(n) bits? 21 20 19 18 17 16 15 14 13 6 5 4 3 1 0

Requirement on the working space for a DFS? O(n) bits to store the colors.

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

6.38 / 10

DFS with O(n) bits? 21 20 19 18 17 16 15 14 13 6 5 4 3 1 0

Requirement on the working space for a DFS? O(n) bits to store the colors.

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

6.39 / 10

DFS with O(n) bits? 22 21 20 19 18 17 16 15 14 13 6 5 4 3 1 0

Requirement on the working space for a DFS? O(n) bits to store the colors.

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

6.40 / 10

DFS with O(n) bits? 21 20 19 18 17 16 15 14 13 6 5 4 3 1 0

Requirement on the working space for a DFS? O(n) bits to store the colors.

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

6.41 / 10

DFS with O(n) bits? 20 19 18 17 16 15 14 13 6 5 4 3 1 0

Requirement on the working space for a DFS? O(n) bits to store the colors.

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

6.42 / 10

DFS with O(n) bits? Requirement on the working space for a DFS? O(n) bits to store the colors. 19 18 17 16 15 14 13 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

6.43 / 10

DFS with O(n) bits? Requirement on the working space for a DFS? O(n) bits to store the colors. 18 17 16 15 14 13 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

6.44 / 10

DFS with O(n) bits? Requirement on the working space for a DFS? O(n) bits to store the colors.

17 16 15 14 13 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

6.45 / 10

DFS with O(n) bits? Requirement on the working space for a DFS? O(n) bits to store the colors. O(n log n) bits for the stack. 23 17 16 15 14 13 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

6.46 / 10

DFS with O(n) bits? Requirement on the working space for a DFS? O(n) bits to store the colors. O(n log n) bits for the stack. 23 17 16 15 14 13 6 5 4 3 1 0

Partition the stack into segments of size O(n/ log n). 3rd segment is needed ⇒ throw away the oldest one 7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

6.47 / 10

DFS with O(n) bits

0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.1 / 10

DFS with O(n) bits

1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.2 / 10

DFS with O(n) bits

2 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.3 / 10

DFS with O(n) bits

1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.4 / 10

DFS with O(n) bits

3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.5 / 10

DFS with O(n) bits

4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.6 / 10

DFS with O(n) bits

4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.7 / 10

DFS with O(n) bits

5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.8 / 10

DFS with O(n) bits

5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.9 / 10

DFS with O(n) bits Oldest segment is thrown away, a new one is used.

6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.10 / 10

DFS with O(n) bits Oldest segment is thrown away, a new one is used.

7 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.11 / 10

DFS with O(n) bits Oldest segment is thrown away, a new one is used.

6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.12 / 10

DFS with O(n) bits Oldest segment is thrown away, a new one is used.

8 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.13 / 10

DFS with O(n) bits Oldest segment is thrown away, a new one is used.

9 8 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.14 / 10

DFS with O(n) bits Oldest segment is thrown away, a new one is used.

10 9 8 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.15 / 10

DFS with O(n) bits Oldest segment is thrown away, a new one is used.

11 10 9 8 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.16 / 10

DFS with O(n) bits Oldest segment is thrown away, a new one is used.

12 11 10 9 8 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.17 / 10

DFS with O(n) bits Oldest segment is thrown away, a new one is used.

11 10 9 8 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.18 / 10

DFS with O(n) bits Oldest segment is thrown away, a new one is used.

10 9 8 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.19 / 10

DFS with O(n) bits Oldest segment is thrown away, a new one is used.

9 8 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.20 / 10

DFS with O(n) bits Oldest segment is thrown away, a new one is used. Empty stack! Restoration starts with new gray color. Old gray color is handled as white.

8 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.21 / 10

DFS with O(n) bits Oldest segment is thrown away, a new one is used. Empty stack! Restoration starts with new gray color. Old gray color is handled as white.

6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.22 / 10

DFS with O(n) bits Oldest segment is thrown away, a new one is used. Empty stack! Restoration starts with new gray color. Old gray color is handled as white. Skipping over black vertices.

6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.23 / 10

DFS with O(n) bits Oldest segment is thrown away, a new one is used. Empty stack! Restoration starts with new gray color. Old gray color is handled as white. Skipping over black vertices.

6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.24 / 10

DFS with O(n) bits Oldest segment is thrown away, a new one is used. Empty stack! Restoration starts with new gray color. Old gray color is handled as white. Skipping over black vertices.

6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.25 / 10

DFS with O(n) bits Oldest segment is thrown away, a new one is used. Empty stack! Restoration starts with new gray color. Old gray color is handled as white. Skipping over black vertices. Different gray colors allow to recognize back edges.

6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.26 / 10

DFS with O(n) bits Oldest segment is thrown away, a new one is used. Empty stack! Restoration starts with new gray color. Old gray color is handled as white. Skipping over black vertices. Different gray colors allow to recognize back edges. Restoration finished. DFS can be continued.

6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.27 / 10

DFS with O(n) bits Oldest segment is thrown away, a new one is used. Empty stack! Restoration starts with new gray color. Old gray color is handled as white. Skipping over black vertices. Different gray colors allow to recognize back edges. Restoration finished. DFS can be continued.

6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.28 / 10

DFS with O(n) bits Oldest segment is thrown away, a new one is used. Empty stack! Restoration starts with new gray color. Old gray color is handled as white. Skipping over black vertices. Different gray colors allow to recognize back edges. Restoration finished. DFS can be continued. 13 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.29 / 10

DFS with O(n) bits Oldest segment is thrown away, a new one is used. Empty stack! Restoration starts with new gray color. Old gray color is handled as white. Skipping over black vertices. Different gray colors allow to recognize back edges. Restoration finished. DFS can be continued. 13 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.30 / 10

DFS with O(n) bits Oldest segment is thrown away, a new one is used. Empty stack! Restoration starts with new gray color. Old gray color is handled as white. Skipping over black vertices. Different gray colors allow to recognize back edges. Restoration finished. DFS can be continued. 14 13 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.31 / 10

DFS with O(n) bits Oldest segment is thrown away, a new one is used. Empty stack! Restoration starts with new gray color. Old gray color is handled as white. Skipping over black vertices. Different gray colors allow to recognize back edges. Restoration finished. DFS can be continued. 15 14 13 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.32 / 10

DFS with O(n) bits Oldest segment is thrown away, a new one is used. Empty stack! Restoration starts with new gray color. Old gray color is handled as white. Skipping over black vertices. Different gray colors allow to recognize back edges. Restoration finished. DFS can be continued. 15 14 13 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.33 / 10

DFS with O(n) bits Oldest segment is thrown away, a new one is used. Empty stack! Restoration starts with new gray color. Old gray color is handled as white. Skipping over black vertices. Different gray colors allow to recognize back edges. Restoration finished. DFS can be continued. 15 14 13 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.34 / 10

DFS with O(n) bits Oldest segment is thrown away, a new one is used. Empty stack! Restoration starts with new gray color. Old gray color is handled as white. Skipping over black vertices. Different gray colors allow to recognize back edges. Restoration finished. DFS can be continued. 15 14 13 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.35 / 10

DFS with O(n) bits

16 15 14 13 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.36 / 10

DFS with O(n) bits

17 16 15 14 13 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.37 / 10

DFS with O(n) bits

17 16 15 14 13 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.38 / 10

DFS with O(n) bits

18 17 16 15 14 13 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.39 / 10

DFS with O(n) bits

19 18 17 16 15 14 13 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.40 / 10

DFS with O(n) bits 20 19 18 17 16 15 14 13 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.41 / 10

DFS with O(n) bits 20 19 18 17 16 15 14 13 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.42 / 10

DFS with O(n) bits 20 19 18 17 16 15 14 13 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.43 / 10

DFS with O(n) bits 21 20 19 18 17 16 15 14 13 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.44 / 10

DFS with O(n) bits 21 20 19 18 17 16 15 14 13 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.45 / 10

DFS with O(n) bits 22 21 20 19 18 17 16 15 14 13 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.46 / 10

DFS with O(n) bits 21 20 19 18 17 16 15 14 13 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.47 / 10

DFS with O(n) bits 20 19 18 17 16 15 14 13 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.48 / 10

DFS with O(n) bits Empty stack! Restoration starts; gray color is reused.

19 18 17 16 15 14 13 6 5 4 3 1 0

Thus, two gray colors suffices.

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.49 / 10

DFS with O(n) bits Empty stack! Restoration starts; gray color is reused. Thus, two gray colors suffices.

18 17 16 15 14 13 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.50 / 10

DFS with O(n) bits Empty stack! Restoration starts; gray color is reused. Thus, two gray colors suffices.

18 17 16 15 14 13 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.51 / 10

DFS with O(n) bits Empty stack! Restoration starts; gray color is reused. Thus, two gray colors suffices.

18 17 16 15 14 13 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.52 / 10

DFS with O(n) bits Empty stack! Restoration starts; gray color is reused. Thus, two gray colors suffices.

18 17 16 15 14 13 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.53 / 10

DFS with O(n) bits Empty stack! Restoration starts; gray color is reused.

18 17 16 15 14 13 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.54 / 10

DFS with O(n) bits Empty stack! Restoration starts; gray color is reused. During restoration, segments are also thrown away.

18 17 16 15 14 13 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.55 / 10

DFS with O(n) bits Empty stack! Restoration starts; gray color is reused. During restoration, segments are also thrown away.

18 17 16 15 14 13 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.56 / 10

DFS with O(n) bits Empty stack! Restoration starts; gray color is reused. During restoration, segments are also thrown away.

18 17 16 15 14 13 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.57 / 10

DFS with O(n) bits Empty stack! Restoration starts; gray color is reused. During restoration, segments are also thrown away.

18 17 16 15 14 13 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.58 / 10

DFS with O(n) bits Empty stack! Restoration starts; gray color is reused. During restoration, segments are also thrown away.

18 17 16 15 14 13 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.59 / 10

DFS with O(n) bits Empty stack! Restoration starts; gray color is reused. During restoration, segments are also thrown away. Even if vertex 3 is not on the stack, we know from its color that edge (17, 3) is a back edge.

18 17 16 15 14 13 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.60 / 10

DFS with O(n) bits

18 17 16 15 14 13 6 5 4 3 1 0

Empty stack! Restoration starts; gray color is reused. During restoration, segments are also thrown away. Even if vertex 3 is not on the stack, we know from its color that edge (17, 3) is a back edge. Restoration finished. DFS can be continued.

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.61 / 10

DFS with O(n) bits

18 17 16 15 14 13 6 5 4 3 1 0

Empty stack! Restoration starts; gray color is reused. During restoration, segments are also thrown away. Even if vertex 3 is not on the stack, we know from its color that edge (17, 3) is a back edge. Restoration finished. DFS can be continued.

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.62 / 10

DFS with O(n) bits Empty stack! Restoration starts; gray color is reused. During restoration, segments are also thrown away. Even if vertex 3 is not on the stack, we know from its color that edge (17, 3) is a back edge. Restoration finished. DFS can be continued.

17 16 15 14 13 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.63 / 10

DFS with O(n) bits

23 17 16 15 14 13 6 5 4 3 1 0

Empty stack! Restoration starts; gray color is reused. During restoration, segments are also thrown away. Even if vertex 3 is not on the stack, we know from its color that edge (17, 3) is a back edge. Restoration finished. DFS can be continued.

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.64 / 10

DFS with O(n) bits

23 17 16 15 14 13 6 5 4 3 1 0

Empty stack! Restoration starts; gray color is reused. During restoration, segments are also thrown away. Even if vertex 3 is not on the stack, we know from its color that edge (17, 3) is a back edge. Restoration finished. DFS can be continued.

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.65 / 10

DFS with O(n) bits

23 17 16 15 14 13 6 5 4 3 1 0

Empty stack! Restoration starts; gray color is reused. During restoration, segments are also thrown away. Even if vertex 3 is not on the stack, we know from its color that edge (17, 3) is a back edge. Restoration finished. DFS can be continued.

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.66 / 10

DFS with O(n) bits

23 17 16 15 14 13 6 5 4 3 1 0

Empty stack! Restoration starts; gray color is reused. During restoration, segments are also thrown away. Even if vertex 3 is not on the stack, we know from its color that edge (17, 3) is a back edge. Restoration finished. DFS can be continued.

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.67 / 10

DFS with O(n) bits Empty stack! Restoration starts; gray color is reused. During restoration, segments are also thrown away. Even if vertex 3 is not on the stack, we know from its color that edge (17, 3) is a back edge. Restoration finished. DFS can be continued.

17 16 15 14 13 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.68 / 10

DFS with O(n) bits Empty stack! Restoration starts; gray color is reused. During restoration, segments are also thrown away. Even if vertex 3 is not on the stack, we know from its color that edge (17, 3) is a back edge. Restoration finished. DFS can be continued.

16 15 14 13 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.69 / 10

DFS with O(n) bits Empty stack! Restoration starts; gray color is reused. During restoration, segments are also thrown away. Even if vertex 3 is not on the stack, we know from its color that edge (17, 3) is a back edge. Restoration finished. DFS can be continued.

15 14 13 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.70 / 10

DFS with O(n) bits Empty stack! Restoration starts; gray color is reused. During restoration, segments are also thrown away. Even if vertex 3 is not on the stack, we know from its color that edge (17, 3) is a back edge. Restoration finished. DFS can be continued.

14 13 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.71 / 10

DFS with O(n) bits Empty stack! Restoration starts; gray color is reused. During restoration, segments are also thrown away. Even if vertex 3 is not on the stack, we know from its color that edge (17, 3) is a back edge. Restoration finished. DFS can be continued.

13 6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.72 / 10

DFS with O(n) bits Empty stack! Restoration starts; gray color is reused. During restoration, segments are also thrown away. Even if vertex 3 is not on the stack, we know from its color that edge (17, 3) is a back edge. Restoration finished. DFS can be continued. Another restoration starts

6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.73 / 10

DFS with O(n) bits Empty stack! Restoration starts; gray color is reused. During restoration, segments are also thrown away. Even if vertex 3 is not on the stack, we know from its color that edge (17, 3) is a back edge. Restoration finished. DFS can be continued. Another restoration starts

6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.74 / 10

DFS with O(n) bits Empty stack! Restoration starts; gray color is reused. During restoration, segments are also thrown away. Even if vertex 3 is not on the stack, we know from its color that edge (17, 3) is a back edge. Restoration finished. DFS can be continued. Another restoration starts

6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.75 / 10

DFS with O(n) bits Empty stack! Restoration starts; gray color is reused. During restoration, segments are also thrown away. Even if vertex 3 is not on the stack, we know from its color that edge (17, 3) is a back edge. Restoration finished. DFS can be continued. Another restoration starts

6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.76 / 10

DFS with O(n) bits Empty stack! Restoration starts; gray color is reused. During restoration, segments are also thrown away. Even if vertex 3 is not on the stack, we know from its color that edge (17, 3) is a back edge. Restoration finished. DFS can be continued. Another restoration starts

6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.77 / 10

DFS with O(n) bits Empty stack! Restoration starts; gray color is reused. During restoration, segments are also thrown away. Even if vertex 3 is not on the stack, we know from its color that edge (17, 3) is a back edge. Restoration finished. DFS can be continued. Another restoration starts

6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.78 / 10

DFS with O(n) bits Empty stack! Restoration starts; gray color is reused. During restoration, segments are also thrown away. Even if vertex 3 is not on the stack, we know from its color that edge (17, 3) is a back edge. Restoration finished. DFS can be continued. Another restoration starts and ends.

6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.79 / 10

DFS with O(n) bits Empty stack! Restoration starts; gray color is reused. During restoration, segments are also thrown away. Even if vertex 3 is not on the stack, we know from its color that edge (17, 3) is a back edge. Restoration finished. DFS can be continued. Another restoration starts and ends.

5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.80 / 10

DFS with O(n) bits Empty stack! Restoration starts; gray color is reused. During restoration, segments are also thrown away. Even if vertex 3 is not on the stack, we know from its color that edge (17, 3) is a back edge. Restoration finished. DFS can be continued. Another restoration starts and ends.

4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.81 / 10

DFS with O(n) bits Empty stack! Restoration starts; gray color is reused. During restoration, segments are also thrown away. Even if vertex 3 is not on the stack, we know from its color that edge (17, 3) is a back edge. Restoration finished. DFS can be continued. Another restoration starts and ends.

3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.82 / 10

DFS with O(n) bits Empty stack! Restoration starts; gray color is reused. During restoration, segments are also thrown away. Even if vertex 3 is not on the stack, we know from its color that edge (17, 3) is a back edge. Restoration finished. DFS can be continued. Another restoration starts and ends.

1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.83 / 10

DFS with O(n) bits Empty stack! Restoration starts; gray color is reused. During restoration, segments are also thrown away. Even if vertex 3 is not on the stack, we know from its color that edge (17, 3) is a back edge. Restoration finished. DFS can be continued. Another restoration starts and ends.

0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.84 / 10

DFS with O(n) bits Empty stack! Restoration starts; gray color is reused. During restoration, segments are also thrown away. Even if vertex 3 is not on the stack, we know from its color that edge (17, 3) is a back edge. Restoration finished. DFS can be continued. Another restoration starts and ends. DFS is finished. O(n) bits used. Running time?

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

7.85 / 10

DFS with O(n) bits Algorithm is a DFS interrupted by restorations. Between two restorations: Ω(n/ log n) pops ⇒ O(log n) restorations. Each restoration runs in O(n + m) time. Altogether: O((n + m) log n) time.

Frank Kammer

Universit¨ at Augsburg

7.86 / 10

DFS with O(n) bits Algorithm is a DFS interrupted by restorations. Between two restorations: Ω(n/ log n) pops ⇒ O(log n) restorations. Each restoration runs in O(n + m) time. Altogether: O((n + m) log n) time. Theorem A DFS of a graph with n vertices and m edges can be performed in O((n + m) log n) time with O(n) bits. Independently discovered by Asano et al. [ISAAC’14].

Frank Kammer

Universit¨ at Augsburg

7.87 / 10

DFS with O(n) bits X

X

X

X

X

Algorithm is a DFS interrupted by restorations. Between two restorations: Ω(n/ log n) pops ⇒ O(log n) restorations. Each restoration runs in O(n + m) time. Altogether: O((n + m) log n) time. Theorem A DFS of a graph with n vertices and m edges can be performed in O((n + m) log n) time with O(n) bits. Independently discovered by Asano et al. [ISAAC’14]. Idea for a faster DFS Color each segment (i.e., the vertices in it) with its own color. Store the trailers of the segments in a separate stack. Frank Kammer

Universit¨ at Augsburg

7.88 / 10

DFS with O(n) bits X

X

X

X

X

Theorem A DFS of a graph with n vertices and m edges can be performed in O((n + m) log n) time with O(n) bits. Idea for a faster DFS Color each segment (i.e., the vertices in it) with its own color. Store the trailers of the segments in a separate stack.

Def.: Call a vertex v big ⇔ deg (v ) ≥ (m log n)/n To find the next vertex w above a vertex v on the stack: v big: store (v , w ) v small: store O(log log n)-bit approximation of (v , w ), i.e., group the outv edges of v into O(log n) groups and store the group of (v , w ). Frank Kammer

Universit¨ at Augsburg

7.89 / 10

DFS with O(n) bits X

X

X

X

X

Theorem A DFS of a graph with n vertices and m edges can be performed in O((n + m) log n) time with O(n) bits. Idea for a faster DFS with O(n log log n) bits Color each segment (i.e., the vertices in it) with its own color. Store the trailers of the segments in a separate stack.

Def.: Call a vertex v big ⇔ deg (v ) ≥ (m log n)/n To find the next vertex w above a vertex v on the stack: v big: store (v , w ) (≤ n/ log n big vertices) v small: store O(log log n)-bit approximation of (v , w ), i.e., group the outv edges of v into O(log n) groups and store the group of (v , w ). Frank Kammer

Universit¨ at Augsburg

7.90 / 10

Faster DFS with O(n log log n) bits

0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.1 / 10

Faster DFS with O(n log log n) bits

1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.2 / 10

Faster DFS with O(n log log n) bits

2 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.3 / 10

Faster DFS with O(n log log n) bits

1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.4 / 10

Faster DFS with O(n log log n) bits

3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.5 / 10

Faster DFS with O(n log log n) bits

4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.6 / 10

Faster DFS with O(n log log n) bits

4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.7 / 10

Faster DFS with O(n log log n) bits

5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.8 / 10

Faster DFS with O(n log log n) bits

5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.9 / 10

Faster DFS with O(n log log n) bits Throw away segment. Keep trailer in an extra stack.

6 5 4 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.10 / 10

Faster DFS with O(n log log n) bits Throw away segment. Keep trailer in an extra stack.

7 6 5 4 3 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.11 / 10

Faster DFS with O(n log log n) bits Throw away segment. Keep trailer in an extra stack.

6 5 4 3 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.12 / 10

Faster DFS with O(n log log n) bits Throw away segment. Keep trailer in an extra stack.

8 6 5 4 3 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.13 / 10

Faster DFS with O(n log log n) bits Throw away segment. Keep trailer in an extra stack.

9 8 6 5 4 3 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.14 / 10

Faster DFS with O(n log log n) bits Throw away segment. Keep trailer in an extra stack.

10 9 8 6 5 4 3 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.15 / 10

Faster DFS with O(n log log n) bits Throw away segment. Keep trailer in an extra stack.

11 10 9 8 6 6 5 4 3 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.16 / 10

Faster DFS with O(n log log n) bits Throw away segment. Keep trailer in an extra stack.

12 11 10 9 8 6 6 5 4 3 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.17 / 10

Faster DFS with O(n log log n) bits Throw away segment. Keep trailer in an extra stack.

11 10 9 8 6 6 5 4 3 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.18 / 10

Faster DFS with O(n log log n) bits Throw away segment. Keep trailer in an extra stack.

10 9 8 6 6 5 4 3 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.19 / 10

Faster DFS with O(n log log n) bits Throw away segment. Keep trailer in an extra stack.

9 8 6 6 5 4 3 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.20 / 10

Faster DFS with O(n log log n) bits Throw away segment. Keep trailer in an extra stack.

8 6 6 5 4 3 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.21 / 10

Faster DFS with O(n log log n) bits Throw away segment. Keep trailer in an extra stack. Stack is empty. Restoration starts from trailer.

6 6 5 4 3 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.22 / 10

Faster DFS with O(n log log n) bits Throw away segment. Keep trailer in an extra stack. Stack is empty. Restoration starts from trailer. New color used. Old color of the segment is handled as white.

6 6 5 4 3 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.23 / 10

Faster DFS with O(n log log n) bits Throw away segment. Keep trailer in an extra stack. Stack is empty. Restoration starts from trailer. New color used. Old color of the segment is handled as white. Back edges and tree edges are distinguishable.

6 6 5 4 3 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.24 / 10

Faster DFS with O(n log log n) bits Throw away segment. Keep trailer in an extra stack. Stack is empty. Restoration starts from trailer. New color used. Old color of the segment is handled as white. Back edges and tree edges are distinguishable.

6 5 4 3 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.25 / 10

Faster DFS with O(n log log n) bits Throw away segment. Keep trailer in an extra stack. Stack is empty. Restoration starts from trailer. New color used. Old color of the segment is handled as white. Back edges and tree edges are distinguishable. Restoration finished. DFS can be continued.

6 5 4 3 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.26 / 10

Faster DFS with O(n log log n) bits Throw away segment. Keep trailer in an extra stack. Stack is empty. Restoration starts from trailer. New color used. Old color of the segment is handled as white. Back edges and tree edges are distinguishable. Restoration finished. DFS can be continued.

13 6 5 4 3 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.27 / 10

Faster DFS with O(n log log n) bits Throw away segment. Keep trailer in an extra stack. Stack is empty. Restoration starts from trailer. New color used. Old color of the segment is handled as white. Back edges and tree edges are distinguishable. Restoration finished. DFS can be continued.

13 6 5 4 3 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.28 / 10

Faster DFS with O(n log log n) bits Throw away segment. Keep trailer in an extra stack. Stack is empty. Restoration starts from trailer. New color used. Old color of the segment is handled as white. Back edges and tree edges are distinguishable. Restoration finished. DFS can be continued.

14 13 6 5 4 3 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.29 / 10

Faster DFS with O(n log log n) bits

15 14 13 6 5 4 3 3 1 0

Throw away segment. Keep trailer in an extra stack. Stack is empty. Restoration starts from trailer. New color used. Old color of the segment is handled as white. Back edges and tree edges are distinguishable. Restoration finished. DFS can be continued.

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.30 / 10

Faster DFS with O(n log log n) bits

15 14 13 6 5 4 3 3 1 0

Throw away segment. Keep trailer in an extra stack. Stack is empty. Restoration starts from trailer. New color used. Old color of the segment is handled as white. Back edges and tree edges are distinguishable. Restoration finished. DFS can be continued.

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.31 / 10

Faster DFS with O(n log log n) bits

15 14 13 6 5 4 3 3 1 0

Throw away segment. Keep trailer in an extra stack. Stack is empty. Restoration starts from trailer. New color used. Old color of the segment is handled as white. Back edges and tree edges are distinguishable. Restoration finished. DFS can be continued.

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.32 / 10

Faster DFS with O(n log log n) bits

15 14 13 6 5 4 3 3 1 0

Throw away segment. Keep trailer in an extra stack. Stack is empty. Restoration starts from trailer. New color used. Old color of the segment is handled as white. Back edges and tree edges are distinguishable. Restoration finished. DFS can be continued.

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.33 / 10

Faster DFS with O(n log log n) bits

16 15 14 13 6 6 5 4 3 3 1 0

Throw away segment. Keep trailer in an extra stack. Stack is empty. Restoration starts from trailer. New color used. Old color of the segment is handled as white. Back edges and tree edges are distinguishable. Restoration finished. DFS can be continued.

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.34 / 10

Faster DFS with O(n log log n) bits

17 16 15 14 13 6 6 5 4 3 3 1 0

Throw away segment. Keep trailer in an extra stack. Stack is empty. Restoration starts from trailer. New color used. Old color of the segment is handled as white. Back edges and tree edges are distinguishable. Restoration finished. DFS can be continued.

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.35 / 10

Faster DFS with O(n log log n) bits

17 16 15 14 13 6 6 5 4 3 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.36 / 10

Faster DFS with O(n log log n) bits

18 17 16 15 14 13 6 6 5 4 3 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.37 / 10

Faster DFS with O(n log log n) bits

19 18 17 16 15 15 14 13 6 6 5 4 3 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.38 / 10

Faster DFS with O(n log log n) bits 20 19 18 17 16 15 15 14 13 6 6 5 4 3 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.39 / 10

Faster DFS with O(n log log n) bits 20 19 18 17 16 15 15 14 13 6 6 5 4 3 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.40 / 10

Faster DFS with O(n log log n) bits 20 19 18 17 16 15 15 14 13 6 6 5 4 3 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.41 / 10

Faster DFS with O(n log log n) bits 21 20 19 18 17 16 15 15 14 13 6 6 5 4 3 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.42 / 10

Faster DFS with O(n log log n) bits 21 20 19 18 17 16 15 15 14 13 6 6 5 4 3 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.43 / 10

Faster DFS with O(n log log n) bits 22 21 20 19 18 17 16 15 14 13 6 5 4 3 1 0

18

15

6

3

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.44 / 10

Faster DFS with O(n log log n) bits 21 20 19 18 17 16 15 14 13 6 5 4 3 1 0

18

15

6

3

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.45 / 10

Faster DFS with O(n log log n) bits 20 19 18 17 16 15 14 13 6 5 4 3 1 0

18

15

6

3

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.46 / 10

Faster DFS with O(n log log n) bits

19 18 17 16 15 14 13 6 5 4 3 1 0

18

15

6

3

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.47 / 10

Faster DFS with O(n log log n) bits

18 17 16 15 14 13 6 5 4 3 1 0

18

15

6

3

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.48 / 10

Faster DFS with O(n log log n) bits

18 17 16 15 14 13 6 5 4 3 1 0

18

15

6

3

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.49 / 10

Faster DFS with O(n log log n) bits

Another restoration starts from trailer. 18 17 16 15 14 13 6 5 4 3 1 0

18

15

6

3

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.50 / 10

Faster DFS with O(n log log n) bits

18 17 16 15 15 14 13 6 6 5 4 3 3 1 0

Another restoration starts from trailer. Restoration finished.

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.51 / 10

Faster DFS with O(n log log n) bits

18 17 16 15 15 14 13 6 6 5 4 3 3 1 0

Another restoration starts from trailer. Restoration finished.

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.52 / 10

Faster DFS with O(n log log n) bits

17 16 15 15 14 13 6 6 5 4 3 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.53 / 10

Faster DFS with O(n log log n) bits

23 17 16 15 15 14 13 6 6 5 4 3 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.54 / 10

Faster DFS with O(n log log n) bits

23 17 16 15 15 14 13 6 6 5 4 3 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.55 / 10

Faster DFS with O(n log log n) bits

23 17 16 15 15 14 13 6 6 5 4 3 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.56 / 10

Faster DFS with O(n log log n) bits

23 17 16 15 15 14 13 6 6 5 4 3 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.57 / 10

Faster DFS with O(n log log n) bits What is the running time?

17 16 15 15 14 13 6 6 5 4 3 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.58 / 10

Faster DFS with O(n log log n) bits What is the running time?

16 15 15 14 13 6 6 5 4 3 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.59 / 10

Faster DFS with O(n log log n) bits What is the running time?

15 15 14 13 6 6 5 4 3 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.60 / 10

Faster DFS with O(n log log n) bits What is the running time?

15 15 14 13 6 6 5 4 3 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.61 / 10

Faster DFS with O(n log log n) bits What is the running time?

15 15 14 13 6 6 5 4 3 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.62 / 10

Faster DFS with O(n log log n) bits What is the running time?

15 14 13 6 6 5 4 3 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.63 / 10

Faster DFS with O(n log log n) bits What is the running time?

15 14 13 6 6 5 4 3 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.64 / 10

Faster DFS with O(n log log n) bits What is the running time?

14 13 6 6 5 4 3 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.65 / 10

Faster DFS with O(n log log n) bits What is the running time?

13 6 6 5 4 3 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.66 / 10

Faster DFS with O(n log log n) bits What is the running time?

6 6 5 4 3 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.67 / 10

Faster DFS with O(n log log n) bits What is the running time?

6 6 5 4 3 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.68 / 10

Faster DFS with O(n log log n) bits What is the running time?

6 6 5 4 3 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.69 / 10

Faster DFS with O(n log log n) bits What is the running time?

6 5 4 3 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.70 / 10

Faster DFS with O(n log log n) bits What is the running time?

6 5 4 3 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.71 / 10

Faster DFS with O(n log log n) bits What is the running time? Now, a restoration iterates over O(n/ log n) vertices.

5 4 3 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.72 / 10

Faster DFS with O(n log log n) bits What is the running time? Now, a restoration iterates over O(n/ log n) vertices.

4 3 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.73 / 10

Faster DFS with O(n log log n) bits What is the running time? Now, a restoration iterates over O(n/ log n) vertices.

3 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.74 / 10

Faster DFS with O(n log log n) bits What is the running time? Now, a restoration iterates over O(n/ log n) vertices.

3 3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.75 / 10

Faster DFS with O(n log log n) bits What is the running time? Now, a restoration iterates over O(n/ log n) vertices.

3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.76 / 10

Faster DFS with O(n log log n) bits What is the running time? Now, a restoration iterates over O(n/ log n) vertices. As before, we need only O(log n) restorations.

3 1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.77 / 10

Faster DFS with O(n log log n) bits What is the running time? Now, a restoration iterates over O(n/ log n) vertices. As before, we need only O(log n) restorations.

1 0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.78 / 10

Faster DFS with O(n log log n) bits What is the running time? Now, a restoration iterates over O(n/ log n) vertices. As before, we need only O(log n) restorations.

0

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.79 / 10

Faster DFS with O(n log log n) bits What is the running time? Now, a restoration iterates over O(n/ log n) vertices. As before, we need only O(log n) restorations. Time to find the vertex u above a vertex v on the stack?

7

6

8

9

10

11

4

5

13

14

15

12

2

3

21

22

23

16

0

1

20

19

18

17

Frank Kammer

Universit¨ at Augsburg

8.80 / 10

Faster DFS with O(n log log n) bits What is the running time? Now, a restoration iterates over O(n/ log n) vertices. As before, we need only O(log n) restorations. Time to find the vertex u above a vertex v on the stack? v is big: O(1) time since we stored (v , u).

Frank Kammer

Universit¨ at Augsburg

8.81 / 10

Faster DFS with O(n log log n) bits What is the running time? Now, a restoration iterates over O(n/ log n) vertices. As before, we need only O(log n) restorations. Time to find the vertex u above a vertex v on the stack? v is big: O(1) time since we stored (v , u). v is small: Assume that adj. arrays are given.     m deg (v ) (m log n)/n O ≤O =O time log n log n n

Frank Kammer

Universit¨ at Augsburg

8.82 / 10

Faster DFS with O(n log log n) bits What is the running time? Now, a restoration iterates over O(n/ log n) vertices. As before, we need only O(log n) restorations. Time to find the vertex u above a vertex v on the stack? v is big: O(1) time since we stored (v , u). v is small: Assume that adj. arrays are given.     m deg (v ) (m log n)/n O ≤O =O time log n log n n ⇒ O((n + m)/ log n) time per restoration ⇒ O(n + m) total time for all restorations.

Frank Kammer

Universit¨ at Augsburg

8.83 / 10

Faster DFS with O(n log log n) bits What is the running time? Now, a restoration iterates over O(n/ log n) vertices. As before, we need only O(log n) restorations. Time to find the vertex u above a vertex v on the stack? v is big: O(1) time since we stored (v , u). v is small: Assume that adj. arrays are given.     m deg (v ) (m log n)/n O ≤O =O time log n log n n ⇒ O((n + m)/ log n) time per restoration ⇒ O(n + m) total time for all restorations. Theorem: Given a graph G = (V , E ) in

representation,

a DFS of G can be performed in O(n + m) time with O(n log log n) bits where n = |V | and m = |E |. Frank Kammer

Universit¨ at Augsburg

8.84 / 10

DFS – Time versus Space Theorem: Given a graph G = (V , E ) in

representation,

for all t(n) : N → N, a DFS of G can be performed in O((n+m)t(n)) time with O(n+n(log log n)/t(n)) bits where n = |V | and m = |E |.

Frank Kammer

Universit¨ at Augsburg

9.1 / 10

DFS – Time versus Space Theorem: Given a graph G = (V , E ) in

representation,

for all t(n) : N → N, a DFS of G can be performed in O((n+m)t(n)) time with O(n+n(log log n)/t(n)) bits where n = |V | and m = |E |. Alg. 1

Alg. 2

z }| { }| { z Idea: Combine the O(n)-bit alg. with the O(n)-time alg. Def. ⌊log n/t(n)⌋ succ. segments are called big segment. ⇒ A big segment consists of O(n/t(n)) vertices. Def. A usual segment is called now a small segment.

Frank Kammer

Universit¨ at Augsburg

9.2 / 10

DFS – Time versus Space Theorem: Given a graph G = (V , E ) in

representation,

for all t(n) : N → N, a DFS of G can be performed in O((n+m)t(n)) time with O(n+n(log log n)/t(n)) bits where n = |V | and m = |E |. Alg. 1

Alg. 2

z }| { }| { z Idea: Combine the O(n)-bit alg. with the O(n)-time alg. Def. ⌊log n/t(n)⌋ succ. segments are called big segment. ⇒ A big segment consists of O(n/t(n)) vertices. Use rainbow colors only in the two topmost big segments. Rainbow colors in older big segments are replaced by gray/black. Outside the two topmost big segments: Only white/gray/black.

Frank Kammer

Universit¨ at Augsburg

9.3 / 10

DFS – Time versus Space Theorem: Given a graph G = (V , E ) in

representation,

for all t(n) : N → N, a DFS of G can be performed in O((n+m)t(n)) time with O(n+n(log log n)/t(n)) bits where n = |V | and m = |E |. Alg. 1

Alg. 2

z }| { }| { z Idea: Combine the O(n)-bit alg. with the O(n)-time alg. Def. ⌊log n/t(n)⌋ succ. segments are called big segment. ⇒ A big segment consists of O(n/t(n)) vertices. Use rainbow colors only in the two topmost big segments. Use Alg. 1 to restore big segments (rainbow colors, . . .): time per big restorations: O(n+m) |big restorations|: O(t(n))

Frank Kammer

Universit¨ at Augsburg

9.4 / 10

DFS – Time versus Space Theorem: Given a graph G = (V , E ) in

representation,

for all t(n) : N → N, a DFS of G can be performed in O((n+m)t(n)) time with O(n+n(log log n)/t(n)) bits where n = |V | and m = |E |. Alg. 1

Alg. 2

z }| { }| { z Idea: Combine the O(n)-bit alg. with the O(n)-time alg. Def. ⌊log n/t(n)⌋ succ. segments are called big segment. ⇒ A big segment consists of O(n/t(n)) vertices. Use rainbow colors only in the two topmost big segments. Use Alg. 1 to restore big segments (rainbow colors, . . .): time per big restorations: O(n+m) |big restorations|: O(t(n)) Use Alg. 2 to restore small segments: time for all restorations of small segments: O(n + m) Frank Kammer

Universit¨ at Augsburg

9.5 / 10

DFS – Time versus Space Theorem: Given a graph G = (V , E ) in

representation,

for all t(n) : N → N, a DFS of G can be performed in O((n+m)t(n)) time with O(n+n(log log n)/t(n)) bits where n = |V | and m = |E |. Alg. 1

Alg. 2

z }| { }| { z Idea: Combine the O(n)-bit alg. with the O(n)-time alg. Def. ⌊log n/t(n)⌋ succ. segments are called big segment. ⇒ A big segment consists of O(n/t(n)) vertices. Use rainbow colors only in the two topmost big segments. Use Alg. 1 to restore big segments (rainbow colors, . . .): time per big restorations: O(n+m) |big restorations|: O(t(n)) Use Alg. 2 to restore small segments: time for all restorations of small segments: O(n + m) Frank Kammer

Universit¨ at Augsburg

9.6 / 10

DFS – Time versus Space Theorem: Given a graph G = (V , E ) in

representation,

for all t(n) : N → N, a DFS of G can be performed in O((n+m)t(n)) time with O(n+n(log log n)/t(n)) bits where n = |V | and m = |E |. Alg. 1

Alg. 2

z }| { }| { z Idea: Combine the O(n)-bit alg. with the O(n)-time alg. Def. ⌊log n/t(n)⌋ succ. segments are called big segment. ⇒ A big segment consists of O(n/t(n)) vertices. Use rainbow colors only in the two topmost big segments. Use Alg. 1 to restore big segments (rainbow colors, . . .): time per big restorations: O(n+m) |big restorations|: O(t(n)) Use Alg. 2 to restore small segments: time for all restorations of small segments: O(n + m) Frank Kammer

Universit¨ at Augsburg

9.7 / 10

DFS – Time versus Space Theorem: Given a graph G = (V , E ) in

representation,

for all t(n) : N → N, a DFS of G can be performed in O((n+m)t(n)) time with O(n+n(log log n)/t(n)) bits where n = |V | and m = |E |. Alg. 1

Alg. 2

z }| { }| { z Idea: Combine the O(n)-bit alg. with the O(n)-time alg. Def. ⌊log n/t(n)⌋ succ. segments are called big segment. ⇒ A big segment consists of O(n/t(n)) vertices. Use rainbow colors only in the two topmost big segments. Problem: The vertices that have colors are not contiguous. To store the colors compactly efficiently readable and writable we use a result of [Hagerup and Kammer, 2015]. Frank Kammer

Universit¨ at Augsburg

9.8 / 10

DFS – Time versus Space Theorem: Given a graph G = (V , E ) in

representation,

for all t(n) : N → N, a DFS of G can be performed in O((n+m)t(n)) time with O(n+n(log log n)/t(n)) bits where n = |V | and m = |E |. Alg. 1

Alg. 2

z }| { }| { z Idea: Combine the O(n)-bit alg. with the O(n)-time alg. Def. ⌊log n/t(n)⌋ succ. segments are called big segment. ⇒ A big segment consists of O(n/t(n)) vertices. Use rainbow colors only in the two topmost big segments. Theorem: Let n ∈ N. There is a dictionary that can store m keys drawn from {1, . . . , n}, each with b bits of satellite data, in O(n + mb) bits that allows each operation insert, delete, and lookup in O(1) amortized time. Frank Kammer

Universit¨ at Augsburg

9.9 / 10

Our Results repres.

time

bits (working space)

DFS

O((n + m)t(n))

O(n+n(log log n)/t(n))

DFS

O(n + m)

O(n log log n)

BFS

O(n + m)

O(n)

CC

O(n + m)

O(n)

O(n + m log n)

O(n)

O(m + n log n)

O(n log(2 + m/n))

MST SSSP

x y

n 2 x y O(m+n log n+n( log ) ) O(n(log(2+ mn )+t(n))) t(n)

: adj. arrays : in/out adj. array x y: cross-pointer n : number of vertices m : number of edges t(n) : N → N, sufficient easily computable Frank Kammer

Universit¨ at Augsburg

10 / 10