Advances in algorithmic graph theorysummerschool2013.ccaba.upc.edu/documents/Lecture6.1... · 2013....

Preview:

Citation preview

Advances in algorithmic graph theory

George B. Mertzios

School of Engineering and Computing Sciences,Durham University, UK

Graph and routing dynamics: models and algorithms

Part II

EULER Summer School 2013

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 1 / 56

Overview

Graph searching

Tolerance graphs

an intersection model

algorithmic applications

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 2 / 56

Graph Searching

How to traverse through a graph?Graph exploring / graph searching is a fundamental graph operation.historically: labyrinth/maze traversals

modern applications: shortest paths / optimum routing

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 3 / 56

Graph Searching

How to traverse through a graph?Graph exploring / graph searching is a fundamental graph operation.historically: labyrinth/maze traversals

modern applications: shortest paths / optimum routing

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 3 / 56

Graph Searching

In a graph search:

we start at a specific initial vertex x of the graph G

we systematically visit new (i.e. undiscovered) vertices and edges of G

every new vertex is adjacent to at least one previously visited vertex(unless we visited one whole connected component of G ,so we continue with the next component)

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 4 / 56

Graph Searching

In a graph search:

we start at a specific initial vertex x of the graph G

we systematically visit new (i.e. undiscovered) vertices and edges of G

every new vertex is adjacent to at least one previously visited vertex(unless we visited one whole connected component of G ,so we continue with the next component)

every graph search outputs an ordering of the vertices of G(according to the order in which the vertices are discovered)

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 4 / 56

Graph Searching

Two most well-known graph searching techniques:1 Breadth First Search (BFS):

visit all unvisited neighbors of the currently visited vertex,before you visit any non-neighbor

visit the vertices in “layers”

always prefer to visit a vertex that is “closer” to the start vertex x

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 5 / 56

Graph Searching

Two most well-known graph searching techniques:1 Breadth First Search (BFS):

visit all unvisited neighbors of the currently visited vertex,before you visit any non-neighbor

visit the vertices in “layers”

always prefer to visit a vertex that is “closer” to the start vertex x

⇒ computes shortest paths from x

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 5 / 56

Graph Searching

Two most well-known graph searching techniques:1 Breadth First Search (BFS):

visit all unvisited neighbors of the currently visited vertex,before you visit any non-neighbor

visit the vertices in “layers”

always prefer to visit a vertex that is “closer” to the start vertex x

⇒ computes shortest paths from x

Implementation of BFS:

using a queue: First-In-First-Out (FIFO) policyadd new vertices at the end of the queueremove vertices from the beginning of the queue

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 5 / 56

Graph Searching

Two most well-known graph searching techniques:1 Breadth First Search (BFS):

visit all unvisited neighbors of the currently visited vertex,before you visit any non-neighbor

visit the vertices in “layers”

always prefer to visit a vertex that is “closer” to the start vertex x

⇒ computes shortest paths from x

1

2 3

45

6

Q =

{1}BFS ordering:

(1,

{6 1, 2, 3}{6 1, 6 2, 3, 4, 5}{6 1, 6 2, 6 3, 4, 5, 6}{6 1, 6 2, 6 3, 6 4, 5, 6}{6 1, 6 2, 6 3, 6 4, 6 5, 6}{6 1, 6 2, 6 3, 6 4, 6 5, 6 6}

Q =Q =Q =Q =Q =

Q =

2, 3, 4, 5, 6)

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 5 / 56

Graph Searching

Two most well-known graph searching techniques:1 Breadth First Search (BFS):

visit all unvisited neighbors of the currently visited vertex,before you visit any non-neighbor

visit the vertices in “layers”

always prefer to visit a vertex that is “closer” to the start vertex x

⇒ computes shortest paths from x

1

2 3

45

6

Q =

{1}BFS ordering:

(1,

{6 1, 2, 3}{6 1, 6 2, 3, 4, 5}{6 1, 6 2, 6 3, 4, 5, 6}{6 1, 6 2, 6 3, 6 4, 5, 6}{6 1, 6 2, 6 3, 6 4, 6 5, 6}{6 1, 6 2, 6 3, 6 4, 6 5, 6 6}

Q =Q =Q =Q =Q =

Q =

2, 3, 4, 5, 6)

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 5 / 56

Graph Searching

Two most well-known graph searching techniques:1 Breadth First Search (BFS):

visit all unvisited neighbors of the currently visited vertex,before you visit any non-neighbor

visit the vertices in “layers”

always prefer to visit a vertex that is “closer” to the start vertex x

⇒ computes shortest paths from x

1

2 3

45

6

Q =

{1}BFS ordering:

(1,

{6 1, 2, 3}{6 1, 6 2, 3, 4, 5}{6 1, 6 2, 6 3, 4, 5, 6}{6 1, 6 2, 6 3, 6 4, 5, 6}{6 1, 6 2, 6 3, 6 4, 6 5, 6}{6 1, 6 2, 6 3, 6 4, 6 5, 6 6}

Q =Q =Q =Q =Q =

Q =

2, 3, 4, 5, 6)

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 5 / 56

Graph Searching

Two most well-known graph searching techniques:1 Breadth First Search (BFS):

visit all unvisited neighbors of the currently visited vertex,before you visit any non-neighbor

visit the vertices in “layers”

always prefer to visit a vertex that is “closer” to the start vertex x

⇒ computes shortest paths from x

1

2 3

45

6

Q =

{1}BFS ordering:

(1,

{6 1, 2, 3}{6 1, 6 2, 3, 4, 5}{6 1, 6 2, 6 3, 4, 5, 6}{6 1, 6 2, 6 3, 6 4, 5, 6}{6 1, 6 2, 6 3, 6 4, 6 5, 6}{6 1, 6 2, 6 3, 6 4, 6 5, 6 6}

Q =Q =Q =Q =Q =

Q =

2, 3, 4, 5, 6)

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 5 / 56

Graph Searching

Two most well-known graph searching techniques:1 Breadth First Search (BFS):

visit all unvisited neighbors of the currently visited vertex,before you visit any non-neighbor

visit the vertices in “layers”

always prefer to visit a vertex that is “closer” to the start vertex x

⇒ computes shortest paths from x

1

2 3

45

6

Q =

{1}BFS ordering:

(1,

{6 1, 2, 3}{6 1, 6 2, 3, 4, 5}{6 1, 6 2, 6 3, 4, 5, 6}{6 1, 6 2, 6 3, 6 4, 5, 6}{6 1, 6 2, 6 3, 6 4, 6 5, 6}{6 1, 6 2, 6 3, 6 4, 6 5, 6 6}

Q =Q =Q =Q =Q =

Q =

2, 3, 4, 5, 6)

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 5 / 56

Graph Searching

Two most well-known graph searching techniques:1 Breadth First Search (BFS):

visit all unvisited neighbors of the currently visited vertex,before you visit any non-neighbor

visit the vertices in “layers”

always prefer to visit a vertex that is “closer” to the start vertex x

⇒ computes shortest paths from x

1

2 3

45

6

Q =

{1}BFS ordering:

(1,

{6 1, 2, 3}{6 1, 6 2, 3, 4, 5}{6 1, 6 2, 6 3, 4, 5, 6}{6 1, 6 2, 6 3, 6 4, 5, 6}{6 1, 6 2, 6 3, 6 4, 6 5, 6}{6 1, 6 2, 6 3, 6 4, 6 5, 6 6}

Q =Q =Q =Q =Q =

Q =

2, 3, 4, 5, 6)

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 5 / 56

Graph Searching

Two most well-known graph searching techniques:1 Breadth First Search (BFS):

visit all unvisited neighbors of the currently visited vertex,before you visit any non-neighbor

visit the vertices in “layers”

always prefer to visit a vertex that is “closer” to the start vertex x

⇒ computes shortest paths from x

1

2 3

45

6

Q =

{1}BFS ordering:

(1,

{6 1, 2, 3}{6 1, 6 2, 3, 4, 5}{6 1, 6 2, 6 3, 4, 5, 6}{6 1, 6 2, 6 3, 6 4, 5, 6}{6 1, 6 2, 6 3, 6 4, 6 5, 6}{6 1, 6 2, 6 3, 6 4, 6 5, 6 6}

Q =Q =Q =Q =Q =

Q =

2, 3, 4, 5, 6)

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 5 / 56

Graph Searching

Two most well-known graph searching techniques:1 Breadth First Search (BFS):

visit all unvisited neighbors of the currently visited vertex,before you visit any non-neighbor

visit the vertices in “layers”

always prefer to visit a vertex that is “closer” to the start vertex x

⇒ computes shortest paths from x

1

2 3

45

6

Q =

{1}BFS ordering:

(1,

{6 1, 2, 3}{6 1, 6 2, 3, 4, 5}{6 1, 6 2, 6 3, 4, 5, 6}{6 1, 6 2, 6 3, 6 4, 5, 6}{6 1, 6 2, 6 3, 6 4, 6 5, 6}{6 1, 6 2, 6 3, 6 4, 6 5, 6 6}

Q =Q =Q =Q =Q =

Q =

2, 3, 4, 5, 6)

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 5 / 56

Graph Searching

Two most well-known graph searching techniques:1 Breadth First Search (BFS):

visit all unvisited neighbors of the currently visited vertex,before you visit any non-neighbor

visit the vertices in “layers”

always prefer to visit a vertex that is “closer” to the start vertex x

⇒ computes shortest paths from x

1

2 3

45

6

Q =

{1}BFS ordering:

(1,

{6 1, 2, 3}{6 1, 6 2, 3, 4, 5}{6 1, 6 2, 6 3, 4, 5, 6}{6 1, 6 2, 6 3, 6 4, 5, 6}{6 1, 6 2, 6 3, 6 4, 6 5, 6}{6 1, 6 2, 6 3, 6 4, 6 5, 6 6}

Q =Q =Q =Q =Q =

Q =

2, 3, 4, 5, 6)

(1, 2, 3, 4, 5, 6) is a BFS ordering ⇒ a distance layering from vertex 1

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 5 / 56

Graph Searching

Two most well-known graph searching techniques:1 Breadth First Search (BFS):

visit all unvisited neighbors of the currently visited vertex,before you visit any non-neighbor

visit the vertices in “layers”

always prefer to visit a vertex that is “closer” to the start vertex x

⇒ computes shortest paths from x

1

2 3

45

6

Q =

{1}BFS ordering:

(1,

{6 1, 2, 3}{6 1, 6 2, 3, 4, 5}{6 1, 6 2, 6 3, 4, 5, 6}{6 1, 6 2, 6 3, 6 4, 5, 6}{6 1, 6 2, 6 3, 6 4, 6 5, 6}{6 1, 6 2, 6 3, 6 4, 6 5, 6 6}

Q =Q =Q =Q =Q =

Q =

2, 3, 4, 5, 6)

(1, 2, 3, 4, 5, 6) is a BFS ordering ⇒ a distance layering from vertex 1

However: the ordering (1, 2, 3, 6, 5, 4) is not a BFS ordering,but still a distance layering from vertex 1 !

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 5 / 56

Graph Searching

Two most well-known graph searching techniques:2 Depth First Search (DFS):

whenever possible, visit an unvisited neighbor v of the currently visitedvertex u, then visit an unvisited neighbor w of v , etc.

searches the graph in “depth”

always prefer to visit a vertex that is “one step further” than thecurrent vertex ⇒ does not compute shortest paths from x

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 6 / 56

Graph Searching

Two most well-known graph searching techniques:2 Depth First Search (DFS):

whenever possible, visit an unvisited neighbor v of the currently visitedvertex u, then visit an unvisited neighbor w of v , etc.

searches the graph in “depth”

always prefer to visit a vertex that is “one step further” than thecurrent vertex ⇒ does not compute shortest paths from x

Implementation of DFS:using a stack: Last-In-First-Out (LIFO) policyadd new vertices at the end (top) of the stackremove vertices also from the end (top) of the stack

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 6 / 56

Graph Searching

Two most well-known graph searching techniques:2 Depth First Search (DFS):

whenever possible, visit an unvisited neighbor v of the currently visitedvertex u, then visit an unvisited neighbor w of v , etc.

searches the graph in “depth”

always prefer to visit a vertex that is “one step further” than thecurrent vertex ⇒ does not compute shortest paths from x

1

2 3

45

6

{1}

(1, 2, 6)4, 5, 3,

DFS ordering: {1, 2}

{1, 2, 4}{1, 2, 4, 5}

S =S =S =S =S =S =S =

{1, 2, 4, 5, 3}{1, 2, 4, 5, 3, 6}{1, 2, 4, 5, 3}

{1, 2, 4, 5}{1, 2, 4}

{1, 2}

{1}

S =S =S =S =

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 6 / 56

Graph Searching

Two most well-known graph searching techniques:2 Depth First Search (DFS):

whenever possible, visit an unvisited neighbor v of the currently visitedvertex u, then visit an unvisited neighbor w of v , etc.

searches the graph in “depth”

always prefer to visit a vertex that is “one step further” than thecurrent vertex ⇒ does not compute shortest paths from x

1

2 3

45

6

{1}

(1, 2, 6)4, 5, 3,

DFS ordering: {1, 2}

{1, 2, 4}{1, 2, 4, 5}

S =S =S =S =S =S =S =

{1, 2, 4, 5, 3}{1, 2, 4, 5, 3, 6}{1, 2, 4, 5, 3}

{1, 2, 4, 5}{1, 2, 4}

{1, 2}

{1}

S =S =S =S =

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 6 / 56

Graph Searching

Two most well-known graph searching techniques:2 Depth First Search (DFS):

whenever possible, visit an unvisited neighbor v of the currently visitedvertex u, then visit an unvisited neighbor w of v , etc.

searches the graph in “depth”

always prefer to visit a vertex that is “one step further” than thecurrent vertex ⇒ does not compute shortest paths from x

1

2 3

45

6

{1}

(1, 2, 6)4, 5, 3,

DFS ordering: {1, 2}

{1, 2, 4}{1, 2, 4, 5}

S =S =S =S =S =S =S =

{1, 2, 4, 5, 3}{1, 2, 4, 5, 3, 6}{1, 2, 4, 5, 3}

{1, 2, 4, 5}{1, 2, 4}

{1, 2}

{1}

S =S =S =S =

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 6 / 56

Graph Searching

Two most well-known graph searching techniques:2 Depth First Search (DFS):

whenever possible, visit an unvisited neighbor v of the currently visitedvertex u, then visit an unvisited neighbor w of v , etc.

searches the graph in “depth”

always prefer to visit a vertex that is “one step further” than thecurrent vertex ⇒ does not compute shortest paths from x

1

2 3

45

6

{1}

(1, 2, 6)4, 5, 3,

DFS ordering: {1, 2}

{1, 2, 4}{1, 2, 4, 5}

S =S =S =S =S =S =S =

{1, 2, 4, 5, 3}{1, 2, 4, 5, 3, 6}{1, 2, 4, 5, 3}

{1, 2, 4, 5}{1, 2, 4}

{1, 2}

{1}

S =S =S =S =

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 6 / 56

Graph Searching

Two most well-known graph searching techniques:2 Depth First Search (DFS):

whenever possible, visit an unvisited neighbor v of the currently visitedvertex u, then visit an unvisited neighbor w of v , etc.

searches the graph in “depth”

always prefer to visit a vertex that is “one step further” than thecurrent vertex ⇒ does not compute shortest paths from x

1

2 3

45

6

{1}

(1, 2, 6)4, 5, 3,

DFS ordering: {1, 2}

{1, 2, 4}{1, 2, 4, 5}

S =S =S =S =S =S =S =

{1, 2, 4, 5, 3}{1, 2, 4, 5, 3, 6}{1, 2, 4, 5, 3}

{1, 2, 4, 5}{1, 2, 4}

{1, 2}

{1}

S =S =S =S =

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 6 / 56

Graph Searching

Two most well-known graph searching techniques:2 Depth First Search (DFS):

whenever possible, visit an unvisited neighbor v of the currently visitedvertex u, then visit an unvisited neighbor w of v , etc.

searches the graph in “depth”

always prefer to visit a vertex that is “one step further” than thecurrent vertex ⇒ does not compute shortest paths from x

1

2 3

45

6

{1}

(1, 2, 6)4, 5, 3,

DFS ordering: {1, 2}

{1, 2, 4}{1, 2, 4, 5}

S =S =S =S =S =S =S =

{1, 2, 4, 5, 3}{1, 2, 4, 5, 3, 6}{1, 2, 4, 5, 3}

{1, 2, 4, 5}{1, 2, 4}

{1, 2}

{1}

S =S =S =S =

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 6 / 56

Graph Searching

Two most well-known graph searching techniques:2 Depth First Search (DFS):

whenever possible, visit an unvisited neighbor v of the currently visitedvertex u, then visit an unvisited neighbor w of v , etc.

searches the graph in “depth”

always prefer to visit a vertex that is “one step further” than thecurrent vertex ⇒ does not compute shortest paths from x

1

2 3

45

6

{1}

(1, 2, 6)4, 5, 3,

DFS ordering: {1, 2}

{1, 2, 4}{1, 2, 4, 5}

S =S =S =S =S =S =S =

{1, 2, 4, 5, 3}{1, 2, 4, 5, 3, 6}{1, 2, 4, 5, 3}

{1, 2, 4, 5}{1, 2, 4}

{1, 2}

{1}

S =S =S =S =

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 6 / 56

Graph Searching

Two most well-known graph searching techniques:2 Depth First Search (DFS):

whenever possible, visit an unvisited neighbor v of the currently visitedvertex u, then visit an unvisited neighbor w of v , etc.

searches the graph in “depth”

always prefer to visit a vertex that is “one step further” than thecurrent vertex ⇒ does not compute shortest paths from x

1

2 3

45

6

{1}

(1, 2, 6)4, 5, 3,

DFS ordering: {1, 2}

{1, 2, 4}{1, 2, 4, 5}

S =S =S =S =S =S =S =

{1, 2, 4, 5, 3}{1, 2, 4, 5, 3, 6}{1, 2, 4, 5, 3}

{1, 2, 4, 5}{1, 2, 4}

{1, 2}

{1}

S =S =S =S =

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 6 / 56

Graph Searching

Two most well-known graph searching techniques:2 Depth First Search (DFS):

whenever possible, visit an unvisited neighbor v of the currently visitedvertex u, then visit an unvisited neighbor w of v , etc.

searches the graph in “depth”

always prefer to visit a vertex that is “one step further” than thecurrent vertex ⇒ does not compute shortest paths from x

1

2 3

45

6

{1}

(1, 2, 6)4, 5, 3,

DFS ordering: {1, 2}

{1, 2, 4}{1, 2, 4, 5}

S =S =S =S =S =S =S =

{1, 2, 4, 5, 3}{1, 2, 4, 5, 3, 6}{1, 2, 4, 5, 3}

{1, 2, 4, 5}{1, 2, 4}

{1, 2}

{1}

S =S =S =S =

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 6 / 56

Graph Searching

Two most well-known graph searching techniques:2 Depth First Search (DFS):

whenever possible, visit an unvisited neighbor v of the currently visitedvertex u, then visit an unvisited neighbor w of v , etc.

searches the graph in “depth”

always prefer to visit a vertex that is “one step further” than thecurrent vertex ⇒ does not compute shortest paths from x

1

2 3

45

6

{1}

(1, 2, 6)4, 5, 3,

DFS ordering: {1, 2}

{1, 2, 4}{1, 2, 4, 5}

S =S =S =S =S =S =S =

{1, 2, 4, 5, 3}{1, 2, 4, 5, 3, 6}{1, 2, 4, 5, 3}

{1, 2, 4, 5}{1, 2, 4}

{1, 2}

{1}

S =S =S =S =

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 6 / 56

Graph Searching

Two most well-known graph searching techniques:2 Depth First Search (DFS):

whenever possible, visit an unvisited neighbor v of the currently visitedvertex u, then visit an unvisited neighbor w of v , etc.

searches the graph in “depth”

always prefer to visit a vertex that is “one step further” than thecurrent vertex ⇒ does not compute shortest paths from x

1

2 3

45

6

{1}

(1, 2, 6)4, 5, 3,

DFS ordering: {1, 2}

{1, 2, 4}{1, 2, 4, 5}

S =S =S =S =S =S =S =

{1, 2, 4, 5, 3}{1, 2, 4, 5, 3, 6}{1, 2, 4, 5, 3}

{1, 2, 4, 5}{1, 2, 4}

{1, 2}

{1}

S =S =S =S =

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 6 / 56

Graph Searching

Two most well-known graph searching techniques:2 Depth First Search (DFS):

whenever possible, visit an unvisited neighbor v of the currently visitedvertex u, then visit an unvisited neighbor w of v , etc.

searches the graph in “depth”

always prefer to visit a vertex that is “one step further” than thecurrent vertex ⇒ does not compute shortest paths from x

1

2 3

45

6

{1}

(1, 2, 6)4, 5, 3,

DFS ordering: {1, 2}

{1, 2, 4}{1, 2, 4, 5}

S =S =S =S =S =S =S =

{1, 2, 4, 5, 3}{1, 2, 4, 5, 3, 6}{1, 2, 4, 5, 3}

{1, 2, 4, 5}{1, 2, 4}

{1, 2}

{1}

S =S =S =S =

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 6 / 56

Graph Searching

Two most well-known graph searching techniques:2 Depth First Search (DFS):

whenever possible, visit an unvisited neighbor v of the currently visitedvertex u, then visit an unvisited neighbor w of v , etc.

searches the graph in “depth”

always prefer to visit a vertex that is “one step further” than thecurrent vertex ⇒ does not compute shortest paths from x

1

2 3

45

6

(1, 2, 6)4, 5, 3,

DFS ordering: {1, 2}

{1, 2, 4}{1, 2, 4, 5}

S =S =S =S =S =S =S =

{1, 2, 4, 5, 3}{1, 2, 4, 5, 3, 6}{1, 2, 4, 5, 3}

{1, 2, 4, 5}{1, 2, 4}

{1, 2}

{1}

S =S =S =

S =S =

∅{1}

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 6 / 56

Generic graph search

Let’s formalize the generic search idea(regardless if the search is BFS, DFS, or another search):

we use a generic data structure S

S stores the candidate vertices that we may visit next

Generic Search

Input: a graph G = (V , E ) with |V | = n, a start vertex s ∈ VOutput: an ordering σ of V

1 S ← {s}2 For i = 1 to n:

3 Pick and remove an unnumbered vertex v from S

4 σ(i)← v // This assigns to v the number i

5 For each unnumbered vertex w adjacent to v:

6 Add w to S

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 7 / 56

Generic graph search

A vertex ordering σ of V is called a search ordering of G :

if σ can be generated by the Generic Search algorithm

How do we select the next (unnumbered) vertex v from S?

Generic Search does not impose any specific criteria !

if we implement S as a queue ⇒ BFS

if we implement S as a stack ⇒ DFS

1

2 3

45

6

Is σ = (1, 2, 4, 3, 5, 6) a search ordering? YES.

Is σ = (1, 2, 6, 3, 4, 5) a search ordering? NO.

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 8 / 56

Generic graph search

A vertex ordering σ of V is called a search ordering of G :

if σ can be generated by the Generic Search algorithm

How do we select the next (unnumbered) vertex v from S?

Generic Search does not impose any specific criteria !

if we implement S as a queue ⇒ BFS

if we implement S as a stack ⇒ DFS

1

2 3

45

6

Is σ = (1, 2, 4, 3, 5, 6) a search ordering? YES.

Is σ = (1, 2, 6, 3, 4, 5) a search ordering? NO.

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 8 / 56

Generic graph search

A vertex ordering σ of V is called a search ordering of G :

if σ can be generated by the Generic Search algorithm

How do we select the next (unnumbered) vertex v from S?

Generic Search does not impose any specific criteria !

if we implement S as a queue ⇒ BFS

if we implement S as a stack ⇒ DFS

1

2 3

45

6

Is σ = (1, 2, 4, 3, 5, 6) a search ordering?

YES.

Is σ = (1, 2, 6, 3, 4, 5) a search ordering? NO.

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 8 / 56

Generic graph search

A vertex ordering σ of V is called a search ordering of G :

if σ can be generated by the Generic Search algorithm

How do we select the next (unnumbered) vertex v from S?

Generic Search does not impose any specific criteria !

if we implement S as a queue ⇒ BFS

if we implement S as a stack ⇒ DFS

1

2 3

45

6

Is σ = (1, 2, 4, 3, 5, 6) a search ordering? YES.

Is σ = (1, 2, 6, 3, 4, 5) a search ordering? NO.

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 8 / 56

Generic graph search

A vertex ordering σ of V is called a search ordering of G :

if σ can be generated by the Generic Search algorithm

How do we select the next (unnumbered) vertex v from S?

Generic Search does not impose any specific criteria !

if we implement S as a queue ⇒ BFS

if we implement S as a stack ⇒ DFS

1

2 3

45

6

Is σ = (1, 2, 4, 3, 5, 6) a search ordering? YES.

Is σ = (1, 2, 6, 3, 4, 5) a search ordering?

NO.

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 8 / 56

Generic graph search

A vertex ordering σ of V is called a search ordering of G :

if σ can be generated by the Generic Search algorithm

How do we select the next (unnumbered) vertex v from S?

Generic Search does not impose any specific criteria !

if we implement S as a queue ⇒ BFS

if we implement S as a stack ⇒ DFS

1

2 3

45

6

Is σ = (1, 2, 4, 3, 5, 6) a search ordering? YES.

Is σ = (1, 2, 6, 3, 4, 5) a search ordering? NO.

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 8 / 56

Generic graph search

How can we check whether an ordering σ is a search ordering?

if, for every i , σ(i) and σ(i + 1) are adjacent ⇒ σ is a search ordering

if σ(i)σ(i + 1) /∈ E for some i ∈ {1, 2, . . . , n− 1}?

Assume that σ visits vertices a, b, c in this order, where ab /∈ E , ac ∈ E .

How could b have been chosen before c in σ?

Property (S)

Given an ordering σ of V , if a < b < c in σ, ab /∈ E , and ac ∈ E , then:

there exists a vertex d < b such that db ∈ E .

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 9 / 56

Generic graph search

How can we check whether an ordering σ is a search ordering?

if, for every i , σ(i) and σ(i + 1) are adjacent ⇒ σ is a search ordering

if σ(i)σ(i + 1) /∈ E for some i ∈ {1, 2, . . . , n− 1}?

Assume that σ visits vertices a, b, c in this order, where ab /∈ E , ac ∈ E .

How could b have been chosen before c in σ?

Property (S)

Given an ordering σ of V , if a < b < c in σ, ab /∈ E , and ac ∈ E , then:

there exists a vertex d < b such that db ∈ E .

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 9 / 56

Generic graph search

How can we check whether an ordering σ is a search ordering?

if, for every i , σ(i) and σ(i + 1) are adjacent ⇒ σ is a search ordering

if σ(i)σ(i + 1) /∈ E for some i ∈ {1, 2, . . . , n− 1}?

Assume that σ visits vertices a, b, c in this order, where ab /∈ E , ac ∈ E .

How could b have been chosen before c in σ?

Property (S)

Given an ordering σ of V , if a < b < c in σ, ab /∈ E , and ac ∈ E , then:

there exists a vertex d < b such that db ∈ E .

a b cd

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 9 / 56

Generic graph search

How can we check whether an ordering σ is a search ordering?

if, for every i , σ(i) and σ(i + 1) are adjacent ⇒ σ is a search ordering

if σ(i)σ(i + 1) /∈ E for some i ∈ {1, 2, . . . , n− 1}?

Assume that σ visits vertices a, b, c in this order, where ab /∈ E , ac ∈ E .

How could b have been chosen before c in σ?

Property (S)

Given an ordering σ of V , if a < b < c in σ, ab /∈ E , and ac ∈ E , then:

there exists a vertex d < b such that db ∈ E .

a b cd

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 9 / 56

Generic graph search

Property (S) can characterize search orderings:

Theorem (Corneil, Krueger, SIAM J. on Discr. Math., 2008)

For any graph G = (V , E ), an ordering σ of V is a search ordering of Gif and only if σ satisfies property (S).

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 10 / 56

Generic graph search

Property (S) can characterize search orderings:

Theorem (Corneil, Krueger, SIAM J. on Discr. Math., 2008)

For any graph G = (V , E ), an ordering σ of V is a search ordering of Gif and only if σ satisfies property (S).

Proof.

(⇒): Suppose that σ is a search ordering.

Let a < b < c in σ, where ab /∈ E and ac ∈ E

At the point when b is chosen in σ, both b and c belong to S :

c ∈ S because ac ∈ Eif b /∈ S then b can not be chosen in σ, contradiction

Since b ∈ S , a neighbor d of b must have been already chosen in σ

Therefore d < b and bd ∈ E

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 10 / 56

Generic graph search

Property (S) can characterize search orderings:

Theorem (Corneil, Krueger, SIAM J. on Discr. Math., 2008)

For any graph G = (V , E ), an ordering σ of V is a search ordering of Gif and only if σ satisfies property (S).

Proof.

(⇒): Suppose that σ is a search ordering.

Let a < b < c in σ, where ab /∈ E and ac ∈ E

At the point when b is chosen in σ, both b and c belong to S :

c ∈ S because ac ∈ Eif b /∈ S then b can not be chosen in σ, contradiction

Since b ∈ S , a neighbor d of b must have been already chosen in σ

Therefore d < b and bd ∈ E

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 10 / 56

Generic graph search

Proof.

(⇐): Suppose that σ = (v1, v2, . . . , vn) is satisfies property (S).Proof by contradiction:

Suppose that (v1, v2, . . . , vi−1) can be obtained by the Generic Searchalgorithm, but (v1, v2, . . . , vi ) can not (for some i ≤ n)

That is: vertex vi is the first vertex that can not be chosen next

Consider the next iteration after choosing vi−1If vi ∈ S ⇒ vi can be chosen next in σ, contradiction. Thus vi /∈ S

Let u be a vertex that the algorithm can choose next

Then u ∈ S (note: many choices for u ! )

Let w be the neighbor of u that caused u to be added to S

If wvi ∈ E ⇒ vi ∈ S , contradiction. Thus wvi /∈ E

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 11 / 56

Generic graph search

Proof.

(⇐): Suppose that σ = (v1, v2, . . . , vn) is satisfies property (S).Proof by contradiction:

Suppose that (v1, v2, . . . , vi−1) can be obtained by the Generic Searchalgorithm, but (v1, v2, . . . , vi ) can not (for some i ≤ n)

That is: vertex vi is the first vertex that can not be chosen next

Consider the next iteration after choosing vi−1If vi ∈ S ⇒ vi can be chosen next in σ, contradiction. Thus vi /∈ S

Let u be a vertex that the algorithm can choose next

Then u ∈ S (note: many choices for u ! )

Let w be the neighbor of u that caused u to be added to S

If wvi ∈ E ⇒ vi ∈ S , contradiction. Thus wvi /∈ E

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 11 / 56

Generic graph search

Proof.

(⇐): Suppose that σ = (v1, v2, . . . , vn) is satisfies property (S).Proof by contradiction:

Suppose that (v1, v2, . . . , vi−1) can be obtained by the Generic Searchalgorithm, but (v1, v2, . . . , vi ) can not (for some i ≤ n)

That is: vertex vi is the first vertex that can not be chosen next

Consider the next iteration after choosing vi−1If vi ∈ S ⇒ vi can be chosen next in σ, contradiction. Thus vi /∈ S

Let u be a vertex that the algorithm can choose next

Then u ∈ S (note: many choices for u ! )

Let w be the neighbor of u that caused u to be added to S

If wvi ∈ E ⇒ vi ∈ S , contradiction. Thus wvi /∈ E

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 11 / 56

Generic graph search

Proof.

(⇐): Suppose that σ = (v1, v2, . . . , vn) is satisfies property (S).Proof by contradiction:

Suppose that (v1, v2, . . . , vi−1) can be obtained by the Generic Searchalgorithm, but (v1, v2, . . . , vi ) can not (for some i ≤ n)

That is: vertex vi is the first vertex that can not be chosen next

Consider the next iteration after choosing vi−1If vi ∈ S ⇒ vi can be chosen next in σ, contradiction. Thus vi /∈ S

Let u be a vertex that the algorithm can choose next

Then u ∈ S (note: many choices for u ! )

Let w be the neighbor of u that caused u to be added to S

If wvi ∈ E ⇒ vi ∈ S , contradiction. Thus wvi /∈ E

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 11 / 56

Generic graph search

Proof.

(⇐): Suppose that σ = (v1, v2, . . . , vn) is satisfies property (S).Proof by contradiction:

Suppose that (v1, v2, . . . , vi−1) can be obtained by the Generic Searchalgorithm, but (v1, v2, . . . , vi ) can not (for some i ≤ n)

That is: vertex vi is the first vertex that can not be chosen next

Consider the next iteration after choosing vi−1If vi ∈ S ⇒ vi can be chosen next in σ, contradiction. Thus vi /∈ S

Let u be a vertex that the algorithm can choose next

Then u ∈ S (note: many choices for u ! )

Let w be the neighbor of u that caused u to be added to S

If wvi ∈ E ⇒ vi ∈ S , contradiction. Thus wvi /∈ E

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 11 / 56

Generic graph search

Proof.

(⇐): Suppose that σ = (v1, v2, . . . , vn) is satisfies property (S).Proof by contradiction:

Suppose that (v1, v2, . . . , vi−1) can be obtained by the Generic Searchalgorithm, but (v1, v2, . . . , vi ) can not (for some i ≤ n)

That is: vertex vi is the first vertex that can not be chosen next

σ has property (S) ⇒ for the triple w < vi < u in σ there existsa vertex d < vi such that dvi ∈ E

Therefore vi ∈ S , contradiction.

Therefore vi can be chosen next ⇒ (v1, v2, . . . , vi ) can be obtainedby the algorithm for every i = 1, 2, . . . , n

⇒ σ = (v1, v2, . . . , vn) is a search ordering

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 11 / 56

Generic graph search

Proof.

(⇐): Suppose that σ = (v1, v2, . . . , vn) is satisfies property (S).Proof by contradiction:

Suppose that (v1, v2, . . . , vi−1) can be obtained by the Generic Searchalgorithm, but (v1, v2, . . . , vi ) can not (for some i ≤ n)

That is: vertex vi is the first vertex that can not be chosen next

σ has property (S) ⇒ for the triple w < vi < u in σ there existsa vertex d < vi such that dvi ∈ E

Therefore vi ∈ S , contradiction.

Therefore vi can be chosen next ⇒ (v1, v2, . . . , vi ) can be obtainedby the algorithm for every i = 1, 2, . . . , n

⇒ σ = (v1, v2, . . . , vn) is a search ordering

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 11 / 56

Generic graph search

Proof.

(⇐): Suppose that σ = (v1, v2, . . . , vn) is satisfies property (S).Proof by contradiction:

Suppose that (v1, v2, . . . , vi−1) can be obtained by the Generic Searchalgorithm, but (v1, v2, . . . , vi ) can not (for some i ≤ n)

That is: vertex vi is the first vertex that can not be chosen next

σ has property (S) ⇒ for the triple w < vi < u in σ there existsa vertex d < vi such that dvi ∈ E

Therefore vi ∈ S , contradiction.

Therefore vi can be chosen next ⇒ (v1, v2, . . . , vi ) can be obtainedby the algorithm for every i = 1, 2, . . . , n

⇒ σ = (v1, v2, . . . , vn) is a search ordering

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 11 / 56

Generic graph search

Proof.

(⇐): Suppose that σ = (v1, v2, . . . , vn) is satisfies property (S).Proof by contradiction:

Suppose that (v1, v2, . . . , vi−1) can be obtained by the Generic Searchalgorithm, but (v1, v2, . . . , vi ) can not (for some i ≤ n)

That is: vertex vi is the first vertex that can not be chosen next

σ has property (S) ⇒ for the triple w < vi < u in σ there existsa vertex d < vi such that dvi ∈ E

Therefore vi ∈ S , contradiction.

Therefore vi can be chosen next ⇒ (v1, v2, . . . , vi ) can be obtainedby the algorithm for every i = 1, 2, . . . , n

⇒ σ = (v1, v2, . . . , vn) is a search ordering

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 11 / 56

Breadth First search

Using the generic search algorithm, we can formalize BFS:

we use a queue S

here again: S stores the candidate vertices that we may visit next

Breadth First Search (BFS)

Input: a graph G = (V , E ) with |V | = n, a start vertex s ∈ VOutput: a BFS ordering σ of V

1 Initialize queue S to {s}2 For i = 1 to n:

3 Dequeue v (from the beginning of the queue S)

4 σ(i)← v // This assigns to v the number i

5 For each unnumbered vertex w adjacent to v:

6 If w is not already in the queue then:

7 add w to S

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 12 / 56

Breadth First search

Using the generic search algorithm, we can formalize BFS:

we use a queue S

here again: S stores the candidate vertices that we may visit next

Breadth First Search (BFS)

Input: a graph G = (V , E ) with |V | = n, a start vertex s ∈ VOutput: a BFS ordering σ of V

1 Initialize queue S to {s}2 For i = 1 to n:

3 Dequeue v (from the beginning of the queue S)

4 σ(i)← v // This assigns to v the number i

5 For each unnumbered vertex w adjacent to v:

6 If w is not already in the queue then:

7 add w to S

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 12 / 56

Breadth First search

A vertex ordering σ of V is called a BFS ordering of G :

if σ can be generated by the BFS algorithm

How can we check whether an ordering σ is a BFS ordering?

Assume that σ visits vertices a, b, c in this order, where ab /∈ E , ac ∈ E .

How could b have been chosen before c in σ?

Since BFS is a graph search ⇒ σ must have property (S)i.e. there exists a vertex d < b such that bd ∈ E

Is this enough? NO.

Property (B)

Given an ordering σ of V , if a < b < c in σ, ab /∈ E , and ac ∈ E , then:

there exists a vertex d < a such that db ∈ E .

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 13 / 56

Breadth First search

How can we check whether an ordering σ is a BFS ordering?

Assume that σ visits vertices a, b, c in this order, where ab /∈ E , ac ∈ E .

How could b have been chosen before c in σ?

Since BFS is a graph search ⇒ σ must have property (S)i.e. there exists a vertex d < b such that bd ∈ E

Is this enough? NO.

Property (B)

Given an ordering σ of V , if a < b < c in σ, ab /∈ E , and ac ∈ E , then:

there exists a vertex d < a such that db ∈ E .

a b cd

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 13 / 56

Breadth First search

How can we check whether an ordering σ is a BFS ordering?

Assume that σ visits vertices a, b, c in this order, where ab /∈ E , ac ∈ E .

How could b have been chosen before c in σ?

Since BFS is a graph search ⇒ σ must have property (S)i.e. there exists a vertex d < b such that bd ∈ E

Is this enough? NO.

Property (B)

Given an ordering σ of V , if a < b < c in σ, ab /∈ E , and ac ∈ E , then:

there exists a vertex d < a such that db ∈ E .

a b cd

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 13 / 56

Breadth First search

How can we check whether an ordering σ is a BFS ordering?

Assume that σ visits vertices a, b, c in this order, where ab /∈ E , ac ∈ E .

How could b have been chosen before c in σ?

Since BFS is a graph search ⇒ σ must have property (S)i.e. there exists a vertex d < b such that bd ∈ E

Is this enough? NO.

Property (B)

Given an ordering σ of V , if a < b < c in σ, ab /∈ E , and ac ∈ E , then:

there exists a vertex d < a such that db ∈ E .

a b cd

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 13 / 56

Breadth First search

How can we check whether an ordering σ is a BFS ordering?

Assume that σ visits vertices a, b, c in this order, where ab /∈ E , ac ∈ E .

How could b have been chosen before c in σ?

Since BFS is a graph search ⇒ σ must have property (S)i.e. there exists a vertex d < b such that bd ∈ E

Is this enough? NO.

Property (B)

Given an ordering σ of V , if a < b < c in σ, ab /∈ E , and ac ∈ E , then:

there exists a vertex d < a such that db ∈ E .

a b cd

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 13 / 56

Breadth First search

Property (B) can characterize BFS orderings:

Theorem (Corneil, Krueger, SIAM J. on Discr. Math., 2008)

For any graph G = (V , E ), an ordering σ of V is a BFS ordering of G ifand only if σ satisfies property (B).

Proof.

(⇒): Suppose that σ is a BFS ordering.

Let a < b < c in σ, where ab /∈ E and ac ∈ E

Then b is removed from the queue before c

⇒ b has also been added to the queue before c

Then b must have a neighbor d that was numbered in σearlier than a, since:

if a < d for all neighbors d of b, then c is added to the queue before b,contradiction

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 14 / 56

Breadth First search

Property (B) can characterize BFS orderings:

Theorem (Corneil, Krueger, SIAM J. on Discr. Math., 2008)

For any graph G = (V , E ), an ordering σ of V is a BFS ordering of G ifand only if σ satisfies property (B).

Proof.

(⇒): Suppose that σ is a BFS ordering.

Let a < b < c in σ, where ab /∈ E and ac ∈ E

Then b is removed from the queue before c

⇒ b has also been added to the queue before c

Then b must have a neighbor d that was numbered in σearlier than a, since:

if a < d for all neighbors d of b, then c is added to the queue before b,contradiction

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 14 / 56

Breadth First search

Proof.

(⇐): Suppose that σ = (v1, v2, . . . , vn) is satisfies property (B).Proof by contradiction:

Suppose that (v1, v2, . . . , vi−1) can be obtained by theBFS algorithm, but (v1, v2, . . . , vi ) can not (for some i ≤ n)

That is: vertex vi is the first vertex that can not be chosen nextby any valid execution of BFS

Let u be a vertex that the algorithm can choose next by somepossible execution of BFS (note: many choices for u ! )

Since u is dequeued before vi (⇔ u is also enqueued before vi )

⇒ u has been enqueued by one of its neighbors vj , where j < i

If vjvi ∈ E , then some BFS execution would enqueue vi before u,contradiction. Thus vjvi /∈ E

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 15 / 56

Breadth First search

Proof.

(⇐): Suppose that σ = (v1, v2, . . . , vn) is satisfies property (B).Proof by contradiction:

Suppose that (v1, v2, . . . , vi−1) can be obtained by theBFS algorithm, but (v1, v2, . . . , vi ) can not (for some i ≤ n)

That is: vertex vi is the first vertex that can not be chosen nextby any valid execution of BFS

Let u be a vertex that the algorithm can choose next by somepossible execution of BFS (note: many choices for u ! )

Since u is dequeued before vi (⇔ u is also enqueued before vi )

⇒ u has been enqueued by one of its neighbors vj , where j < i

If vjvi ∈ E , then some BFS execution would enqueue vi before u,contradiction. Thus vjvi /∈ E

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 15 / 56

Breadth First search

Proof.

(⇐): Suppose that σ = (v1, v2, . . . , vn) is satisfies property (B).Proof by contradiction:

Suppose that (v1, v2, . . . , vi−1) can be obtained by theBFS algorithm, but (v1, v2, . . . , vi ) can not (for some i ≤ n)

That is: vertex vi is the first vertex that can not be chosen nextby any valid execution of BFS

Let u be a vertex that the algorithm can choose next by somepossible execution of BFS (note: many choices for u ! )

Since u is dequeued before vi (⇔ u is also enqueued before vi )

⇒ u has been enqueued by one of its neighbors vj , where j < i

If vjvi ∈ E , then some BFS execution would enqueue vi before u,contradiction. Thus vjvi /∈ E

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 15 / 56

Breadth First search

Proof.

(⇐): Suppose that σ = (v1, v2, . . . , vn) is satisfies property (B).Proof by contradiction:

Suppose that (v1, v2, . . . , vi−1) can be obtained by theBFS algorithm, but (v1, v2, . . . , vi ) can not (for some i ≤ n)

That is: vertex vi is the first vertex that can not be chosen nextby any valid execution of BFS

Let u be a vertex that the algorithm can choose next by somepossible execution of BFS (note: many choices for u ! )

Since u is dequeued before vi (⇔ u is also enqueued before vi )

⇒ u has been enqueued by one of its neighbors vj , where j < i

If vjvi ∈ E , then some BFS execution would enqueue vi before u,contradiction. Thus vjvi /∈ E

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 15 / 56

Breadth First search

Proof.

(⇐): Suppose that σ = (v1, v2, . . . , vn) is satisfies property (B).Proof by contradiction:

Suppose that (v1, v2, . . . , vi−1) can be obtained by theBFS algorithm, but (v1, v2, . . . , vi ) can not (for some i ≤ n)

σ has property (B) ⇒ for the triple vj < vi < u in σ there existsa vertex d < vj such that dvi ∈ E

Therefore vi can be enqueued before u (⇔ vi is dequeued before u),contradiction.

Therefore vi can be chosen next by some BFS execution ⇒(v1, v2, . . . , vi ) can be obtained by the BFS algorithm for every i

⇒ σ = (v1, v2, . . . , vn) is a BFS ordering

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 15 / 56

Breadth First search

Proof.

(⇐): Suppose that σ = (v1, v2, . . . , vn) is satisfies property (B).Proof by contradiction:

Suppose that (v1, v2, . . . , vi−1) can be obtained by theBFS algorithm, but (v1, v2, . . . , vi ) can not (for some i ≤ n)

σ has property (B) ⇒ for the triple vj < vi < u in σ there existsa vertex d < vj such that dvi ∈ E

Therefore vi can be enqueued before u (⇔ vi is dequeued before u),contradiction.

Therefore vi can be chosen next by some BFS execution ⇒(v1, v2, . . . , vi ) can be obtained by the BFS algorithm for every i

⇒ σ = (v1, v2, . . . , vn) is a BFS ordering

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 15 / 56

Breadth First search

Proof.

(⇐): Suppose that σ = (v1, v2, . . . , vn) is satisfies property (B).Proof by contradiction:

Suppose that (v1, v2, . . . , vi−1) can be obtained by theBFS algorithm, but (v1, v2, . . . , vi ) can not (for some i ≤ n)

σ has property (B) ⇒ for the triple vj < vi < u in σ there existsa vertex d < vj such that dvi ∈ E

Therefore vi can be enqueued before u (⇔ vi is dequeued before u),contradiction.

Therefore vi can be chosen next by some BFS execution ⇒(v1, v2, . . . , vi ) can be obtained by the BFS algorithm for every i

⇒ σ = (v1, v2, . . . , vn) is a BFS ordering

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 15 / 56

Breadth First search

Proof.

(⇐): Suppose that σ = (v1, v2, . . . , vn) is satisfies property (B).Proof by contradiction:

Suppose that (v1, v2, . . . , vi−1) can be obtained by theBFS algorithm, but (v1, v2, . . . , vi ) can not (for some i ≤ n)

σ has property (B) ⇒ for the triple vj < vi < u in σ there existsa vertex d < vj such that dvi ∈ E

Therefore vi can be enqueued before u (⇔ vi is dequeued before u),contradiction.

Therefore vi can be chosen next by some BFS execution ⇒(v1, v2, . . . , vi ) can be obtained by the BFS algorithm for every i

⇒ σ = (v1, v2, . . . , vn) is a BFS ordering

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 15 / 56

Breadth First search

Recall our BFS example:1

2 3

45

6

BFS ordering:

1 2 3 4 5 6

σ :

σ = (1, 2, 3, 4, 5, 6)

ad b c

σ satisfies property (B):

triple {a, b, c}, where a = 3, b = 4, c = 5

⇒ d = 2

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 16 / 56

Breadth First search

Recall our BFS example:1

2 3

45

6

BFS ordering:

1 2 3 4 5 6

σ :

σ = (1, 2, 3, 4, 5, 6)

ad b c

σ satisfies property (B):

triple {a, b, c}, where a = 3, b = 4, c = 5

⇒ d = 2

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 16 / 56

Breadth First search

Recall our BFS example:1

2 3

45

6

BFS ordering:

1 2 3 4 5 6

σ :

σ = (1, 2, 3, 4, 5, 6)

ad b c

σ satisfies property (B):

triple {a, b, c}, where a = 3, b = 4, c = 5 ⇒ d = 2

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 16 / 56

Depth First search

Using the generic search algorithm, we can also formalize DFS:

we use a stack S

once again: S stores the candidate vertices that we may visit next

Depdth First Search (DFS)

Input: a graph G = (V , E ) with |V | = n, a start vertex s ∈ VOutput: a DFS ordering σ of V

1 Initialize stack S to {s}2 For i = 1 to n:

3 Pop v (from the top of the stack S)

4 σ(i)← v // This assigns to v the number i

5 For each unnumbered vertex w adjacent to v:

6 If w is already in S then remove w from S

7 Push w (on the top of the stack S)

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 17 / 56

Depth First search

Using the generic search algorithm, we can also formalize DFS:

we use a stack S

once again: S stores the candidate vertices that we may visit next

Depdth First Search (DFS)

Input: a graph G = (V , E ) with |V | = n, a start vertex s ∈ VOutput: a DFS ordering σ of V

1 Initialize stack S to {s}2 For i = 1 to n:

3 Pop v (from the top of the stack S)

4 σ(i)← v // This assigns to v the number i

5 For each unnumbered vertex w adjacent to v:

6 If w is already in S then remove w from S

7 Push w (on the top of the stack S)

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 17 / 56

Depth First search

In contrast to BFS:

we may reorder the (unnumbered) vertices of the stack S

always at the top of S : a neighbor of the last numbered vertex

Depdth First Search (DFS)

Input: a graph G = (V , E ) with |V | = n, a start vertex s ∈ VOutput: a DFS ordering σ of V

1 Initialize stack S to {s}2 For i = 1 to n:

3 Pop v (from the top of the stack S)

4 σ(i)← v // This assigns to v the number i

5 For each unnumbered vertex w adjacent to v:

6 If w is already in S then remove w from S

7 Push w (on the top of the stack S)

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 17 / 56

Depth First search

A vertex ordering σ of V is called a DFS ordering of G :

if σ can be generated by the DFS algorithm

There can be many different executions of DFS:

many possible orders of the neighbors w of the current vertex v⇒ many possible ways to build the stack S

How can we check whether an ordering σ is a DFS ordering?

Assume that σ visits vertices a, b, c in this order, where ab /∈ E , ac ∈ E .

How could b have been chosen before c in σ?Since DFS is a graph search ⇒ σ must have property (S)i.e. there exists a vertex d < b such that bd ∈ E

Is this enough? NO.

Property (D)

Given an ordering σ of V , if a < b < c in σ, ab /∈ E , and ac ∈ E , then:

there exists a vertex d with a < d < b such that db ∈ E .

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 18 / 56

Depth First search

How can we check whether an ordering σ is a DFS ordering?

Assume that σ visits vertices a, b, c in this order, where ab /∈ E , ac ∈ E .

How could b have been chosen before c in σ?

Since DFS is a graph search ⇒ σ must have property (S)i.e. there exists a vertex d < b such that bd ∈ E

Is this enough? NO.

Property (D)

Given an ordering σ of V , if a < b < c in σ, ab /∈ E , and ac ∈ E , then:

there exists a vertex d with a < d < b such that db ∈ E .

a b cd

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 18 / 56

Depth First search

How can we check whether an ordering σ is a DFS ordering?

Assume that σ visits vertices a, b, c in this order, where ab /∈ E , ac ∈ E .

How could b have been chosen before c in σ?

Since DFS is a graph search ⇒ σ must have property (S)i.e. there exists a vertex d < b such that bd ∈ E

Is this enough? NO.

Property (D)

Given an ordering σ of V , if a < b < c in σ, ab /∈ E , and ac ∈ E , then:

there exists a vertex d with a < d < b such that db ∈ E .

a b cd

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 18 / 56

Depth First search

How can we check whether an ordering σ is a DFS ordering?

Assume that σ visits vertices a, b, c in this order, where ab /∈ E , ac ∈ E .

How could b have been chosen before c in σ?

Since DFS is a graph search ⇒ σ must have property (S)i.e. there exists a vertex d < b such that bd ∈ E

Is this enough? NO.

Property (D)

Given an ordering σ of V , if a < b < c in σ, ab /∈ E , and ac ∈ E , then:

there exists a vertex d with a < d < b such that db ∈ E .

a b cd

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 18 / 56

Depth First search

How can we check whether an ordering σ is a DFS ordering?

Assume that σ visits vertices a, b, c in this order, where ab /∈ E , ac ∈ E .

How could b have been chosen before c in σ?

Since DFS is a graph search ⇒ σ must have property (S)i.e. there exists a vertex d < b such that bd ∈ E

Is this enough? NO.

Property (D)

Given an ordering σ of V , if a < b < c in σ, ab /∈ E , and ac ∈ E , then:

there exists a vertex d with a < d < b such that db ∈ E .

a b cd

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 18 / 56

Depth First search

Property (D) can characterize DFS orderings:

Theorem (Corneil, Krueger, SIAM J. on Discr. Math., 2008)

For any graph G = (V , E ), an ordering σ of V is a DFS ordering of Gif and only if σ satisfies property (D).

Proof.

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 19 / 56

Depth First search

Property (D) can characterize DFS orderings:

Theorem (Corneil, Krueger, SIAM J. on Discr. Math., 2008)

For any graph G = (V , E ), an ordering σ of V is a DFS ordering of Gif and only if σ satisfies property (D).

Proof.

(⇒): Suppose that σ is a DFS ordering.

Let a < b < c in σ, where ab /∈ E and ac ∈ E

Consider the iteration when b is numbered in σ

⇒ b has been pushed on the top of the stack, when one of its neighborswas previously numbered

Let d be the rightmost neighbor of b that is numbered so far in σ(d was numbered the last time that b was pushed on the top of S)

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 19 / 56

Depth First search

Property (D) can characterize DFS orderings:

Theorem (Corneil, Krueger, SIAM J. on Discr. Math., 2008)

For any graph G = (V , E ), an ordering σ of V is a DFS ordering of Gif and only if σ satisfies property (D).

Proof.

(⇒): Suppose that σ is a DFS ordering.

Let a < b < c in σ, where ab /∈ E and ac ∈ E

Consider the iteration when b is numbered in σ

⇒ b has been pushed on the top of the stack, when one of its neighborswas previously numbered

Let d be the rightmost neighbor of b that is numbered so far in σ(d was numbered the last time that b was pushed on the top of S)

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 19 / 56

Depth First search

Property (D) can characterize DFS orderings:

Theorem (Corneil, Krueger, SIAM J. on Discr. Math., 2008)

For any graph G = (V , E ), an ordering σ of V is a DFS ordering of Gif and only if σ satisfies property (D).

Proof.

d < b (since d was numbered before b in σ)

d 6= a (since ab /∈ E and db ∈ E )

Thus: either d < a or a < d < b. Assume that d < a

Then, at the iteration when a was numbered (i.e. after d):

c is pushed on the top of S ⇒ c is higher than b in S

no other neighbors of b (until b is numbered)⇒ c remains higher than b in S ⇒ c is numbered before b, contradiction

Therefore a < d < b ⇒ σ satisfies property (D).

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 19 / 56

Depth First search

Property (D) can characterize DFS orderings:

Theorem (Corneil, Krueger, SIAM J. on Discr. Math., 2008)

For any graph G = (V , E ), an ordering σ of V is a DFS ordering of Gif and only if σ satisfies property (D).

Proof.

d < b (since d was numbered before b in σ)

d 6= a (since ab /∈ E and db ∈ E )

Thus: either d < a or a < d < b. Assume that d < a

Then, at the iteration when a was numbered (i.e. after d):

c is pushed on the top of S ⇒ c is higher than b in S

no other neighbors of b (until b is numbered)⇒ c remains higher than b in S ⇒ c is numbered before b, contradiction

Therefore a < d < b ⇒ σ satisfies property (D).

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 19 / 56

Depth First search

Property (D) can characterize DFS orderings:

Theorem (Corneil, Krueger, SIAM J. on Discr. Math., 2008)

For any graph G = (V , E ), an ordering σ of V is a DFS ordering of Gif and only if σ satisfies property (D).

Proof.

d < b (since d was numbered before b in σ)

d 6= a (since ab /∈ E and db ∈ E )

Thus: either d < a or a < d < b. Assume that d < a

Then, at the iteration when a was numbered (i.e. after d):

c is pushed on the top of S ⇒ c is higher than b in S

no other neighbors of b (until b is numbered)⇒ c remains higher than b in S ⇒ c is numbered before b, contradiction

Therefore a < d < b ⇒ σ satisfies property (D).

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 19 / 56

Depth First search

Property (D) can characterize DFS orderings:

Theorem (Corneil, Krueger, SIAM J. on Discr. Math., 2008)

For any graph G = (V , E ), an ordering σ of V is a DFS ordering of Gif and only if σ satisfies property (D).

Proof.

d < b (since d was numbered before b in σ)

d 6= a (since ab /∈ E and db ∈ E )

Thus: either d < a or a < d < b. Assume that d < a

Then, at the iteration when a was numbered (i.e. after d):

c is pushed on the top of S ⇒ c is higher than b in S

no other neighbors of b (until b is numbered)⇒ c remains higher than b in S ⇒ c is numbered before b, contradiction

Therefore a < d < b ⇒ σ satisfies property (D).

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 19 / 56

Depth First search

Property (D) can characterize DFS orderings:

Theorem (Corneil, Krueger, SIAM J. on Discr. Math., 2008)

For any graph G = (V , E ), an ordering σ of V is a DFS ordering of Gif and only if σ satisfies property (D).

Proof.

d < b (since d was numbered before b in σ)

d 6= a (since ab /∈ E and db ∈ E )

Thus: either d < a or a < d < b. Assume that d < a

Then, at the iteration when a was numbered (i.e. after d):

c is pushed on the top of S ⇒ c is higher than b in Sno other neighbors of b (until b is numbered)

⇒ c remains higher than b in S

⇒ c is numbered before b, contradiction

Therefore a < d < b ⇒ σ satisfies property (D).

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 19 / 56

Depth First search

Property (D) can characterize DFS orderings:

Theorem (Corneil, Krueger, SIAM J. on Discr. Math., 2008)

For any graph G = (V , E ), an ordering σ of V is a DFS ordering of Gif and only if σ satisfies property (D).

Proof.

d < b (since d was numbered before b in σ)

d 6= a (since ab /∈ E and db ∈ E )

Thus: either d < a or a < d < b. Assume that d < a

Then, at the iteration when a was numbered (i.e. after d):

c is pushed on the top of S ⇒ c is higher than b in Sno other neighbors of b (until b is numbered)

⇒ c remains higher than b in S ⇒ c is numbered before b, contradiction

Therefore a < d < b ⇒ σ satisfies property (D).

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 19 / 56

Depth First search

Property (D) can characterize DFS orderings:

Theorem (Corneil, Krueger, SIAM J. on Discr. Math., 2008)

For any graph G = (V , E ), an ordering σ of V is a DFS ordering of Gif and only if σ satisfies property (D).

Proof.

d < b (since d was numbered before b in σ)

d 6= a (since ab /∈ E and db ∈ E )

Thus: either d < a or a < d < b. Assume that d < a

Then, at the iteration when a was numbered (i.e. after d):

c is pushed on the top of S ⇒ c is higher than b in Sno other neighbors of b (until b is numbered)

⇒ c remains higher than b in S ⇒ c is numbered before b, contradiction

Therefore a < d < b ⇒ σ satisfies property (D).

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 19 / 56

Depth First search

Proof.

(⇐): Suppose that σ = (v1, v2, . . . , vn) is satisfies property (D).Proof by contradiction:

Suppose that (v1, v2, . . . , vi−1) can be obtained by theDFS algorithm, but σi−1 = (v1, v2, . . . , vi ) can not (for some i ≤ n)

That is: vertex vi is the first vertex that can not be chosen nextby any valid execution of DFS

Let u be a vertex that the algorithm can choose next by somepossible execution of DFS (many choices for u ! )

Then:

vi < u in σu is at the top of S after vi−1 is numbered (in this execution of DFS)

Let vj be the rightmost neighbor of u in σi−1(vj was numbered the last time that u was pushed on the top of S)

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 20 / 56

Depth First search

Proof.

(⇐): Suppose that σ = (v1, v2, . . . , vn) is satisfies property (D).Proof by contradiction:

Suppose that (v1, v2, . . . , vi−1) can be obtained by theDFS algorithm, but σi−1 = (v1, v2, . . . , vi ) can not (for some i ≤ n)

That is: vertex vi is the first vertex that can not be chosen nextby any valid execution of DFS

Let u be a vertex that the algorithm can choose next by somepossible execution of DFS (many choices for u ! )

Then:

vi < u in σu is at the top of S after vi−1 is numbered (in this execution of DFS)

Let vj be the rightmost neighbor of u in σi−1(vj was numbered the last time that u was pushed on the top of S)

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 20 / 56

Depth First search

Proof.

(⇐): Suppose that σ = (v1, v2, . . . , vn) is satisfies property (D).Proof by contradiction:

Suppose that (v1, v2, . . . , vi−1) can be obtained by theDFS algorithm, but σi−1 = (v1, v2, . . . , vi ) can not (for some i ≤ n)

That is: vertex vi is the first vertex that can not be chosen nextby any valid execution of DFS

Let u be a vertex that the algorithm can choose next by somepossible execution of DFS (many choices for u ! ) Then:

vi < u in σu is at the top of S after vi−1 is numbered (in this execution of DFS)

Let vj be the rightmost neighbor of u in σi−1(vj was numbered the last time that u was pushed on the top of S)

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 20 / 56

Depth First search

Proof.

(⇐): Suppose that σ = (v1, v2, . . . , vn) is satisfies property (D).Proof by contradiction:

Suppose that (v1, v2, . . . , vi−1) can be obtained by theDFS algorithm, but σi−1 = (v1, v2, . . . , vi ) can not (for some i ≤ n)

That is: vertex vi is the first vertex that can not be chosen nextby any valid execution of DFS

Let u be a vertex that the algorithm can choose next by somepossible execution of DFS (many choices for u ! ) Then:

vi < u in σu is at the top of S after vi−1 is numbered (in this execution of DFS)

Let vj be the rightmost neighbor of u in σi−1(vj was numbered the last time that u was pushed on the top of S)

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 20 / 56

Depth First search

Proof.

Let k ∈ {j , j + 1, . . . , i − 1}. If vkvi ∈ E then:

vi can be pushed higher than u in S in some execution of DFS(since vj is the rightmost neighbor of u in σi−1)

⇒ vi can be numbered directly after vi−1 (instead of u), a contradiction

Therefore vkvi /∈ E for every k = j , j + 1, . . . , i − 1

σ has property (D) ⇒ for the triple vj < vi < u in σ there existsa vertex vj < d < vi such that dvi ∈ E , contradiction

Therefore vi can be chosen next by some DFS execution ⇒(v1, v2, . . . , vi ) can be obtained by the DFS algorithm for every i

⇒ σ = (v1, v2, . . . , vn) is a DFS ordering

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 20 / 56

Depth First search

Proof.

Let k ∈ {j , j + 1, . . . , i − 1}. If vkvi ∈ E then:

vi can be pushed higher than u in S in some execution of DFS(since vj is the rightmost neighbor of u in σi−1)

⇒ vi can be numbered directly after vi−1 (instead of u), a contradiction

Therefore vkvi /∈ E for every k = j , j + 1, . . . , i − 1

σ has property (D) ⇒ for the triple vj < vi < u in σ there existsa vertex vj < d < vi such that dvi ∈ E , contradiction

Therefore vi can be chosen next by some DFS execution ⇒(v1, v2, . . . , vi ) can be obtained by the DFS algorithm for every i

⇒ σ = (v1, v2, . . . , vn) is a DFS ordering

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 20 / 56

Depth First search

Proof.

Let k ∈ {j , j + 1, . . . , i − 1}. If vkvi ∈ E then:

vi can be pushed higher than u in S in some execution of DFS(since vj is the rightmost neighbor of u in σi−1)

⇒ vi can be numbered directly after vi−1 (instead of u), a contradiction

Therefore vkvi /∈ E for every k = j , j + 1, . . . , i − 1

σ has property (D) ⇒ for the triple vj < vi < u in σ there existsa vertex vj < d < vi such that dvi ∈ E , contradiction

Therefore vi can be chosen next by some DFS execution ⇒(v1, v2, . . . , vi ) can be obtained by the DFS algorithm for every i

⇒ σ = (v1, v2, . . . , vn) is a DFS ordering

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 20 / 56

Depth First search

Proof.

Let k ∈ {j , j + 1, . . . , i − 1}. If vkvi ∈ E then:

vi can be pushed higher than u in S in some execution of DFS(since vj is the rightmost neighbor of u in σi−1)

⇒ vi can be numbered directly after vi−1 (instead of u), a contradiction

Therefore vkvi /∈ E for every k = j , j + 1, . . . , i − 1

σ has property (D) ⇒ for the triple vj < vi < u in σ there existsa vertex vj < d < vi such that dvi ∈ E , contradiction

Therefore vi can be chosen next by some DFS execution ⇒(v1, v2, . . . , vi ) can be obtained by the DFS algorithm for every i

⇒ σ = (v1, v2, . . . , vn) is a DFS ordering

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 20 / 56

Depth First search

Proof.

Let k ∈ {j , j + 1, . . . , i − 1}. If vkvi ∈ E then:

vi can be pushed higher than u in S in some execution of DFS(since vj is the rightmost neighbor of u in σi−1)

⇒ vi can be numbered directly after vi−1 (instead of u), a contradiction

Therefore vkvi /∈ E for every k = j , j + 1, . . . , i − 1

σ has property (D) ⇒ for the triple vj < vi < u in σ there existsa vertex vj < d < vi such that dvi ∈ E , contradiction

Therefore vi can be chosen next by some DFS execution ⇒(v1, v2, . . . , vi ) can be obtained by the DFS algorithm for every i

⇒ σ = (v1, v2, . . . , vn) is a DFS ordering

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 20 / 56

Depth First search

Proof.

Let k ∈ {j , j + 1, . . . , i − 1}. If vkvi ∈ E then:

vi can be pushed higher than u in S in some execution of DFS(since vj is the rightmost neighbor of u in σi−1)

⇒ vi can be numbered directly after vi−1 (instead of u), a contradiction

Therefore vkvi /∈ E for every k = j , j + 1, . . . , i − 1

σ has property (D) ⇒ for the triple vj < vi < u in σ there existsa vertex vj < d < vi such that dvi ∈ E , contradiction

Therefore vi can be chosen next by some DFS execution ⇒(v1, v2, . . . , vi ) can be obtained by the DFS algorithm for every i

⇒ σ = (v1, v2, . . . , vn) is a DFS ordering

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 20 / 56

Lexicographic search

BFS and DFS are special cases of the Generic Graph Search⇒ we can use BFS and DFS for specific applications

still BFS and DFS can be executed in many different ways

⇒ many different BFS orderings and DFS orderings !

To “refine” BFS and DFS: we need a way to break ties:

how to choose among many “equal” candidates?

Definition

Let k , k ′, `, `′ ∈N. The ordered pair (k, `) is lexicographically smallerthan the ordered pair (k ′, `′) (denoted (k, `) < (k ′, `′)) if:

k < k ′, ork = k ′ and ` ≤ `′.

Similarly for longer sequences of integers:(5, 4, 8, 3) < (5, 4, 8, 6)

(2, 6, 4) < (2, 6, 4, 1)(3, 5, 2, 6) < (3, 6, 8)

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 21 / 56

Lexicographic search

BFS and DFS are special cases of the Generic Graph Search⇒ we can use BFS and DFS for specific applications

still BFS and DFS can be executed in many different ways

⇒ many different BFS orderings and DFS orderings !

To “refine” BFS and DFS: we need a way to break ties:

how to choose among many “equal” candidates?

Definition

Let k , k ′, `, `′ ∈N. The ordered pair (k, `) is lexicographically smallerthan the ordered pair (k ′, `′) (denoted (k, `) < (k ′, `′)) if:

k < k ′, ork = k ′ and ` ≤ `′.

Similarly for longer sequences of integers:(5, 4, 8, 3) < (5, 4, 8, 6)

(2, 6, 4) < (2, 6, 4, 1)(3, 5, 2, 6) < (3, 6, 8)

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 21 / 56

Lexicographic search

BFS and DFS are special cases of the Generic Graph Search⇒ we can use BFS and DFS for specific applications

still BFS and DFS can be executed in many different ways

⇒ many different BFS orderings and DFS orderings !

To “refine” BFS and DFS: we need a way to break ties:

how to choose among many “equal” candidates?

Definition

Let k , k ′, `, `′ ∈N. The ordered pair (k, `) is lexicographically smallerthan the ordered pair (k ′, `′) (denoted (k, `) < (k ′, `′)) if:

k < k ′, ork = k ′ and ` ≤ `′.

Similarly for longer sequences of integers:(5, 4, 8, 3) < (5, 4, 8, 6)

(2, 6, 4) < (2, 6, 4, 1)(3, 5, 2, 6) < (3, 6, 8)

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 21 / 56

Lexicographic search

BFS and DFS are special cases of the Generic Graph Search⇒ we can use BFS and DFS for specific applications

still BFS and DFS can be executed in many different ways

⇒ many different BFS orderings and DFS orderings !

To “refine” BFS and DFS: we need a way to break ties:

how to choose among many “equal” candidates?

Definition

Let k , k ′, `, `′ ∈N. The ordered pair (k, `) is lexicographically smallerthan the ordered pair (k ′, `′) (denoted (k, `) < (k ′, `′)) if:

k < k ′, ork = k ′ and ` ≤ `′.

Similarly for longer sequences of integers:(5, 4, 8, 3) < (5, 4, 8, 6)

(2, 6, 4) < (2, 6, 4, 1)(3, 5, 2, 6) < (3, 6, 8)

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 21 / 56

Lexicographic search

BFS and DFS are special cases of the Generic Graph Search⇒ we can use BFS and DFS for specific applications

still BFS and DFS can be executed in many different ways

⇒ many different BFS orderings and DFS orderings !

To “refine” BFS and DFS: we need a way to break ties:

how to choose among many “equal” candidates?

Definition

Let k , k ′, `, `′ ∈N. The ordered pair (k, `) is lexicographically smallerthan the ordered pair (k ′, `′) (denoted (k, `) < (k ′, `′)) if:

k < k ′, ork = k ′ and ` ≤ `′.

Similarly for longer sequences of integers:(5, 4, 8, 3) < (5, 4, 8, 6)(2, 6, 4) < (2, 6, 4, 1)

(3, 5, 2, 6) < (3, 6, 8)

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 21 / 56

Lexicographic search

BFS and DFS are special cases of the Generic Graph Search⇒ we can use BFS and DFS for specific applications

still BFS and DFS can be executed in many different ways

⇒ many different BFS orderings and DFS orderings !

To “refine” BFS and DFS: we need a way to break ties:

how to choose among many “equal” candidates?

Definition

Let k , k ′, `, `′ ∈N. The ordered pair (k, `) is lexicographically smallerthan the ordered pair (k ′, `′) (denoted (k, `) < (k ′, `′)) if:

k < k ′, ork = k ′ and ` ≤ `′.

Similarly for longer sequences of integers:(5, 4, 8, 3) < (5, 4, 8, 6)(2, 6, 4) < (2, 6, 4, 1)(3, 5, 2, 6) < (3, 6, 8)

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 21 / 56

Lexicographic Depth First search

Modifying again the generic search algorithm, we can “refine” DFS:

we do not use a stack any more !

we use labels and lexicographic order !

Lexicogr. Depdth First Search (LDFS) (Corneil, Krueger, 2008)

Input: a graph G = (V , E ) with |V | = n, a start vertex s ∈ VOutput: a Lexicographic DFS (LDFS) ordering σ of V

1 Assign the label ε to all vertices

2 label(s)← {0} // s is still unnumbered

3 For i = 1 to n:

4 Pick an unnumbered vertex v with lexicographically largest label

5 σ(i)← v // This assigns to v the number i

6 For each unnumbered vertex w adjacent to v:

7 prepend i to label(w)

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 22 / 56

Lexicographic Depth First search

Modifying again the generic search algorithm, we can “refine” DFS:

we do not use a stack any more !

we use labels and lexicographic order !

Lexicogr. Depdth First Search (LDFS) (Corneil, Krueger, 2008)

Input: a graph G = (V , E ) with |V | = n, a start vertex s ∈ VOutput: a Lexicographic DFS (LDFS) ordering σ of V

1 Assign the label ε to all vertices

2 label(s)← {0} // s is still unnumbered

3 For i = 1 to n:

4 Pick an unnumbered vertex v with lexicographically largest label

5 σ(i)← v // This assigns to v the number i

6 For each unnumbered vertex w adjacent to v:

7 prepend i to label(w)

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 22 / 56

Lexicographic Depth First search

we prepend the labels of all neighbors of the current vertex vwith the position of v in σ

⇒ LDFS always chooses vertices that are adjacent to as many verticeswe have recently numbered, as possible

Recall our example graph:

The digits in each label appear in decreasing order

The ordering (1, 2, 4, 5, 6, 3) is a DFS but not an LDFS ordering

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 23 / 56

Lexicographic Depth First search

we prepend the labels of all neighbors of the current vertex vwith the position of v in σ

⇒ LDFS always chooses vertices that are adjacent to as many verticeswe have recently numbered, as possible

Recall our example graph:

1

2 3

45

6

(1, 2, 5,

LDFS ordering:

3, 6,4)

labels0

1 1σ =

2

2 23 34 4

ε

εε

ε

ε

The digits in each label appear in decreasing order

The ordering (1, 2, 4, 5, 6, 3) is a DFS but not an LDFS ordering

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 23 / 56

Lexicographic Depth First search

we prepend the labels of all neighbors of the current vertex vwith the position of v in σ

⇒ LDFS always chooses vertices that are adjacent to as many verticeswe have recently numbered, as possible

Recall our example graph:

1

2 3

45

6

(1, 2, 5,

LDFS ordering:

3, 6,4)

labels0

1 1σ =

2

2 23 34 4

ε

εε

ε

ε

The digits in each label appear in decreasing order

The ordering (1, 2, 4, 5, 6, 3) is a DFS but not an LDFS ordering

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 23 / 56

Lexicographic Depth First search

we prepend the labels of all neighbors of the current vertex vwith the position of v in σ

⇒ LDFS always chooses vertices that are adjacent to as many verticeswe have recently numbered, as possible

Recall our example graph:

1

2 3

45

6

(1, 2, 5,

LDFS ordering:

3, 6,4)

labels0

1 1σ =

2

2 23 34 4

ε

εε

ε

ε

The digits in each label appear in decreasing order

The ordering (1, 2, 4, 5, 6, 3) is a DFS but not an LDFS ordering

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 23 / 56

Lexicographic Depth First search

we prepend the labels of all neighbors of the current vertex vwith the position of v in σ

⇒ LDFS always chooses vertices that are adjacent to as many verticeswe have recently numbered, as possible

Recall our example graph:

1

2 3

45

6

(1, 2, 5,

LDFS ordering:

3, 6,4)

labels0

1 1σ =

2

2 23 34 4

ε

εε

ε

ε

The digits in each label appear in decreasing order

The ordering (1, 2, 4, 5, 6, 3) is a DFS but not an LDFS ordering

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 23 / 56

Lexicographic Depth First search

we prepend the labels of all neighbors of the current vertex vwith the position of v in σ

⇒ LDFS always chooses vertices that are adjacent to as many verticeswe have recently numbered, as possible

Recall our example graph:

1

2 3

45

6

(1, 2, 5,

LDFS ordering:

3, 6,4)

labels0

1 1σ =

2

2 23 34 4

ε

εε

ε

ε

The digits in each label appear in decreasing order

The ordering (1, 2, 4, 5, 6, 3) is a DFS but not an LDFS ordering

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 23 / 56

Lexicographic Depth First search

we prepend the labels of all neighbors of the current vertex vwith the position of v in σ

⇒ LDFS always chooses vertices that are adjacent to as many verticeswe have recently numbered, as possible

Recall our example graph:

1

2 3

45

6

(1, 2, 5,

LDFS ordering:

3, 6,4)

labels0

1 1σ =

2

2 23 34 4

ε

εε

ε

ε

The digits in each label appear in decreasing order

The ordering (1, 2, 4, 5, 6, 3) is a DFS but not an LDFS ordering

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 23 / 56

Lexicographic Depth First search

we prepend the labels of all neighbors of the current vertex vwith the position of v in σ

⇒ LDFS always chooses vertices that are adjacent to as many verticeswe have recently numbered, as possible

Recall our example graph:

1

2 3

45

6

(1, 2, 5,

LDFS ordering:

3, 6,4)

labels0

1 1σ =

2

2 23 34 4

ε

εε

ε

ε

The digits in each label appear in decreasing order

The ordering (1, 2, 4, 5, 6, 3) is a DFS but not an LDFS ordering

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 23 / 56

Lexicographic Depth First search

we prepend the labels of all neighbors of the current vertex vwith the position of v in σ

⇒ LDFS always chooses vertices that are adjacent to as many verticeswe have recently numbered, as possible

Recall our example graph:

1

2 3

45

6

(1, 2, 5,

LDFS ordering:

3, 6,4)

labels0

1 1σ =

2

2 23 34 4

ε

εε

ε

ε

The digits in each label appear in decreasing order

The ordering (1, 2, 4, 5, 6, 3) is a DFS but not an LDFS ordering

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 23 / 56

Lexicographic Depth First search

we prepend the labels of all neighbors of the current vertex vwith the position of v in σ

⇒ LDFS always chooses vertices that are adjacent to as many verticeswe have recently numbered, as possible

Recall our example graph:

1

2 3

45

6

(1, 2, 5,

LDFS ordering:

3, 6,4)

labels0

1 1σ =

2

2 23 34 4

ε

εε

ε

ε

The digits in each label appear in decreasing order

The ordering (1, 2, 4, 5, 6, 3) is a DFS but not an LDFS ordering

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 23 / 56

Lexicographic Depth First search

we prepend the labels of all neighbors of the current vertex vwith the position of v in σ

⇒ LDFS always chooses vertices that are adjacent to as many verticeswe have recently numbered, as possible

Recall our example graph:

1

2 3

45

6

(1, 2, 5,

LDFS ordering:

3, 6,4)

labels0

1 1σ =

2

2 23 34 4

ε

εε

ε

ε

The digits in each label appear in decreasing order

The ordering (1, 2, 4, 5, 6, 3) is a DFS but not an LDFS ordering

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 23 / 56

Lexicographic Depth First search

we prepend the labels of all neighbors of the current vertex vwith the position of v in σ

⇒ LDFS always chooses vertices that are adjacent to as many verticeswe have recently numbered, as possible

Recall our example graph:

1

2 3

45

6

(1, 2, 5,

LDFS ordering:

3, 6,4)

labels0

1 1σ =

2

2 23 34 4

ε

εε

ε

ε

The digits in each label appear in decreasing order

The ordering (1, 2, 4, 5, 6, 3) is a DFS but not an LDFS ordering

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 23 / 56

Lexicographic Depth First search

we prepend the labels of all neighbors of the current vertex vwith the position of v in σ

⇒ LDFS always chooses vertices that are adjacent to as many verticeswe have recently numbered, as possible

Recall our example graph:

1

2 3

45

6

(1, 2, 5,

LDFS ordering:

3, 6,4)

labels0

1 1σ =

2

2 23 34 4

ε

εε

ε

ε

The digits in each label appear in decreasing order

The ordering (1, 2, 4, 5, 6, 3) is a DFS but not an LDFS ordering

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 23 / 56

Lexicographic Depth First search

we prepend the labels of all neighbors of the current vertex vwith the position of v in σ

⇒ LDFS always chooses vertices that are adjacent to as many verticeswe have recently numbered, as possible

Recall our example graph:

1

2 3

45

6

(1, 2, 5,

LDFS ordering:

3, 6,4)

labels0

1 1σ =

2

2 23 34 4

ε

εε

ε

ε

The digits in each label appear in decreasing order

The ordering (1, 2, 4, 5, 6, 3) is a DFS but not an LDFS ordering

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 23 / 56

Lexicographic Depth First search

How can we check whether an ordering σ is an LDFS ordering?

Assume that σ visits vertices a, b, c in this order, where ab /∈ E , ac ∈ E .

How could b have been chosen before c in σ?

Since LDFS is a DFS ⇒ σ must have property (D)i.e. there exists a vertex d with a < d < b such that bd ∈ E

Is this enough? NO.

Property (LD)

Given an ordering σ of V , if a < b < c in σ, ab /∈ E , and ac ∈ E , then:

there exists a vertex d with a < d < b such that db ∈ E and dc /∈ E .

a b cd

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 24 / 56

Lexicographic Depth First search

How can we check whether an ordering σ is an LDFS ordering?

Assume that σ visits vertices a, b, c in this order, where ab /∈ E , ac ∈ E .

How could b have been chosen before c in σ?

Since LDFS is a DFS ⇒ σ must have property (D)i.e. there exists a vertex d with a < d < b such that bd ∈ E

Is this enough? NO.

Property (LD)

Given an ordering σ of V , if a < b < c in σ, ab /∈ E , and ac ∈ E , then:

there exists a vertex d with a < d < b such that db ∈ E and dc /∈ E .

a b cd

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 24 / 56

Lexicographic Depth First search

How can we check whether an ordering σ is an LDFS ordering?

Assume that σ visits vertices a, b, c in this order, where ab /∈ E , ac ∈ E .

How could b have been chosen before c in σ?

Since LDFS is a DFS ⇒ σ must have property (D)i.e. there exists a vertex d with a < d < b such that bd ∈ E

Is this enough? NO.

Property (LD)

Given an ordering σ of V , if a < b < c in σ, ab /∈ E , and ac ∈ E , then:

there exists a vertex d with a < d < b such that db ∈ E and dc /∈ E .

a b cd

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 24 / 56

Lexicographic Depth First search

How can we check whether an ordering σ is an LDFS ordering?

Assume that σ visits vertices a, b, c in this order, where ab /∈ E , ac ∈ E .

How could b have been chosen before c in σ?

Since LDFS is a DFS ⇒ σ must have property (D)i.e. there exists a vertex d with a < d < b such that bd ∈ E

Is this enough? NO.

Property (LD)

Given an ordering σ of V , if a < b < c in σ, ab /∈ E , and ac ∈ E , then:

there exists a vertex d with a < d < b such that db ∈ E and dc /∈ E .

a b cd

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 24 / 56

Lexicographic Depth First search

Property (LD) can characterize LDFS orderings:

Theorem (Corneil, Krueger, SIAM J. on Discr. Math., 2008)

For any graph G = (V , E ), an ordering σ of V is an LDFS ordering of Gif and only if σ satisfies property (LD).

Proof.

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 25 / 56

Lexicographic Depth First search

Property (LD) can characterize LDFS orderings:

Theorem (Corneil, Krueger, SIAM J. on Discr. Math., 2008)

For any graph G = (V , E ), an ordering σ of V is an LDFS ordering of Gif and only if σ satisfies property (LD).

Notation:

the ordering σ is a mapping σ : N→ V

⇒ σ(i) = v means: “the ith vertex in σ is v”

⇒ σ−1(v) = i means: “the position of v in σ is i”

Proof.

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 25 / 56

Lexicographic Depth First search

Property (LD) can characterize LDFS orderings:

Theorem (Corneil, Krueger, SIAM J. on Discr. Math., 2008)

For any graph G = (V , E ), an ordering σ of V is an LDFS ordering of Gif and only if σ satisfies property (LD).

Notation:

the ordering σ is a mapping σ : N→ V

⇒ σ(i) = v means: “the ith vertex in σ is v”

⇒ σ−1(v) = i means: “the position of v in σ is i”

for two vertices u, v : labelu(v) is the label assigned to vertex vimmediately before vertex u was numbered

Proof.

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 25 / 56

Lexicographic Depth First search

Property (LD) can characterize LDFS orderings:

Theorem (Corneil, Krueger, SIAM J. on Discr. Math., 2008)

For any graph G = (V , E ), an ordering σ of V is an LDFS ordering of Gif and only if σ satisfies property (LD).

Proof.

(⇒): Suppose that σ is an LDFS ordering.

Let a < b < c in σ, where ab /∈ E and ac ∈ E

Since b was numbered before c ⇒ labelb(b) ≥ labelb(c)

Since σ−1(a) appears in labelb(c) but not in labelb(b):

⇒ labelb(b) includes a digit j > σ−1(a) that does not appear in labelb(c)

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 25 / 56

Lexicographic Depth First search

Property (LD) can characterize LDFS orderings:

Theorem (Corneil, Krueger, SIAM J. on Discr. Math., 2008)

For any graph G = (V , E ), an ordering σ of V is an LDFS ordering of Gif and only if σ satisfies property (LD).

Proof.

(⇒): Suppose that σ is an LDFS ordering.

Let a < b < c in σ, where ab /∈ E and ac ∈ E

Since b was numbered before c ⇒ labelb(b) ≥ labelb(c)

Since σ−1(a) appears in labelb(c) but not in labelb(b):

⇒ labelb(b) includes a digit j > σ−1(a) that does not appear in labelb(c)

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 25 / 56

Lexicographic Depth First search

Property (LD) can characterize LDFS orderings:

Theorem (Corneil, Krueger, SIAM J. on Discr. Math., 2008)

For any graph G = (V , E ), an ordering σ of V is an LDFS ordering of Gif and only if σ satisfies property (LD).

Proof.

Let d = σ(j). Then:

d < b in σ, since d was numbered before b

db ∈ E , since j = σ−1(d) appears in labelb(b)

d > a in σ, since j = σ−1(d) > σ−1(a)

dc /∈ E , since j = σ−1(d) does not appear in labelb(c)

⇒ σ satisfies property (LD)

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 25 / 56

Lexicographic Depth First search

Property (LD) can characterize LDFS orderings:

Theorem (Corneil, Krueger, SIAM J. on Discr. Math., 2008)

For any graph G = (V , E ), an ordering σ of V is an LDFS ordering of Gif and only if σ satisfies property (LD).

Proof.

Let d = σ(j). Then:

d < b in σ, since d was numbered before b

db ∈ E , since j = σ−1(d) appears in labelb(b)

d > a in σ, since j = σ−1(d) > σ−1(a)

dc /∈ E , since j = σ−1(d) does not appear in labelb(c)

⇒ σ satisfies property (LD)

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 25 / 56

Lexicographic Depth First search

Property (LD) can characterize LDFS orderings:

Theorem (Corneil, Krueger, SIAM J. on Discr. Math., 2008)

For any graph G = (V , E ), an ordering σ of V is an LDFS ordering of Gif and only if σ satisfies property (LD).

Proof.

Let d = σ(j). Then:

d < b in σ, since d was numbered before b

db ∈ E , since j = σ−1(d) appears in labelb(b)

d > a in σ, since j = σ−1(d) > σ−1(a)

dc /∈ E , since j = σ−1(d) does not appear in labelb(c)

⇒ σ satisfies property (LD)

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 25 / 56

Lexicographic Depth First search

Property (LD) can characterize LDFS orderings:

Theorem (Corneil, Krueger, SIAM J. on Discr. Math., 2008)

For any graph G = (V , E ), an ordering σ of V is an LDFS ordering of Gif and only if σ satisfies property (LD).

Proof.

Let d = σ(j). Then:

d < b in σ, since d was numbered before b

db ∈ E , since j = σ−1(d) appears in labelb(b)

d > a in σ, since j = σ−1(d) > σ−1(a)

dc /∈ E , since j = σ−1(d) does not appear in labelb(c)

⇒ σ satisfies property (LD)

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 25 / 56

Lexicographic Depth First search

Property (LD) can characterize LDFS orderings:

Theorem (Corneil, Krueger, SIAM J. on Discr. Math., 2008)

For any graph G = (V , E ), an ordering σ of V is an LDFS ordering of Gif and only if σ satisfies property (LD).

Proof.

Let d = σ(j). Then:

d < b in σ, since d was numbered before b

db ∈ E , since j = σ−1(d) appears in labelb(b)

d > a in σ, since j = σ−1(d) > σ−1(a)

dc /∈ E , since j = σ−1(d) does not appear in labelb(c)

⇒ σ satisfies property (LD)

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 25 / 56

Lexicographic Depth First search

Proof.

(⇐): Suppose that σ = (v1, v2, . . . , vn) is satisfies property (LD).Proof by contradiction:

Suppose that (v1, v2, . . . , vi−1) can be obtained by the LDFSalgorithm, but σi−1 = (v1, v2, . . . , vi ) can not (for some i ≤ n)

i.e. vi is the first vertex that can not be chosen next by LDFS

Let u be a vertex that the algorithm can choose next by LDFS(many equal labels ⇒ many choices for u ! )

At the point when u is chosen next by the algorithm:

u is preferred over vi ⇒ label(u) > label(vi )

let j be the largest digit in label(u) that is not in label(vi )

⇒ vj is the rightmost vertex in σi−1 with vju ∈ E and vjvi /∈ E

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 26 / 56

Lexicographic Depth First search

Proof.

(⇐): Suppose that σ = (v1, v2, . . . , vn) is satisfies property (LD).Proof by contradiction:

Suppose that (v1, v2, . . . , vi−1) can be obtained by the LDFSalgorithm, but σi−1 = (v1, v2, . . . , vi ) can not (for some i ≤ n)

i.e. vi is the first vertex that can not be chosen next by LDFS

Let u be a vertex that the algorithm can choose next by LDFS(many equal labels ⇒ many choices for u ! )

At the point when u is chosen next by the algorithm:

u is preferred over vi ⇒ label(u) > label(vi )

let j be the largest digit in label(u) that is not in label(vi )

⇒ vj is the rightmost vertex in σi−1 with vju ∈ E and vjvi /∈ E

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 26 / 56

Lexicographic Depth First search

Proof.

(⇐): Suppose that σ = (v1, v2, . . . , vn) is satisfies property (LD).Proof by contradiction:

Suppose that (v1, v2, . . . , vi−1) can be obtained by the LDFSalgorithm, but σi−1 = (v1, v2, . . . , vi ) can not (for some i ≤ n)

i.e. vi is the first vertex that can not be chosen next by LDFS

Let u be a vertex that the algorithm can choose next by LDFS(many equal labels ⇒ many choices for u ! )

At the point when u is chosen next by the algorithm:

u is preferred over vi ⇒ label(u) > label(vi )

let j be the largest digit in label(u) that is not in label(vi )

⇒ vj is the rightmost vertex in σi−1 with vju ∈ E and vjvi /∈ E

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 26 / 56

Lexicographic Depth First search

Proof.

(⇐): Suppose that σ = (v1, v2, . . . , vn) is satisfies property (LD).Proof by contradiction:

Suppose that (v1, v2, . . . , vi−1) can be obtained by the LDFSalgorithm, but σi−1 = (v1, v2, . . . , vi ) can not (for some i ≤ n)

i.e. vi is the first vertex that can not be chosen next by LDFS

Let u be a vertex that the algorithm can choose next by LDFS(many equal labels ⇒ many choices for u ! )

At the point when u is chosen next by the algorithm:

u is preferred over vi ⇒ label(u) > label(vi )

let j be the largest digit in label(u) that is not in label(vi )

⇒ vj is the rightmost vertex in σi−1 with vju ∈ E and vjvi /∈ E

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 26 / 56

Lexicographic Depth First search

Proof.

(⇐): Suppose that σ = (v1, v2, . . . , vn) is satisfies property (LD).Proof by contradiction:

Suppose that (v1, v2, . . . , vi−1) can be obtained by the LDFSalgorithm, but σi−1 = (v1, v2, . . . , vi ) can not (for some i ≤ n)

σ has property (LD) ⇒ for the triple vj < vi < u in σ there existsa vertex vj < d < vi such that dvi ∈ E and du /∈ E

⇒ the position of d in σ (i.e. σ−1(d)) is in label(vi ) but not in label(u)

vj < d ⇒ j < σ−1(d) ⇒ label(vi ) > label(u) (by the choice of j),contradiction

Therefore vi can be chosen next by LDFS ⇒ (v1, v2, . . . , vi ) can beobtained by the LDFS algorithm for every i

⇒ σ = (v1, v2, . . . , vn) is an LDFS ordering

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 26 / 56

Lexicographic Depth First search

Proof.

(⇐): Suppose that σ = (v1, v2, . . . , vn) is satisfies property (LD).Proof by contradiction:

Suppose that (v1, v2, . . . , vi−1) can be obtained by the LDFSalgorithm, but σi−1 = (v1, v2, . . . , vi ) can not (for some i ≤ n)

σ has property (LD) ⇒ for the triple vj < vi < u in σ there existsa vertex vj < d < vi such that dvi ∈ E and du /∈ E

⇒ the position of d in σ (i.e. σ−1(d)) is in label(vi ) but not in label(u)

vj < d ⇒ j < σ−1(d) ⇒ label(vi ) > label(u) (by the choice of j),contradiction

Therefore vi can be chosen next by LDFS ⇒ (v1, v2, . . . , vi ) can beobtained by the LDFS algorithm for every i

⇒ σ = (v1, v2, . . . , vn) is an LDFS ordering

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 26 / 56

Lexicographic Depth First search

Proof.

(⇐): Suppose that σ = (v1, v2, . . . , vn) is satisfies property (LD).Proof by contradiction:

Suppose that (v1, v2, . . . , vi−1) can be obtained by the LDFSalgorithm, but σi−1 = (v1, v2, . . . , vi ) can not (for some i ≤ n)

σ has property (LD) ⇒ for the triple vj < vi < u in σ there existsa vertex vj < d < vi such that dvi ∈ E and du /∈ E

⇒ the position of d in σ (i.e. σ−1(d)) is in label(vi ) but not in label(u)

vj < d ⇒ j < σ−1(d) ⇒ label(vi ) > label(u) (by the choice of j),contradiction

Therefore vi can be chosen next by LDFS ⇒ (v1, v2, . . . , vi ) can beobtained by the LDFS algorithm for every i

⇒ σ = (v1, v2, . . . , vn) is an LDFS ordering

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 26 / 56

Lexicographic Depth First search

Proof.

(⇐): Suppose that σ = (v1, v2, . . . , vn) is satisfies property (LD).Proof by contradiction:

Suppose that (v1, v2, . . . , vi−1) can be obtained by the LDFSalgorithm, but σi−1 = (v1, v2, . . . , vi ) can not (for some i ≤ n)

σ has property (LD) ⇒ for the triple vj < vi < u in σ there existsa vertex vj < d < vi such that dvi ∈ E and du /∈ E

⇒ the position of d in σ (i.e. σ−1(d)) is in label(vi ) but not in label(u)

vj < d ⇒ j < σ−1(d) ⇒ label(vi ) > label(u) (by the choice of j),contradiction

Therefore vi can be chosen next by LDFS ⇒ (v1, v2, . . . , vi ) can beobtained by the LDFS algorithm for every i

⇒ σ = (v1, v2, . . . , vn) is an LDFS ordering

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 26 / 56

Lexicographic Depth First search

Proof.

(⇐): Suppose that σ = (v1, v2, . . . , vn) is satisfies property (LD).Proof by contradiction:

Suppose that (v1, v2, . . . , vi−1) can be obtained by the LDFSalgorithm, but σi−1 = (v1, v2, . . . , vi ) can not (for some i ≤ n)

σ has property (LD) ⇒ for the triple vj < vi < u in σ there existsa vertex vj < d < vi such that dvi ∈ E and du /∈ E

⇒ the position of d in σ (i.e. σ−1(d)) is in label(vi ) but not in label(u)

vj < d ⇒ j < σ−1(d) ⇒ label(vi ) > label(u) (by the choice of j),contradiction

Therefore vi can be chosen next by LDFS ⇒ (v1, v2, . . . , vi ) can beobtained by the LDFS algorithm for every i

⇒ σ = (v1, v2, . . . , vn) is an LDFS ordering

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 26 / 56

Lexicographic Breadth First search

Modifying once again the generic search algorithm, we can “refine” BFSusing labels and lexicographic order:

we do not use a queue any more !

Lexicogr. Breadth First Search (LBFS) (Rose, Tarjan, Lueker, 1976)

Input: a graph G = (V , E ) with |V | = n, a start vertex s ∈ VOutput: a Lexicographic BFS (LBFS) ordering σ of V

1 Assign the label ε to all vertices

2 label(s)← {n + 1} // s is still unnumbered

3 For i = 1 to n:

4 Pick an unnumbered vertex v with lexicographically largest label

5 σ(i)← v // This assigns to v the number i

6 For each unnumbered vertex w adjacent to v:

7 append (n− i) to label(w)

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 27 / 56

Lexicographic Breadth First search

Modifying once again the generic search algorithm, we can “refine” BFSusing labels and lexicographic order:

we do not use a queue any more !

Lexicogr. Breadth First Search (LBFS) (Rose, Tarjan, Lueker, 1976)

Input: a graph G = (V , E ) with |V | = n, a start vertex s ∈ VOutput: a Lexicographic BFS (LBFS) ordering σ of V

1 Assign the label ε to all vertices

2 label(s)← {n + 1} // s is still unnumbered

3 For i = 1 to n:

4 Pick an unnumbered vertex v with lexicographically largest label

5 σ(i)← v // This assigns to v the number i

6 For each unnumbered vertex w adjacent to v:

7 append (n− i) to label(w)

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 27 / 56

Lexicographic Breadth First search

we append the labels of all neighbors of the current vertex vwith the position of v in σ

⇒ LBFS always chooses vertices that are adjacent to as many verticeswe have numbered early, as possible

Recall our example graph:

The digits in each label appear in decreasing order (like in LDFS)

The ordering (1, 2, 3, 4, 5, 6) is a BFS but not an LBFS ordering

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 28 / 56

Lexicographic Breadth First search

we append the labels of all neighbors of the current vertex vwith the position of v in σ

⇒ LBFS always chooses vertices that are adjacent to as many verticeswe have numbered early, as possible

Recall our example graph:

1

2 3

45

6

(1, 2, 5,3,

labels

σ =

34

ε

εε

ε

ε

LBFS ordering: 74,6)

6 65

5 543

The digits in each label appear in decreasing order (like in LDFS)

The ordering (1, 2, 3, 4, 5, 6) is a BFS but not an LBFS ordering

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 28 / 56

Lexicographic Breadth First search

we append the labels of all neighbors of the current vertex vwith the position of v in σ

⇒ LBFS always chooses vertices that are adjacent to as many verticeswe have numbered early, as possible

Recall our example graph:

1

2 3

45

6

(1, 2, 5,3,

labels

σ =

34

ε

εε

ε

ε

LBFS ordering: 74,6)

6 65

5 543

The digits in each label appear in decreasing order (like in LDFS)

The ordering (1, 2, 3, 4, 5, 6) is a BFS but not an LBFS ordering

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 28 / 56

Lexicographic Breadth First search

we append the labels of all neighbors of the current vertex vwith the position of v in σ

⇒ LBFS always chooses vertices that are adjacent to as many verticeswe have numbered early, as possible

Recall our example graph:

1

2 3

45

6

(1, 2, 5,3,

labels

σ =

34

ε

εε

ε

ε

LBFS ordering: 74,6)

6 65

5 543

The digits in each label appear in decreasing order (like in LDFS)

The ordering (1, 2, 3, 4, 5, 6) is a BFS but not an LBFS ordering

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 28 / 56

Lexicographic Breadth First search

we append the labels of all neighbors of the current vertex vwith the position of v in σ

⇒ LBFS always chooses vertices that are adjacent to as many verticeswe have numbered early, as possible

Recall our example graph:

1

2 3

45

6

(1, 2, 5,3,

labels

σ =

34

ε

εε

ε

ε

LBFS ordering: 74,6)

6 65

5 543

The digits in each label appear in decreasing order (like in LDFS)

The ordering (1, 2, 3, 4, 5, 6) is a BFS but not an LBFS ordering

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 28 / 56

Lexicographic Breadth First search

we append the labels of all neighbors of the current vertex vwith the position of v in σ

⇒ LBFS always chooses vertices that are adjacent to as many verticeswe have numbered early, as possible

Recall our example graph:

1

2 3

45

6

(1, 2, 5,3,

labels

σ =

34

ε

εε

ε

ε

LBFS ordering: 74,6)

6 65

5 543

The digits in each label appear in decreasing order (like in LDFS)

The ordering (1, 2, 3, 4, 5, 6) is a BFS but not an LBFS ordering

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 28 / 56

Lexicographic Breadth First search

we append the labels of all neighbors of the current vertex vwith the position of v in σ

⇒ LBFS always chooses vertices that are adjacent to as many verticeswe have numbered early, as possible

Recall our example graph:

1

2 3

45

6

(1, 2, 5,3,

labels

σ =

34

ε

εε

ε

ε

LBFS ordering: 74,6)

6 65

5 543

The digits in each label appear in decreasing order (like in LDFS)

The ordering (1, 2, 3, 4, 5, 6) is a BFS but not an LBFS ordering

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 28 / 56

Lexicographic Breadth First search

we append the labels of all neighbors of the current vertex vwith the position of v in σ

⇒ LBFS always chooses vertices that are adjacent to as many verticeswe have numbered early, as possible

Recall our example graph:

1

2 3

45

6

(1, 2, 5,3,

labels

σ =

34

ε

εε

ε

ε

LBFS ordering: 74,6)

6 65

5 543

The digits in each label appear in decreasing order (like in LDFS)

The ordering (1, 2, 3, 4, 5, 6) is a BFS but not an LBFS ordering

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 28 / 56

Lexicographic Breadth First search

we append the labels of all neighbors of the current vertex vwith the position of v in σ

⇒ LBFS always chooses vertices that are adjacent to as many verticeswe have numbered early, as possible

Recall our example graph:

1

2 3

45

6

(1, 2, 5,3,

labels

σ =

34

ε

εε

ε

ε

LBFS ordering: 74,6)

6 65

5 543

The digits in each label appear in decreasing order (like in LDFS)

The ordering (1, 2, 3, 4, 5, 6) is a BFS but not an LBFS ordering

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 28 / 56

Lexicographic Breadth First search

we append the labels of all neighbors of the current vertex vwith the position of v in σ

⇒ LBFS always chooses vertices that are adjacent to as many verticeswe have numbered early, as possible

Recall our example graph:

1

2 3

45

6

(1, 2, 5,3,

labels

σ =

34

ε

εε

ε

ε

LBFS ordering: 74,6)

6 65

5 543

The digits in each label appear in decreasing order (like in LDFS)

The ordering (1, 2, 3, 4, 5, 6) is a BFS but not an LBFS ordering

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 28 / 56

Lexicographic Breadth First search

we append the labels of all neighbors of the current vertex vwith the position of v in σ

⇒ LBFS always chooses vertices that are adjacent to as many verticeswe have numbered early, as possible

Recall our example graph:

1

2 3

45

6

(1, 2, 5,3,

labels

σ =

34

ε

εε

ε

ε

LBFS ordering: 74,6)

6 65

5 543

The digits in each label appear in decreasing order (like in LDFS)

The ordering (1, 2, 3, 4, 5, 6) is a BFS but not an LBFS ordering

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 28 / 56

Lexicographic Breadth First search

we append the labels of all neighbors of the current vertex vwith the position of v in σ

⇒ LBFS always chooses vertices that are adjacent to as many verticeswe have numbered early, as possible

Recall our example graph:

1

2 3

45

6

(1, 2, 5,3,

labels

σ =

34

ε

εε

ε

ε

LBFS ordering: 74,6)

6 65

5 543

The digits in each label appear in decreasing order (like in LDFS)

The ordering (1, 2, 3, 4, 5, 6) is a BFS but not an LBFS ordering

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 28 / 56

Lexicographic Breadth First search

we append the labels of all neighbors of the current vertex vwith the position of v in σ

⇒ LBFS always chooses vertices that are adjacent to as many verticeswe have numbered early, as possible

Recall our example graph:

1

2 3

45

6

(1, 2, 5,3,

labels

σ =

34

ε

εε

ε

ε

LBFS ordering: 74,6)

6 65

5 543

The digits in each label appear in decreasing order (like in LDFS)

The ordering (1, 2, 3, 4, 5, 6) is a BFS but not an LBFS ordering

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 28 / 56

Lexicographic Breadth First search

How can we check whether an ordering σ is an LBFS ordering?

Assume that σ visits vertices a, b, c in this order, where ab /∈ E , ac ∈ E .

How could b have been chosen before c in σ?

Since LBFS is a BFS ⇒ σ must have property (B)i.e. there exists a vertex d < a such that db ∈ E

Is this enough? NO.

Property (LB)

Given an ordering σ of V , if a < b < c in σ, ab /∈ E , and ac ∈ E , then:

there exists a vertex d < a such that db ∈ E and dc /∈ E .

a b cd

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 29 / 56

Lexicographic Breadth First search

How can we check whether an ordering σ is an LBFS ordering?

Assume that σ visits vertices a, b, c in this order, where ab /∈ E , ac ∈ E .

How could b have been chosen before c in σ?

Since LBFS is a BFS ⇒ σ must have property (B)i.e. there exists a vertex d < a such that db ∈ E

Is this enough? NO.

Property (LB)

Given an ordering σ of V , if a < b < c in σ, ab /∈ E , and ac ∈ E , then:

there exists a vertex d < a such that db ∈ E and dc /∈ E .

a b cd

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 29 / 56

Lexicographic Breadth First search

How can we check whether an ordering σ is an LBFS ordering?

Assume that σ visits vertices a, b, c in this order, where ab /∈ E , ac ∈ E .

How could b have been chosen before c in σ?

Since LBFS is a BFS ⇒ σ must have property (B)i.e. there exists a vertex d < a such that db ∈ E

Is this enough? NO.

Property (LB)

Given an ordering σ of V , if a < b < c in σ, ab /∈ E , and ac ∈ E , then:

there exists a vertex d < a such that db ∈ E and dc /∈ E .

a b cd

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 29 / 56

Lexicographic Breadth First search

How can we check whether an ordering σ is an LBFS ordering?

Assume that σ visits vertices a, b, c in this order, where ab /∈ E , ac ∈ E .

How could b have been chosen before c in σ?

Since LBFS is a BFS ⇒ σ must have property (B)i.e. there exists a vertex d < a such that db ∈ E

Is this enough? NO.

Property (LB)

Given an ordering σ of V , if a < b < c in σ, ab /∈ E , and ac ∈ E , then:

there exists a vertex d < a such that db ∈ E and dc /∈ E .

a b cd

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 29 / 56

Lexicographic Breadth First search

Property (LB) can characterize LBFS orderings:

Theorem (Rose, Tarjan, Lueker, SIAM Journal on Computing, 1976)

For any graph G = (V , E ), if an ordering σ of V is an LBFS ordering of Gthen σ satisfies property (LB).

Proof.

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 30 / 56

Lexicographic Breadth First search

Property (LB) can characterize LBFS orderings:

Theorem (Rose, Tarjan, Lueker, SIAM Journal on Computing, 1976)

For any graph G = (V , E ), if an ordering σ of V is an LBFS ordering of Gthen σ satisfies property (LB).

Later also the other direction has been proved:

Theorem (Brandstadt, Dragan, Nicolai, Discrete Math., 1997)

For any graph G = (V , E ), if an ordering σ of V satisfies property (LB)then σ is an LBFS ordering of G.

Proof.

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 30 / 56

Lexicographic Breadth First search

Property (LB) can characterize LBFS orderings:

Theorem (Rose, Tarjan, Lueker, SIAM Journal on Computing, 1976)

For any graph G = (V , E ), if an ordering σ of V is an LBFS ordering of Gthen σ satisfies property (LB).

Later also the other direction has been proved:

Theorem (Brandstadt, Dragan, Nicolai, Discrete Math., 1997)

For any graph G = (V , E ), if an ordering σ of V satisfies property (LB)then σ is an LBFS ordering of G.

Recall:

for two vertices u, v : labelu(v) is the label assigned to vertex vimmediately before vertex u was numbered

Proof.

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 30 / 56

Lexicographic Breadth First search

Property (LB) can characterize LBFS orderings:

Theorem (Rose, Tarjan, Lueker, SIAM Journal on Computing, 1976)

For any graph G = (V , E ), if an ordering σ of V is an LBFS ordering of Gthen σ satisfies property (LB).

Proof.

Suppose that σ is an LBFS ordering.

Let a < b < c in σ, where ab /∈ E and ac ∈ E

Since b was numbered before c ⇒ labelb(b) ≥ labelb(c)

Since (n− σ−1(a)) appears in labelb(c) but not in labelb(b):

⇒ labelb(b) includes a digit (n− j) > (n− σ−1(a)) thatdoes not appear in labelb(c)

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 30 / 56

Lexicographic Breadth First search

Property (LB) can characterize LBFS orderings:

Theorem (Rose, Tarjan, Lueker, SIAM Journal on Computing, 1976)

For any graph G = (V , E ), if an ordering σ of V is an LBFS ordering of Gthen σ satisfies property (LB).

Proof.

Suppose that σ is an LBFS ordering.

Let a < b < c in σ, where ab /∈ E and ac ∈ E

Since b was numbered before c ⇒ labelb(b) ≥ labelb(c)

Since (n− σ−1(a)) appears in labelb(c) but not in labelb(b):

⇒ labelb(b) includes a digit (n− j) > (n− σ−1(a)) thatdoes not appear in labelb(c)

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 30 / 56

Lexicographic Breadth First search

Property (LB) can characterize LBFS orderings:

Theorem (Rose, Tarjan, Lueker, SIAM Journal on Computing, 1976)

For any graph G = (V , E ), if an ordering σ of V is an LBFS ordering of Gthen σ satisfies property (LB).

Proof.

Let d = σ(j). Then:

db ∈ E , since (n− j) = (n− σ−1(d)) appears in labelb(b)

d < a in σ, since (n− j) = (n− σ−1(d)) > (n− σ−1(a))

dc /∈ E , since (n− j) = (n− σ−1(d)) does not appear in labelb(c)

⇒ σ satisfies property (LB)

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 30 / 56

Lexicographic Breadth First search

Property (LB) can characterize LBFS orderings:

Theorem (Rose, Tarjan, Lueker, SIAM Journal on Computing, 1976)

For any graph G = (V , E ), if an ordering σ of V is an LBFS ordering of Gthen σ satisfies property (LB).

Proof.

Let d = σ(j). Then:

db ∈ E , since (n− j) = (n− σ−1(d)) appears in labelb(b)

d < a in σ, since (n− j) = (n− σ−1(d)) > (n− σ−1(a))

dc /∈ E , since (n− j) = (n− σ−1(d)) does not appear in labelb(c)

⇒ σ satisfies property (LB)

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 30 / 56

Lexicographic Breadth First search

Property (LB) can characterize LBFS orderings:

Theorem (Rose, Tarjan, Lueker, SIAM Journal on Computing, 1976)

For any graph G = (V , E ), if an ordering σ of V is an LBFS ordering of Gthen σ satisfies property (LB).

Proof.

Let d = σ(j). Then:

db ∈ E , since (n− j) = (n− σ−1(d)) appears in labelb(b)

d < a in σ, since (n− j) = (n− σ−1(d)) > (n− σ−1(a))

dc /∈ E , since (n− j) = (n− σ−1(d)) does not appear in labelb(c)

⇒ σ satisfies property (LB)

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 30 / 56

Lexicographic Breadth First search

Property (LB) can characterize LBFS orderings:

Theorem (Rose, Tarjan, Lueker, SIAM Journal on Computing, 1976)

For any graph G = (V , E ), if an ordering σ of V is an LBFS ordering of Gthen σ satisfies property (LB).

Proof.

Let d = σ(j). Then:

db ∈ E , since (n− j) = (n− σ−1(d)) appears in labelb(b)

d < a in σ, since (n− j) = (n− σ−1(d)) > (n− σ−1(a))

dc /∈ E , since (n− j) = (n− σ−1(d)) does not appear in labelb(c)

⇒ σ satisfies property (LB)

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 30 / 56

Lexicographic Breadth First search

Theorem (Brandstadt, Dragan, Nicolai, Discrete Math., 1997)

For any graph G = (V , E ), if an ordering σ of V satisfies property (LB)then σ is an LBFS ordering of G.

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 31 / 56

Lexicographic Breadth First search

Theorem (Brandstadt, Dragan, Nicolai, Discrete Math., 1997)

For any graph G = (V , E ), if an ordering σ of V satisfies property (LB)then σ is an LBFS ordering of G.

Proof.

Suppose that σ = (v1, v2, . . . , vn) is satisfies property (LB).

Suppose that (v1, v2, . . . , vi−1) can be obtained by the LBFSalgorithm, but σi−1 = (v1, v2, . . . , vi ) can not (for some i ≤ n)

Let u be a vertex that the algorithm can choose next by LBFS(many equal labels ⇒ many choices for u ! )

At the point when u is chosen next by the algorithm:

u is preferred over vi ⇒ label(u) > label(vi )

let (n− j) be the largest digit in label(u) that is not in label(vi )

⇒ vj is the leftmost vertex in σi−1 with vju ∈ E and vjvi /∈ E

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 31 / 56

Lexicographic Breadth First search

Theorem (Brandstadt, Dragan, Nicolai, Discrete Math., 1997)

For any graph G = (V , E ), if an ordering σ of V satisfies property (LB)then σ is an LBFS ordering of G.

Proof.

Suppose that σ = (v1, v2, . . . , vn) is satisfies property (LB).

Suppose that (v1, v2, . . . , vi−1) can be obtained by the LBFSalgorithm, but σi−1 = (v1, v2, . . . , vi ) can not (for some i ≤ n)

Let u be a vertex that the algorithm can choose next by LBFS(many equal labels ⇒ many choices for u ! )

At the point when u is chosen next by the algorithm:

u is preferred over vi ⇒ label(u) > label(vi )

let (n− j) be the largest digit in label(u) that is not in label(vi )

⇒ vj is the leftmost vertex in σi−1 with vju ∈ E and vjvi /∈ E

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 31 / 56

Lexicographic Breadth First search

Theorem (Brandstadt, Dragan, Nicolai, Discrete Math., 1997)

For any graph G = (V , E ), if an ordering σ of V satisfies property (LB)then σ is an LBFS ordering of G.

Proof.

Suppose that σ = (v1, v2, . . . , vn) is satisfies property (LB).

Suppose that (v1, v2, . . . , vi−1) can be obtained by the LBFSalgorithm, but σi−1 = (v1, v2, . . . , vi ) can not (for some i ≤ n)

Let u be a vertex that the algorithm can choose next by LBFS(many equal labels ⇒ many choices for u ! )

At the point when u is chosen next by the algorithm:

u is preferred over vi ⇒ label(u) > label(vi )

let (n− j) be the largest digit in label(u) that is not in label(vi )

⇒ vj is the leftmost vertex in σi−1 with vju ∈ E and vjvi /∈ E

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 31 / 56

Lexicographic Breadth First search

Theorem (Brandstadt, Dragan, Nicolai, Discrete Math., 1997)

For any graph G = (V , E ), if an ordering σ of V satisfies property (LB)then σ is an LBFS ordering of G.

Proof.

σ has property (LB) ⇒ for the triple vj < vi < u in σ there existsa vertex d < vj such that dvi ∈ E and du /∈ E

⇒ the digit (n− σ−1(d)) is in label(vi ) but not in label(u)

d < vj ⇒ σ−1(d) < j ⇒ (n− σ−1(d)) > (n− j)

⇒ label(vi ) > label(u) (by the choice of j), contradiction

Therefore vi can be chosen next by LBFS⇒ (v1, v2, . . . , vi ) can be obtained by the LBFS algorithm for every i⇒ σ = (v1, v2, . . . , vn) is an LBFS ordering

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 31 / 56

Lexicographic Breadth First search

Theorem (Brandstadt, Dragan, Nicolai, Discrete Math., 1997)

For any graph G = (V , E ), if an ordering σ of V satisfies property (LB)then σ is an LBFS ordering of G.

Proof.

σ has property (LB) ⇒ for the triple vj < vi < u in σ there existsa vertex d < vj such that dvi ∈ E and du /∈ E

⇒ the digit (n− σ−1(d)) is in label(vi ) but not in label(u)

d < vj ⇒ σ−1(d) < j ⇒ (n− σ−1(d)) > (n− j)

⇒ label(vi ) > label(u) (by the choice of j), contradiction

Therefore vi can be chosen next by LBFS⇒ (v1, v2, . . . , vi ) can be obtained by the LBFS algorithm for every i⇒ σ = (v1, v2, . . . , vn) is an LBFS ordering

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 31 / 56

Lexicographic Breadth First search

Theorem (Brandstadt, Dragan, Nicolai, Discrete Math., 1997)

For any graph G = (V , E ), if an ordering σ of V satisfies property (LB)then σ is an LBFS ordering of G.

Proof.

σ has property (LB) ⇒ for the triple vj < vi < u in σ there existsa vertex d < vj such that dvi ∈ E and du /∈ E

⇒ the digit (n− σ−1(d)) is in label(vi ) but not in label(u)

d < vj ⇒ σ−1(d) < j ⇒ (n− σ−1(d)) > (n− j)

⇒ label(vi ) > label(u) (by the choice of j), contradiction

Therefore vi can be chosen next by LBFS⇒ (v1, v2, . . . , vi ) can be obtained by the LBFS algorithm for every i⇒ σ = (v1, v2, . . . , vn) is an LBFS ordering

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 31 / 56

Lexicographic Breadth First search

Theorem (Brandstadt, Dragan, Nicolai, Discrete Math., 1997)

For any graph G = (V , E ), if an ordering σ of V satisfies property (LB)then σ is an LBFS ordering of G.

Proof.

σ has property (LB) ⇒ for the triple vj < vi < u in σ there existsa vertex d < vj such that dvi ∈ E and du /∈ E

⇒ the digit (n− σ−1(d)) is in label(vi ) but not in label(u)

d < vj ⇒ σ−1(d) < j ⇒ (n− σ−1(d)) > (n− j)

⇒ label(vi ) > label(u) (by the choice of j), contradiction

Therefore vi can be chosen next by LBFS⇒ (v1, v2, . . . , vi ) can be obtained by the LBFS algorithm for every i⇒ σ = (v1, v2, . . . , vn) is an LBFS ordering

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 31 / 56

Lexicographic Breadth First search

Theorem (Brandstadt, Dragan, Nicolai, Discrete Math., 1997)

For any graph G = (V , E ), if an ordering σ of V satisfies property (LB)then σ is an LBFS ordering of G.

Proof.

σ has property (LB) ⇒ for the triple vj < vi < u in σ there existsa vertex d < vj such that dvi ∈ E and du /∈ E

⇒ the digit (n− σ−1(d)) is in label(vi ) but not in label(u)

d < vj ⇒ σ−1(d) < j ⇒ (n− σ−1(d)) > (n− j)

⇒ label(vi ) > label(u) (by the choice of j), contradiction

Therefore vi can be chosen next by LBFS⇒ (v1, v2, . . . , vi ) can be obtained by the LBFS algorithm for every i

⇒ σ = (v1, v2, . . . , vn) is an LBFS ordering

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 31 / 56

Lexicographic Breadth First search

Theorem (Brandstadt, Dragan, Nicolai, Discrete Math., 1997)

For any graph G = (V , E ), if an ordering σ of V satisfies property (LB)then σ is an LBFS ordering of G.

Proof.

σ has property (LB) ⇒ for the triple vj < vi < u in σ there existsa vertex d < vj such that dvi ∈ E and du /∈ E

⇒ the digit (n− σ−1(d)) is in label(vi ) but not in label(u)

d < vj ⇒ σ−1(d) < j ⇒ (n− σ−1(d)) > (n− j)

⇒ label(vi ) > label(u) (by the choice of j), contradiction

Therefore vi can be chosen next by LBFS⇒ (v1, v2, . . . , vi ) can be obtained by the LBFS algorithm for every i⇒ σ = (v1, v2, . . . , vn) is an LBFS ordering

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 31 / 56

Graph search

Summarizing:

Properties (S, B, LB, D, LD)

If a < b < c in an ordering σ, where ab /∈ E and ac ∈ E ,then σ has the property:

S: if there exists a vertex d < b such that db ∈ E ,

B: if there exists a vertex d < a such that db ∈ E ,

LB: if there exists a vertex d < a such that db ∈ E and dc /∈ E ,

D: if there exists a vertex a < d < b such that db ∈ E ,

LD: if there exists a vertex a < d < b such that db ∈ E and dc /∈ E .

Note that:

every LBFS is a BFS, which is a Generic Search,

every LDFS is a DFS, which is a Generic Search,

only small differences in the property statements→ very different applications

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 32 / 56

Graph search

Summarizing:

Properties (S, B, LB, D, LD)

If a < b < c in an ordering σ, where ab /∈ E and ac ∈ E ,then σ has the property:

S: if there exists a vertex d < b such that db ∈ E ,

B: if there exists a vertex d < a such that db ∈ E ,

LB: if there exists a vertex d < a such that db ∈ E and dc /∈ E ,

D: if there exists a vertex a < d < b such that db ∈ E ,

LD: if there exists a vertex a < d < b such that db ∈ E and dc /∈ E .

Note that:

every LBFS is a BFS, which is a Generic Search,

every LDFS is a DFS, which is a Generic Search,

only small differences in the property statements→ very different applications

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 32 / 56

Graph search

Summarizing:

Properties (S, B, LB, D, LD)

If a < b < c in an ordering σ, where ab /∈ E and ac ∈ E ,then σ has the property:

S: if there exists a vertex d < b such that db ∈ E ,

B: if there exists a vertex d < a such that db ∈ E ,

LB: if there exists a vertex d < a such that db ∈ E and dc /∈ E ,

D: if there exists a vertex a < d < b such that db ∈ E ,

LD: if there exists a vertex a < d < b such that db ∈ E and dc /∈ E .

Note that:

every LBFS is a BFS, which is a Generic Search,

every LDFS is a DFS, which is a Generic Search,

only small differences in the property statements→ very different applications

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 32 / 56

Graph search

Summarizing:

Properties (S, B, LB, D, LD)

If a < b < c in an ordering σ, where ab /∈ E and ac ∈ E ,then σ has the property:

S: if there exists a vertex d < b such that db ∈ E ,

B: if there exists a vertex d < a such that db ∈ E ,

LB: if there exists a vertex d < a such that db ∈ E and dc /∈ E ,

D: if there exists a vertex a < d < b such that db ∈ E ,

LD: if there exists a vertex a < d < b such that db ∈ E and dc /∈ E .

Note that:

every LBFS is a BFS, which is a Generic Search,

every LDFS is a DFS, which is a Generic Search,

only small differences in the property statements→ very different applications

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 32 / 56

Applications of LBFS

What about applications of these graph search algorithms?

Definition

A graph G is chordal if every cycle of length ≥ 4 has a chord,i.e. an edge joining two non-consecutive vertices of the cycle.

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 33 / 56

Applications of LBFS

What about applications of these graph search algorithms?

Definition

A graph G is chordal if every cycle of length ≥ 4 has a chord,i.e. an edge joining two non-consecutive vertices of the cycle.

chordal: non-chordal:

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 33 / 56

Applications of LBFS

What about applications of these graph search algorithms?

Definition

A graph G is chordal if every cycle of length ≥ 4 has a chord,i.e. an edge joining two non-consecutive vertices of the cycle.

chordal: non-chordal:

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 33 / 56

Applications of LBFS

What about applications of these graph search algorithms?

Definition

A graph G is chordal if every cycle of length ≥ 4 has a chord,i.e. an edge joining two non-consecutive vertices of the cycle.

Observation

Every interval graph is a chordal graph.

ab c

de

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 33 / 56

Applications of LBFS

Definition

A vertex v of a graph G is called simplicial if the set N(v) of its neighborsin G induces a complete subgraph of G , i.e. N(v) is a clique.

Theorem (Dirac, 1961)

Let G be a chordal graph. Then G has at least one simplicial vertex.If G is not a clique, it has at least two non-adjacent simplicial vertices.

Chordal graphs are hereditary. Therefore:

Let v1 be a simplicial vertex of a chordal graph G

G − v1 is a chordal graph ⇒ it has a simplicial vertex v2

G − {v1, v2} is a chordal graph ⇒ it has a simplicial vertex v3

. . .

G − {v1, . . . , vn−1} is a (trivial) chordal graph⇒ it has the simplicial vertex vn

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 34 / 56

Applications of LBFS

Definition

A vertex v of a graph G is called simplicial if the set N(v) of its neighborsin G induces a complete subgraph of G , i.e. N(v) is a clique.

Theorem (Dirac, 1961)

Let G be a chordal graph. Then G has at least one simplicial vertex.If G is not a clique, it has at least two non-adjacent simplicial vertices.

Chordal graphs are hereditary. Therefore:

Let v1 be a simplicial vertex of a chordal graph G

G − v1 is a chordal graph ⇒ it has a simplicial vertex v2

G − {v1, v2} is a chordal graph ⇒ it has a simplicial vertex v3

. . .

G − {v1, . . . , vn−1} is a (trivial) chordal graph⇒ it has the simplicial vertex vn

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 34 / 56

Applications of LBFS

Definition

A vertex v of a graph G is called simplicial if the set N(v) of its neighborsin G induces a complete subgraph of G , i.e. N(v) is a clique.

Theorem (Dirac, 1961)

Let G be a chordal graph. Then G has at least one simplicial vertex.If G is not a clique, it has at least two non-adjacent simplicial vertices.

Chordal graphs are hereditary. Therefore:

Let v1 be a simplicial vertex of a chordal graph G

G − v1 is a chordal graph ⇒ it has a simplicial vertex v2

G − {v1, v2} is a chordal graph ⇒ it has a simplicial vertex v3

. . .

G − {v1, . . . , vn−1} is a (trivial) chordal graph⇒ it has the simplicial vertex vn

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 34 / 56

Applications of LBFS

Definition

A vertex v of a graph G is called simplicial if the set N(v) of its neighborsin G induces a complete subgraph of G , i.e. N(v) is a clique.

Theorem (Dirac, 1961)

Let G be a chordal graph. Then G has at least one simplicial vertex.If G is not a clique, it has at least two non-adjacent simplicial vertices.

Chordal graphs are hereditary. Therefore:

Let v1 be a simplicial vertex of a chordal graph G

G − v1 is a chordal graph ⇒ it has a simplicial vertex v2

G − {v1, v2} is a chordal graph ⇒ it has a simplicial vertex v3

. . .

G − {v1, . . . , vn−1} is a (trivial) chordal graph⇒ it has the simplicial vertex vn

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 34 / 56

Applications of LBFS

Definition

A vertex v of a graph G is called simplicial if the set N(v) of its neighborsin G induces a complete subgraph of G , i.e. N(v) is a clique.

Theorem (Dirac, 1961)

Let G be a chordal graph. Then G has at least one simplicial vertex.If G is not a clique, it has at least two non-adjacent simplicial vertices.

Chordal graphs are hereditary. Therefore:

Let v1 be a simplicial vertex of a chordal graph G

G − v1 is a chordal graph ⇒ it has a simplicial vertex v2

G − {v1, v2} is a chordal graph ⇒ it has a simplicial vertex v3

. . .

G − {v1, . . . , vn−1} is a (trivial) chordal graph⇒ it has the simplicial vertex vn

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 34 / 56

Applications of LBFS

Definition

A vertex v of a graph G is called simplicial if the set N(v) of its neighborsin G induces a complete subgraph of G , i.e. N(v) is a clique.

Theorem (Dirac, 1961)

Let G be a chordal graph. Then G has at least one simplicial vertex.If G is not a clique, it has at least two non-adjacent simplicial vertices.

Chordal graphs are hereditary. Therefore:

Let v1 be a simplicial vertex of a chordal graph G

G − v1 is a chordal graph ⇒ it has a simplicial vertex v2

G − {v1, v2} is a chordal graph ⇒ it has a simplicial vertex v3

. . .

G − {v1, . . . , vn−1} is a (trivial) chordal graph⇒ it has the simplicial vertex vn

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 34 / 56

Applications of LBFS

This suggests a recognition algorithm for chordal graphs:[Fulkerson, Gross, Pacific J. Math., 1965]

repeatedly locate a simplicial vertex and eliminate it from the graph:

until no simplicial vertices are left ⇒ the initial graph is not chordal,

or until no vertices remain in the graph ⇒ the initial graph is chordal

This motivates the next definition:

Definition

Let G = (V , E ) be a graph. An ordering σ = (v1, v2, . . . , vn) of V isa perfect elimination ordering if each vi is a simplicial vertex of theinduced subgraph G [vi , vi+1, . . . , vn].

Theorem (Fulkerson, Gross, 1965)

A graph G = (V , E ) is a chordal graph if and only if G has a perfectelimination ordering on V .

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 35 / 56

Applications of LBFS

This suggests a recognition algorithm for chordal graphs:[Fulkerson, Gross, Pacific J. Math., 1965]

repeatedly locate a simplicial vertex and eliminate it from the graph:

until no simplicial vertices are left ⇒ the initial graph is not chordal,or until no vertices remain in the graph ⇒ the initial graph is chordal

This motivates the next definition:

Definition

Let G = (V , E ) be a graph. An ordering σ = (v1, v2, . . . , vn) of V isa perfect elimination ordering if each vi is a simplicial vertex of theinduced subgraph G [vi , vi+1, . . . , vn].

Theorem (Fulkerson, Gross, 1965)

A graph G = (V , E ) is a chordal graph if and only if G has a perfectelimination ordering on V .

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 35 / 56

Applications of LBFS

This suggests a recognition algorithm for chordal graphs:[Fulkerson, Gross, Pacific J. Math., 1965]

repeatedly locate a simplicial vertex and eliminate it from the graph:

until no simplicial vertices are left ⇒ the initial graph is not chordal,or until no vertices remain in the graph ⇒ the initial graph is chordal

This motivates the next definition:

Definition

Let G = (V , E ) be a graph. An ordering σ = (v1, v2, . . . , vn) of V isa perfect elimination ordering if each vi is a simplicial vertex of theinduced subgraph G [vi , vi+1, . . . , vn].

Theorem (Fulkerson, Gross, 1965)

A graph G = (V , E ) is a chordal graph if and only if G has a perfectelimination ordering on V .

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 35 / 56

Applications of LBFS

This suggests a recognition algorithm for chordal graphs:[Fulkerson, Gross, Pacific J. Math., 1965]

repeatedly locate a simplicial vertex and eliminate it from the graph:

until no simplicial vertices are left ⇒ the initial graph is not chordal,or until no vertices remain in the graph ⇒ the initial graph is chordal

This motivates the next definition:

Definition

Let G = (V , E ) be a graph. An ordering σ = (v1, v2, . . . , vn) of V isa perfect elimination ordering if each vi is a simplicial vertex of theinduced subgraph G [vi , vi+1, . . . , vn].

Theorem (Fulkerson, Gross, 1965)

A graph G = (V , E ) is a chordal graph if and only if G has a perfectelimination ordering on V .

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 35 / 56

Applications of LBFS

Example:

1 2 3 4

567

G :

perfect elimination ordering:

(1, 7, 2, 6, 3, 5, 4)σ =

1 2 3 4567

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 36 / 56

Applications of LBFS

Example:

1 2 3 4

567

G :

perfect elimination ordering:

(1, 7, 2, 6, 3, 5, 4)σ =

1 2 3 4567

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 36 / 56

Applications of LBFS

Example:

1 2 3 4

567

G :

perfect elimination ordering:

(1, 7, 2, 6, 3, 5, 4)σ =

1 2 3 4567

5 is simplicial among G[5, 4]

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 36 / 56

Applications of LBFS

Example:

1 2 3 4

567

G :

perfect elimination ordering:

(1, 7, 2, 6, 3, 5, 4)σ =

1 2 3 4567

3 is simplicial among G[3, 5, 4]

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 36 / 56

Applications of LBFS

Example:

1 2 3 4

567

G :

perfect elimination ordering:

(1, 7, 2, 6, 3, 5, 4)σ =

1 2 3 4567

6 is simplicial among G[6, 3, 5, 4]

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 36 / 56

Applications of LBFS

Example:

1 2 3 4

567

G :

perfect elimination ordering:

(1, 7, 2, 6, 3, 5, 4)σ =

1 2 3 4567

2 is simplicial among G[2, 6, 3, 5, 4]

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 36 / 56

Applications of LBFS

Example:

1 2 3 4

567

G :

perfect elimination ordering:

(1, 7, 2, 6, 3, 5, 4)σ =

1 2 3 4567

7 is simplicial among G[7, 2, 6, 3, 5, 4]

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 36 / 56

Applications of LBFS

Example:

1 2 3 4

567

G :

perfect elimination ordering:

(1, 7, 2, 6, 3, 5, 4)σ =

1 2 3 4567

1 is simplicial in G = G[1, 7, 2, 6, 3, 5, 4]

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 36 / 56

Applications of LBFS

Example:

1 2 3 4

567

G :

perfect elimination ordering:

(1, 7, 2, 6, 3, 5, 4)σ =

1 2 3 4567

1 is simplicial in G = G[1, 7, 2, 6, 3, 5, 4]

⇒ G is chordal

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 36 / 56

Applications of LBFS

Another example:

G :

1

2 3 4 5

6

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 36 / 56

Applications of LBFS

Another example:

G :

1

2 3 4 5

61 is not simplicial in G

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 36 / 56

Applications of LBFS

Another example:

G :

1

2 3 4 5

61 is not simplicial in G

2 is not simplicial in G

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 36 / 56

Applications of LBFS

Another example:

G :

1

2 3 4 5

61 is not simplicial in G

2 is not simplicial in G

3 is not simplicial in G

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 36 / 56

Applications of LBFS

Another example:

G :

1

2 3 4 5

61 is not simplicial in G

2 is not simplicial in G

3 is not simplicial in G

. . .

no vertex is simplicial in G

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 36 / 56

Applications of LBFS

Another example:

G :

1

2 3 4 5

61 is not simplicial in G

2 is not simplicial in G

3 is not simplicial in G

. . .

no vertex is simplicial in G

⇒ G is not chordal (e.g. the vertices 1, 2, 3, 6 induce a chordless cycle)

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 36 / 56

Applications of LBFS

How can we use LBFS?

Theorem (Rose, Tarjan, Lueker, SIAM Journal on Computing, 1976)

Let G = (V , E ) be a graph and σ be an LBFS ordering of G . Then:

G is chordal ⇔ the inverse ordering of σ is a perfect elimination ordering.

⇒ chordal graphs can be recognized in linear time

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 36 / 56

Applications of LBFS

The main advantage of LBFS over BFS:

it “breaks ties” in a particular way: lexicographically larger labels first

how to deal with two equal labels? (LBFS chooses arbitrarily)

we need to “break ties” again

One solution: LBFS+(G , π)

together with the graph G , take as input also a vertex ordering π

among equal labels, prefer the vertex that is most to the right in π

otherwise the same as LBFS

Similarly we can “break ties” in LDFS: LDFS+(G , π)

among equal labels, prefer the vertex that is most to the right in π

otherwise the same as LDFS

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 37 / 56

Applications of LBFS

The main advantage of LBFS over BFS:

it “breaks ties” in a particular way: lexicographically larger labels first

how to deal with two equal labels? (LBFS chooses arbitrarily)

we need to “break ties” again

One solution: LBFS+(G , π)

together with the graph G , take as input also a vertex ordering π

among equal labels, prefer the vertex that is most to the right in π

otherwise the same as LBFS

Similarly we can “break ties” in LDFS: LDFS+(G , π)

among equal labels, prefer the vertex that is most to the right in π

otherwise the same as LDFS

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 37 / 56

Applications of LBFS

The main advantage of LBFS over BFS:

it “breaks ties” in a particular way: lexicographically larger labels first

how to deal with two equal labels? (LBFS chooses arbitrarily)

we need to “break ties” again

One solution: LBFS+(G , π)

together with the graph G , take as input also a vertex ordering π

among equal labels, prefer the vertex that is most to the right in π

otherwise the same as LBFS

Similarly we can “break ties” in LDFS: LDFS+(G , π)

among equal labels, prefer the vertex that is most to the right in π

otherwise the same as LDFS

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 37 / 56

Applications of LBFS

The main advantage of LBFS over BFS:

it “breaks ties” in a particular way: lexicographically larger labels first

how to deal with two equal labels? (LBFS chooses arbitrarily)

we need to “break ties” again

One solution: LBFS+(G , π)

together with the graph G , take as input also a vertex ordering π

among equal labels, prefer the vertex that is most to the right in π

otherwise the same as LBFS

Similarly we can “break ties” in LDFS: LDFS+(G , π)

among equal labels, prefer the vertex that is most to the right in π

otherwise the same as LDFS

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 37 / 56

Applications of LBFS

LBFS+(G , π) has been used in many algorithms:

multiple “sweeps” of LBFS+, one after the other

for every “sweep”, the input vertex ordering π specifies:

which is the initial vertex of the output LBFS ordering

how to “break ties”

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 38 / 56

Applications of LBFS

LBFS+(G , π) has been used in many algorithms:

multiple “sweeps” of LBFS+, one after the other

for every “sweep”, the input vertex ordering π specifies:

which is the initial vertex of the output LBFS ordering

how to “break ties”

Many applications of multi-sweep LBFS+, for example:

recognition of unit interval graphs (3 sweeps)[Corneil, Discrete Applied Mathematics, 2004]

recognition of cographs (3 sweeps)[Bretscher, Corneil, Habib, Paul, SIAM J. Discrete Math., 2008]

recognition of interval graphs (5 sweeps)[Corneil, Olariu, Stewart, SIAM J. Discrete Mathematics, 2009]

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 38 / 56

Applications of LBFS

LBFS+(G , π) has been used in many algorithms:

multiple “sweeps” of LBFS+, one after the other

for every “sweep”, the input vertex ordering π specifies:

which is the initial vertex of the output LBFS ordering

how to “break ties”

An example algorithm:

Unit Interval Recognition Algorithm (Corneil, 2004)

1 Compute an arbitrary LBFS ordering σ1

2 LBFS+(G , σ1) yielding ordering σ23 LBFS+(G , σ2) yielding ordering σ34 If σ3 satisfies a “special property” then G is a unit interval graph

5 else G is not a unit interval graph

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 38 / 56

Applications of LBFS

LBFS+(G , π) has been used in many algorithms:

multiple “sweeps” of LBFS+, one after the other

for every “sweep”, the input vertex ordering π specifies:

which is the initial vertex of the output LBFS ordering

how to “break ties”

An example algorithm:

Unit Interval Recognition Algorithm (Corneil, 2004)

1 Compute an arbitrary LBFS ordering σ12 LBFS+(G , σ1) yielding ordering σ2

3 LBFS+(G , σ2) yielding ordering σ34 If σ3 satisfies a “special property” then G is a unit interval graph

5 else G is not a unit interval graph

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 38 / 56

Applications of LBFS

LBFS+(G , π) has been used in many algorithms:

multiple “sweeps” of LBFS+, one after the other

for every “sweep”, the input vertex ordering π specifies:

which is the initial vertex of the output LBFS ordering

how to “break ties”

An example algorithm:

Unit Interval Recognition Algorithm (Corneil, 2004)

1 Compute an arbitrary LBFS ordering σ12 LBFS+(G , σ1) yielding ordering σ23 LBFS+(G , σ2) yielding ordering σ3

4 If σ3 satisfies a “special property” then G is a unit interval graph

5 else G is not a unit interval graph

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 38 / 56

Applications of LBFS

LBFS+(G , π) has been used in many algorithms:

multiple “sweeps” of LBFS+, one after the other

for every “sweep”, the input vertex ordering π specifies:

which is the initial vertex of the output LBFS ordering

how to “break ties”

An example algorithm:

Unit Interval Recognition Algorithm (Corneil, 2004)

1 Compute an arbitrary LBFS ordering σ12 LBFS+(G , σ1) yielding ordering σ23 LBFS+(G , σ2) yielding ordering σ34 If σ3 satisfies a “special property” then G is a unit interval graph

5 else G is not a unit interval graph

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 38 / 56

Applications of LDFS

Recently, after LDFS has been discovered:[Corneil, Krueger, SIAM J. on Discr. Math., 2008]

LDFS+ has also found applications in algorithms

A polynomial algorithm for the longest path problemon cocomparability graphs[Mertzios, Corneil, SIAM J. on Discr. Math., 2012]

A polynomial algorithm for the minimum path cover problemon cocomparability graphs[Corneil, Dalton, Habib, SIAM J. on Computing, 2013]

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 39 / 56

Applications of LDFS

Definition

In a graph G = (V , E ), a simple path (or just: path) is a set of distinctvertices v1, v2, . . . , vk ∈ V such that vivi+1 ∈ E for every 1 ≤ i ≤ k − 1.Notation: P = (v1, v2, . . . , vk).

The length |P | of the path P is the number of its edges.

Definition

In a graph G with n vertices, a path P of G is a Hamiltonian path if|P | = n− 1. A graph G is a Hamiltonian graph if it has such a path P.

The Hamiltonian path problem is:

given a graph G , does G have a Hamiltonian path?

it is an NP-complete problem(i.e. no efficient algorithm is believed to exist ! )

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 39 / 56

Applications of LDFS

Definition

In a graph G = (V , E ), a simple path (or just: path) is a set of distinctvertices v1, v2, . . . , vk ∈ V such that vivi+1 ∈ E for every 1 ≤ i ≤ k − 1.Notation: P = (v1, v2, . . . , vk).

The length |P | of the path P is the number of its edges.

Definition

In a graph G with n vertices, a path P of G is a Hamiltonian path if|P | = n− 1. A graph G is a Hamiltonian graph if it has such a path P.

The Hamiltonian path problem is:

given a graph G , does G have a Hamiltonian path?

it is an NP-complete problem(i.e. no efficient algorithm is believed to exist ! )

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 39 / 56

Applications of LDFS

Definition

In a graph G = (V , E ), a simple path (or just: path) is a set of distinctvertices v1, v2, . . . , vk ∈ V such that vivi+1 ∈ E for every 1 ≤ i ≤ k − 1.Notation: P = (v1, v2, . . . , vk).

The length |P | of the path P is the number of its edges.

Definition

In a graph G with n vertices, a path P of G is a Hamiltonian path if|P | = n− 1. A graph G is a Hamiltonian graph if it has such a path P.

The Hamiltonian path problem is:

given a graph G , does G have a Hamiltonian path?

it is an NP-complete problem(i.e. no efficient algorithm is believed to exist ! )

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 39 / 56

Applications of LDFS

Two natural generalizations of the Hamiltonian path problem:

Longest path problem:Given a graph G , compute the greatest length k among all paths in G .

Minimum path cover problem:Given a graph G , compute the smallest number k of disjoint pathsP1, P2, . . . , Pk that cover all vertices of G .

Observation

A graph G has a Hamiltonian path ⇔ longest path = n− 1⇔ minimum path cover = 1.

Given a cocomparability graph G , we can decide in polynomial timewhether G has a Hamiltonian path[Deogun, Steiner, SIAM J. on Computing, 1994]

What about the other two (harder) optimization problemson cocomparability graphs?

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 40 / 56

Applications of LDFS

Two natural generalizations of the Hamiltonian path problem:

Longest path problem:Given a graph G , compute the greatest length k among all paths in G .

Minimum path cover problem:Given a graph G , compute the smallest number k of disjoint pathsP1, P2, . . . , Pk that cover all vertices of G .

Observation

A graph G has a Hamiltonian path ⇔ longest path = n− 1⇔ minimum path cover = 1.

Given a cocomparability graph G , we can decide in polynomial timewhether G has a Hamiltonian path[Deogun, Steiner, SIAM J. on Computing, 1994]

What about the other two (harder) optimization problemson cocomparability graphs?

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 40 / 56

Applications of LDFS

Two natural generalizations of the Hamiltonian path problem:

Longest path problem:Given a graph G , compute the greatest length k among all paths in G .

Minimum path cover problem:Given a graph G , compute the smallest number k of disjoint pathsP1, P2, . . . , Pk that cover all vertices of G .

Observation

A graph G has a Hamiltonian path ⇔ longest path = n− 1⇔ minimum path cover = 1.

Given a cocomparability graph G , we can decide in polynomial timewhether G has a Hamiltonian path[Deogun, Steiner, SIAM J. on Computing, 1994]

What about the other two (harder) optimization problemson cocomparability graphs?

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 40 / 56

Applications of LDFS

Theorem (Mertzios, Corneil, SIAM J. on Discr. Math., 2012)

Given a cocomparability graph G with n vertices, we can computein O(n4) time a longest path in G.

Previously:

unknown whether the longest path is polynomial or NP-complete

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 41 / 56

Applications of LDFS

Theorem (Mertzios, Corneil, SIAM J. on Discr. Math., 2012)

Given a cocomparability graph G with n vertices, we can computein O(n4) time a longest path in G.

Previously:

unknown whether the longest path is polynomial or NP-complete

Theorem (Corneil, Dalton, Habib, SIAM J. on Computing, 2013)

Given a cocomparability graph G with n vertices and m edges, we cancompute in O(min{n2, n + m log log n}) time a minimum path cover in G .

Previously:

the only known polynomial algorithms for the minimum path coverwere using partial orders (i.e. no graph-theoretic algorithm)

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 41 / 56

Applications of LDFS

These two algorithms use very different techniques, but they both:

start with a “cocomparability vertex ordering” π(such an ordering exists for every cocomparability graph G )

compute the vertex ordering σ =LDFS+(G , π)

follow the basic principles of the corresponding algorithmsfor interval graphs

Therefore these algorithms illustrate for the first time that:

cocomparability graphs present an interval graph structurewhen considered with this LDFS ordering σ

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 41 / 56

Applications of LDFS

The minimum path cover algorithm of [Corneil, Dalton, Habib, 2013]is a certifying algorithm

i.e.: together with a path cover P of size |P| = k, it outputs a certificatethat P is indeed of minimum cardinality

⇒ the optimality of the output can be “verified”

For a connected graph G , the certificate for P is a vertex set S such that:

G − S is disconnected with c(G − S) ≥ 2 connected components

|P| = c(G − S)− |S |

the minimum path cover of G − S is at least c(G − S)

for every vertex of S : we can merge at most two paths into one new

⇒ for the whole set S : we can reduce the total number of pathsby at most |S |

⇒ the minimum path cover of G is at least |P| = c(G − S)− |S |

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 42 / 56

Applications of LDFS

The minimum path cover algorithm of [Corneil, Dalton, Habib, 2013]is a certifying algorithm

i.e.: together with a path cover P of size |P| = k, it outputs a certificatethat P is indeed of minimum cardinality

⇒ the optimality of the output can be “verified”

For a connected graph G , the certificate for P is a vertex set S such that:

G − S is disconnected with c(G − S) ≥ 2 connected components

|P| = c(G − S)− |S |

the minimum path cover of G − S is at least c(G − S)

for every vertex of S : we can merge at most two paths into one new

⇒ for the whole set S : we can reduce the total number of pathsby at most |S |

⇒ the minimum path cover of G is at least |P| = c(G − S)− |S |

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 42 / 56

Applications of LDFS

The minimum path cover algorithm of [Corneil, Dalton, Habib, 2013]is a certifying algorithm

i.e.: together with a path cover P of size |P| = k, it outputs a certificatethat P is indeed of minimum cardinality

⇒ the optimality of the output can be “verified”

For a connected graph G , the certificate for P is a vertex set S such that:

G − S is disconnected with c(G − S) ≥ 2 connected components

|P| = c(G − S)− |S |

the minimum path cover of G − S is at least c(G − S)

for every vertex of S : we can merge at most two paths into one new

⇒ for the whole set S : we can reduce the total number of pathsby at most |S |

⇒ the minimum path cover of G is at least |P| = c(G − S)− |S |

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 42 / 56

Applications of LDFS

The minimum path cover algorithm of [Corneil, Dalton, Habib, 2013]is a certifying algorithm

i.e.: together with a path cover P of size |P| = k, it outputs a certificatethat P is indeed of minimum cardinality

⇒ the optimality of the output can be “verified”

For a connected graph G , the certificate for P is a vertex set S such that:

G − S is disconnected with c(G − S) ≥ 2 connected components

|P| = c(G − S)− |S |

the minimum path cover of G − S is at least c(G − S)

for every vertex of S : we can merge at most two paths into one new

⇒ for the whole set S : we can reduce the total number of pathsby at most |S |

⇒ the minimum path cover of G is at least |P| = c(G − S)− |S |

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 42 / 56

Overview

Graph searching

Tolerance graphs

an intersection model

algorithmic applications

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 43 / 56

Tolerance and bounded tolerance graphs

Definition (Golumbic, Monma, 1982)

A graph G = (V , E ) is called a tolerance graph, if there is a setI = {Iv | v ∈ V } of intervals and a set t = {tv | v ∈ V } of positivenumbers, such that uv ∈ E if and only if |Iu ∩ Iv | ≥ min{tu, tv}.The pair 〈I , t〉 is called a tolerance representation of G .

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 44 / 56

Tolerance and bounded tolerance graphs

Definition (Golumbic, Monma, 1982)

A graph G = (V , E ) is called a tolerance graph, if there is a setI = {Iv | v ∈ V } of intervals and a set t = {tv | v ∈ V } of positivenumbers, such that uv ∈ E if and only if |Iu ∩ Iv | ≥ min{tu, tv}.The pair 〈I , t〉 is called a tolerance representation of G .

0 1 2 3 4 5 6 7 8 9 10

Ia Ic

Ib

Id

ta = tc = 1 tb = 8 td = 7

a

b c

d

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 44 / 56

Tolerance and bounded tolerance graphs

Definition (Golumbic, Monma, 1982)

A graph G = (V , E ) is called a tolerance graph, if there is a setI = {Iv | v ∈ V } of intervals and a set t = {tv | v ∈ V } of positivenumbers, such that uv ∈ E if and only if |Iu ∩ Iv | ≥ min{tu, tv}.The pair 〈I , t〉 is called a tolerance representation of G .

Tolerance graphs find important applications[Golumbic, Trenk, Tolerance graphs, 2004]:

biology and bioinformatics (DNA sequences),

temporal reasoning,

resource allocation,

scheduling ...

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 44 / 56

Tolerance and bounded tolerance graphs

Definition (Golumbic, Monma, 1982)

A vertex v of a tolerance graph G = (V , E ) with a tolerancerepresentation 〈I , t〉 is called a bounded vertex, if tv ≤ |Iv |.Otherwise, if tv > |Iv |, v is called an unbounded vertex.

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 45 / 56

Tolerance and bounded tolerance graphs

Definition (Golumbic, Monma, 1982)

A vertex v of a tolerance graph G = (V , E ) with a tolerancerepresentation 〈I , t〉 is called a bounded vertex, if tv ≤ |Iv |.Otherwise, if tv > |Iv |, v is called an unbounded vertex.

Definition (Golumbic, Monma, 1982)

A tolerance graph G is called a bounded tolerance graph, if there exists atolerance representation 〈I , t〉 of G , such that all vertices of G arebounded.

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 45 / 56

Parallelogram and bounded tolerance graphs

Theorem (Langley, PhD thesis, 1993; Bogart et al., 1995)

Bounded tolerance graphs coincide with parallelogram graphs.

Proof (idea):

L1

L2

tv

cv bvav

dv

P v⇔

av

bv

tv tv

cv dv

tv

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 46 / 56

Parallelogram and bounded tolerance graphs

Theorem (Langley, PhD thesis, 1993; Bogart et al., 1995)

Bounded tolerance graphs coincide with parallelogram graphs.

Proof (idea):

L1

L2

tv

cv bvav

P v⇔

av

bv

tv tv

cv dv

au cu

tu

du

tu

bu

au du

cu

P u

bu

tu

dv

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 46 / 56

Parallelogram and bounded tolerance graphs

Theorem (Langley, PhD thesis, 1993; Bogart et al., 1995)

Bounded tolerance graphs coincide with parallelogram graphs.

Proof (idea):

L1

L2

tv

cv bvav

P v⇔

av

bv

tv tv

cv dv

au cu

tu

du

tu

bu

au du

cu

P u

bu

tu

dv

Clearly:

interval graphs are bounded tolerance graphs (tu = ε, for all u ∈ V ),

permutation graphs are bounded tolerance graphs (lines are trivialparallelograms).

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 46 / 56

Parallelogram and bounded tolerance graphs

Theorem (Langley, PhD thesis, 1993; Bogart et al., 1995)

Bounded tolerance graphs coincide with parallelogram graphs.

Proof (idea):

L1

L2

tv

cv bvav

P v⇔

av

bv

tv tv

cv dv

au cu

tu

du

tu

bu

au du

cu

P u

bu

tu

dv

Question: Does there exist a non-trivial intersection model for the classof tolerance graphs?

Why? This would help us design efficient algorithms.

Main idea: We exploit the third dimension.

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 46 / 56

Parallelogram and bounded tolerance graphs

Theorem (Langley, PhD thesis, 1993; Bogart et al., 1995)

Bounded tolerance graphs coincide with parallelogram graphs.

Proof (idea):

L1

L2

tv

cv bvav

P v⇔

av

bv

tv tv

cv dv

au cu

tu

du

tu

bu

au du

cu

P u

bu

tu

dv

Question: Does there exist a non-trivial intersection model for the classof tolerance graphs?

Why? This would help us design efficient algorithms.

Main idea: We exploit the third dimension.

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 46 / 56

The slopes of the parallelograms

We extend the construction of the parallelograms Pv to the case ofunbounded vertices v .

We define the slope φv of the parallelogram Pv as:

φv = arctan ( 1tv), if v is bounded,

φv = arctan ( 1|Iv | ), if v is unbounded.

The slopes φv capture essential information about the structure.

L1

L2

1

tu tu

bu

duau |Iu|

PuP v Pw

av = dv

cv = bv

tv

|Iv| |Iw|

tw =∞

aw = dw

cw = bwcu

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 47 / 56

The slopes of the parallelograms

We extend the construction of the parallelograms Pv to the case ofunbounded vertices v .

We define the slope φv of the parallelogram Pv as:

φv = arctan ( 1tv), if v is bounded,

φv = arctan ( 1|Iv | ), if v is unbounded.

The slopes φv capture essential information about the structure.

L1

L2

1

tu tu

bu

duau |Iu|

PuP v Pw

av = dv

cv = bv

tv

|Iv| |Iw|

tw =∞

aw = dw

cw = bwcu

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 47 / 56

The slopes of the parallelograms

We extend the construction of the parallelograms Pv to the case ofunbounded vertices v .

We define the slope φv of the parallelogram Pv as:

φv = arctan ( 1tv), if v is bounded,

φv = arctan ( 1|Iv | ), if v is unbounded.

The slopes φv capture essential information about the structure.

L1

L2

tu

bu

duau |Iu|

PuP v Pw

av = dv

cv = bv

|Iv| |Iw|

tw =∞

aw = dw

cw = bwcu

bounded

tu

φu

tv

φv

1

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 47 / 56

The slopes of the parallelograms

We extend the construction of the parallelograms Pv to the case ofunbounded vertices v .

We define the slope φv of the parallelogram Pv as:

φv = arctan ( 1tv), if v is bounded,

φv = arctan ( 1|Iv | ), if v is unbounded.

The slopes φv capture essential information about the structure.

L1

L2

tu tu

cu bu

duau |Iu|φu

PuP v Pw

av = dv

cv = bv

tv

|Iv|φv

tw =∞

aw = dw

cw = bw

bounded unbounded

1

φw

|Iw|

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 47 / 56

The slopes of the parallelograms

We extend the construction of the parallelograms Pv to the case ofunbounded vertices v .

We define the slope φv of the parallelogram Pv as:

φv = arctan ( 1tv), if v is bounded,

φv = arctan ( 1|Iv | ), if v is unbounded.

The slopes φv capture essential information about the structure.

L1

L2

tu tu

cu bu

duau |Iu|φu

PuP v Pw

av = dv

cv = bv

tv

|Iv|φv

tw =∞

aw = dw

cw = bw

bounded

φw

|Iw|

unbounded

1

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 47 / 56

The slopes of the parallelograms

The parallelogram representation does not suffice for general tolerancegraphs:

0 1 2 3 4 5 6 7 8 9 10⇔

11 12 13 14

Iu

tv = 2 < |Iv| = 4

tw = 100 > |Iw| = 8Iv

Iw

(bounded)

(bounded)

(unbounded)15

tu = 13 < |Iu| = 15u

v

w

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 48 / 56

The slopes of the parallelograms

The parallelogram representation does not suffice for general tolerancegraphs:

0 1 2 3 4 5 6 7 8 9 10⇔

11 12 13 14

Iu

tv = 2 < |Iv| = 4

tw = 100 > |Iw| = 8Iv

Iw

(bounded)

(bounded)

(unbounded)

L1

L2

P v

P u

15

Pw

φwφu φv

tu = 13 < |Iu| = 15u

v

w

tvtu

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 48 / 56

The slopes of the parallelograms

The parallelogram representation does not suffice for general tolerancegraphs:

0 1 2 3 4 5 6 7 8 9 10⇔

11 12 13 14

Iu

tv = 2 < |Iv| = 4

tw = 100 > |Iw| = 8Iv

Iw

(bounded)

(bounded)

(unbounded)

L1

L2

P v

P u

15

Pw

φwφu φv

tu = 13 < |Iu| = 15u

v

w

tvtu

Pw intersects both Pv and Pu

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 48 / 56

The slopes of the parallelograms

The parallelogram representation does not suffice for general tolerancegraphs:

0 1 2 3 4 5 6 7 8 9 10⇔

11 12 13 14

Iu

tv = 2 < |Iv| = 4

tw = 100 > |Iw| = 8Iv

Iw

(bounded)

(bounded)

(unbounded)

L1

L2

P v

P u

15

Pw

φwφu φv

tu = 13 < |Iu| = 15u

v

w

tvtu

Pw intersects both Pv and Pu

However, wv ∈ E , but wu /∈ E .

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 48 / 56

The slopes of the parallelograms

The parallelogram representation does not suffice for general tolerancegraphs:

0 1 2 3 4 5 6 7 8 9 10⇔

11 12 13 14

Iu

tv = 2 < |Iv| = 4

tw = 100 > |Iw| = 8Iv

Iw

(bounded)

(bounded)

(unbounded)

L1

L2

P v

P u

15

Pw

φwφu φv

tu = 13 < |Iu| = 15u

v

w

tvtu

|Iw | > |Iw ∩ Iv | = |Iv | > tv

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 48 / 56

The slopes of the parallelograms

The parallelogram representation does not suffice for general tolerancegraphs:

0 1 2 3 4 5 6 7 8 9 10⇔

11 12 13 14

Iu

tv = 2 < |Iv| = 4

tw = 100 > |Iw| = 8Iv

Iw

(bounded)

(bounded)

(unbounded)

L1

L2

P v

P u

15

Pw

φwφu φv

tu = 13 < |Iu| = 15u

v

w

tvtu

|Iw | > |Iw ∩ Iv | = |Iv | > tv ⇒ wv ∈ E ,

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 48 / 56

The slopes of the parallelograms

The parallelogram representation does not suffice for general tolerancegraphs:

0 1 2 3 4 5 6 7 8 9 10⇔

11 12 13 14

Iu

tv = 2 < |Iv| = 4

tw = 100 > |Iw| = 8Iv

Iw

(bounded)

(bounded)

(unbounded)

L1

L2

P v

P u

15

Pw

φwφu φv

tu = 13 < |Iu| = 15u

v

w

tvtu

|Iw | > |Iw ∩ Iv | = |Iv | > tv ⇒ wv ∈ E , tan(φw ) < tan(φv ), φw < φv

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 48 / 56

The slopes of the parallelograms

The parallelogram representation does not suffice for general tolerancegraphs:

0 1 2 3 4 5 6 7 8 9 10⇔

11 12 13 14

Iu

tv = 2 < |Iv| = 4

tw = 100 > |Iw| = 8Iv

Iw

(bounded)

(bounded)

(unbounded)

L1

L2

P v

P u

15

Pw

φwφu φv

tu = 13 < |Iu| = 15u

v

w

tvtu

|Iw | > |Iw ∩ Iv | = |Iv | > tv ⇒ wv ∈ E , tan(φw ) < tan(φv ), φw < φv

|Iw ∩ Iu | = |Iw | < tu

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 48 / 56

The slopes of the parallelograms

The parallelogram representation does not suffice for general tolerancegraphs:

0 1 2 3 4 5 6 7 8 9 10⇔

11 12 13 14

Iu

tv = 2 < |Iv| = 4

tw = 100 > |Iw| = 8Iv

Iw

(bounded)

(bounded)

(unbounded)

L1

L2

P v

P u

15

Pw

φwφu φv

tu = 13 < |Iu| = 15u

v

w

tvtu

|Iw | > |Iw ∩ Iv | = |Iv | > tv ⇒ wv ∈ E , tan(φw ) < tan(φv ), φw < φv

|Iw ∩ Iu | = |Iw | < tu ⇒ wu /∈ E ,

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 48 / 56

The slopes of the parallelograms

The parallelogram representation does not suffice for general tolerancegraphs:

0 1 2 3 4 5 6 7 8 9 10⇔

11 12 13 14

Iu

tv = 2 < |Iv| = 4

tw = 100 > |Iw| = 8Iv

Iw

(bounded)

(bounded)

(unbounded)

L1

L2

P v

P u

15

Pw

φwφu φv

tu = 13 < |Iu| = 15u

v

w

tvtu

|Iw | > |Iw ∩ Iv | = |Iv | > tv ⇒ wv ∈ E , tan(φw ) < tan(φv ), φw < φv

|Iw ∩ Iu | = |Iw | < tu ⇒ wu /∈ E , tan(φw ) > tan(φu), φw > φu

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 48 / 56

Intersection of 3D-parallelepipeds

We define the parallelepipeds Pv as follows:

If v is bounded, thenPv = {(x , y , z) ∈ R3 | (x , y) ∈ Pv , 0 ≤ z ≤ φv}.

If v is unbounded, thenPv = {(x , y , z) ∈ R3 | (x , y) ∈ Pv , z = φv}.

[Mertzios, Sau , Zaks, SIAM J. on Discrete Mathematics, 2009]

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 49 / 56

Intersection of 3D-parallelepipeds

The parallelepiped representation: (for general tolerance graphs)[Mertzios, Sau , Zaks, SIAM J. on Discrete Mathematics, 2009]

L1

L2

P v

P u

Pw

φwφu φv

u

v

w

tvtu

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 49 / 56

Intersection of 3D-parallelepipeds

The parallelepiped representation: (for general tolerance graphs)[Mertzios, Sau , Zaks, SIAM J. on Discrete Mathematics, 2009]

L1

L2

P v

P u

Pw

φwφu φv

u

v

w

tvtu

x

yz

L1

L2

Puφu

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 49 / 56

Intersection of 3D-parallelepipeds

The parallelepiped representation: (for general tolerance graphs)[Mertzios, Sau , Zaks, SIAM J. on Discrete Mathematics, 2009]

L1

L2

L1

L2

P v

P u

Pw

φwφu φv

u

v

w

tvtu

x

yz

φv

Pu

Pv

φu

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 49 / 56

Intersection of 3D-parallelepipeds

The parallelepiped representation: (for general tolerance graphs)[Mertzios, Sau , Zaks, SIAM J. on Discrete Mathematics, 2009]

L1

L2

L1

L2

P v

P u

Pw

φwφu φv

u

v

w

tvtu

x

yz

φv

φw

Pu

Pv Pw

φu

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 49 / 56

Intersection of 3D-parallelepipeds

The parallelepiped representation: (for general tolerance graphs)[Mertzios, Sau , Zaks, SIAM J. on Discrete Mathematics, 2009]

L1

L2

φv

φw

L1

L2

P v

P u

Pw

φwφu φv

u

v

w

tvtu

x

yz

u

v

w

Pu

Pv Pw

φu

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 49 / 56

The parallelepiped representation

Definition (Mertzios, Sau , Zaks, SIAM J. on Discr. Math., 2009)

An unbounded vertex v of a tolerance graph G (in a certain parallelepipedrepresentation) is called inevitable, if replacing Pi with{(x , y , z) | (x , y) ∈ Pv , 0 ≤ z ≤ φv} creates a new edge in G .

Otherwise, v is called evitable.

φ

P

1 6 12 17 21 27 32 37 41 43 4947 52 54 61 66 684

P

PP

P

P

P

P1

1

2

2

33

4

4

5

6

5

8

77

6

8

1

L1

L2 x

yz

φ

φ

φ

φ

φ

φ

φ

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 50 / 56

The parallelepiped representation

Definition (Mertzios, Sau , Zaks, SIAM J. on Discr. Math., 2009)

An unbounded vertex v of a tolerance graph G (in a certain parallelepipedrepresentation) is called inevitable, if replacing Pi with{(x , y , z) | (x , y) ∈ Pv , 0 ≤ z ≤ φv} creates a new edge in G .Otherwise, v is called evitable.

φ

P

1 6 12 17 21 27 32 37 41 43 4947 52 54 61 66 684

P

PP

P

P

P

P1

1

2

2

33

4

4

5

6

5

8

77

6

8

1

L1

L2 x

yz

φ

φ

φ

φ

φ

φ

φ

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 50 / 56

The parallelepiped representation

Definition (Mertzios, Sau , Zaks, SIAM J. on Discr. Math., 2009)

Let v be an inevitable unbounded vertex of a tolerance graph G (in acertain parallelepiped representation). A vertex u is called a hoveringvertex of u if φu < φv , au < av , and bu > bv .

φ

P

1 6 12 17 21 27 32 37 41 43 4947 52 54 61 66 684

P

PP

P

P

P

P1

1

2

2

33

4

4

5

6

5

8

77

6

8

1

L1

L2 x

yz

φ

φ

φ

φ

φ

φ

φ

b3a3

a4 b4 a8 b8

a6 b6

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 51 / 56

The parallelepiped representation

Definition (Mertzios, Sau , Zaks, SIAM J. on Discr. Math., 2009)

A parallelepiped representation of a tolerance graph G is called canonical ifevery unbounded vertex is inevitable.

An example of a non-canonical representation:

φ

P

1 6 12 17 21 27 32 37 41 43 4947 52 54 61 66 684

P

PP

P

P

P

P1

1

2

2

33

4

4

5

6

5

8

77

6

8

1

L1

L2 x

yz

φ

φ

φ

φ

φ

φ

φ

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 52 / 56

The parallelepiped representation

Definition (Mertzios, Sau , Zaks, SIAM J. on Discr. Math., 2009)

A parallelepiped representation of a tolerance graph G is called canonical ifevery unbounded vertex is inevitable.

Similar “canonical representations” for tolerance graphs were defined in:

[Golumbic, Siani, AISC, 2002]“canonical tolerance representation”, computation in O(n2) time

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 52 / 56

The parallelepiped representation

Definition (Mertzios, Sau , Zaks, SIAM J. on Discr. Math., 2009)

A parallelepiped representation of a tolerance graph G is called canonical ifevery unbounded vertex is inevitable.

Theorem (Mertzios, Sau , Zaks, SIAM J. on Discr. Math., 2009)

Given a parallelepiped representation of a tolerance graph G ,a canonical representation of G can be computed in O(n log n) time.

Idea:

Exploit the endpoints and slopes of the parallelograms(resp. heights of parallelepipeds)

Map: each vertex v of G to a point on the plane

Solve a problem of computational geometry(using binary search)

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 52 / 56

Canonical parallelepiped representations

Algorithmic applications:[Mertzios, Sau , Zaks, SIAM J. on Discr. Math., 2009]

Minimum coloring:

Construct in O(n log n) a canonical representation of G

Color in O(n log n) the induced subgraph on the bounded verticesby [Felsner et al., Discr. Appl. Math., 1997]

For every unbounded vertex v :

Assign to v the color of a hovering vertex u of it (since N(v) ⊆ N(u))

Total complexity: O(n log n) (optimal).

Maximum clique: in the same time (O(n log n)) time (optimal),since χ(G ) = ω(G ) (perfect graphs).

Previously known results: O(n2) [Golumbic, Siani, AISC, 2002]

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 53 / 56

Canonical parallelepiped representations

Algorithmic applications:[Mertzios, Sau , Zaks, SIAM J. on Discr. Math., 2009]

Minimum coloring:

Construct in O(n log n) a canonical representation of G

Color in O(n log n) the induced subgraph on the bounded verticesby [Felsner et al., Discr. Appl. Math., 1997]

For every unbounded vertex v :

Assign to v the color of a hovering vertex u of it (since N(v) ⊆ N(u))

Total complexity: O(n log n) (optimal).

Maximum clique: in the same time (O(n log n)) time (optimal),since χ(G ) = ω(G ) (perfect graphs).

Previously known results: O(n2) [Golumbic, Siani, AISC, 2002]

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 53 / 56

Canonical parallelepiped representations

Algorithmic applications:[Mertzios, Sau , Zaks, SIAM J. on Discr. Math., 2009]

Minimum coloring:

Construct in O(n log n) a canonical representation of G

Color in O(n log n) the induced subgraph on the bounded verticesby [Felsner et al., Discr. Appl. Math., 1997]

For every unbounded vertex v :

Assign to v the color of a hovering vertex u of it (since N(v) ⊆ N(u))

Total complexity: O(n log n) (optimal).

Maximum clique: in the same time (O(n log n)) time (optimal),since χ(G ) = ω(G ) (perfect graphs).

Previously known results: O(n2) [Golumbic, Siani, AISC, 2002]

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 53 / 56

Canonical parallelepiped representations

Algorithmic applications:[Mertzios, Sau , Zaks, SIAM J. on Discr. Math., 2009]

Weighted independent set:Input: a graph G and a positive weight wv for every vertex v of G .Output: an independent set in G with the greatest sum of weights.

Use of the parallelepiped representation ⇒ O(n2).

Exploit the endpoints and slopes of the parallelepipeds

Sweep line algorithm from right to left

Previously known results: O(n3)[Golumbic, Trenk, Tolerance Graphs, 2004]

Subsequently improved (optimal) running time: O(n log n)[Mertzios, SODA, 2011]

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 54 / 56

Canonical parallelepiped representations

Algorithmic applications:[Mertzios, Sau , Zaks, SIAM J. on Discr. Math., 2009]

Weighted independent set:Input: a graph G and a positive weight wv for every vertex v of G .Output: an independent set in G with the greatest sum of weights.

Use of the parallelepiped representation ⇒ O(n2).

Exploit the endpoints and slopes of the parallelepipeds

Sweep line algorithm from right to left

Previously known results: O(n3)[Golumbic, Trenk, Tolerance Graphs, 2004]

Subsequently improved (optimal) running time: O(n log n)[Mertzios, SODA, 2011]

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 54 / 56

Canonical parallelepiped representations

Algorithmic applications:[Mertzios, Sau , Zaks, SIAM J. on Discr. Math., 2009]

Weighted independent set:Input: a graph G and a positive weight wv for every vertex v of G .Output: an independent set in G with the greatest sum of weights.

Use of the parallelepiped representation ⇒ O(n2).

Exploit the endpoints and slopes of the parallelepipeds

Sweep line algorithm from right to left

Previously known results: O(n3)[Golumbic, Trenk, Tolerance Graphs, 2004]

Subsequently improved (optimal) running time: O(n log n)[Mertzios, SODA, 2011]

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 54 / 56

Canonical parallelepiped representations

Summarizing:

Given the tolerance representation (or the parallelepipedrepresentation) of a tolerance graph G :

many generally “hard” problems we can be solved efficiently:minimum coloringmaximum cliquemaximum weight independent set

However computing a representation (if one exists ! ) is hard:

Theorem (Mertzios, Sau, Zaks, SIAM Journal on Computing, 2011)

Given a graph G , it is NP-complete to decide whether G is a tolerancegraph (or even a bounded tolerance graph).

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 55 / 56

Canonical parallelepiped representations

Summarizing:

Given the tolerance representation (or the parallelepipedrepresentation) of a tolerance graph G :

many generally “hard” problems we can be solved efficiently:minimum coloringmaximum cliquemaximum weight independent set

However computing a representation (if one exists ! ) is hard:

Theorem (Mertzios, Sau, Zaks, SIAM Journal on Computing, 2011)

Given a graph G , it is NP-complete to decide whether G is a tolerancegraph (or even a bounded tolerance graph).

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 55 / 56

Thank you for your attention!

George Mertzios (Durham) Advances in algorithmic graph theory EULER, July 2013 56 / 56

Recommended