Distributed Computing, COMP 4001 1
Universal Traversals
Evangelos Kranakis, Carleton University, SCS (October 31, 2020)
Distributed Computing, COMP 4001 2 Labeling Schemes
• How can we use port labeling schemes to improve
communication? Given different n a m e s to the nodes
• What role do port labeling schemes play in distributed computing?
• The execution of a distributed algorithm at a node depends on the sequence of port labels that must be followed by the distributed algorithm at that node.
• Can we solve a problem in a way that all nodes follow identical sequences at each node?
Evangelos Kranakis, Carleton University, SCS (October 31, 2020)
At
each node follow the
labels 1-2=2412.10
sequence of
Each
me
such execution
an
sequencegives
Distributed Computing, COMP 4001 3
• Probabilistic Method • Universal traversals
Outline
Must defined labels that w ill be
of universal !
sequence
port
If youthink ofthe
labels as a
of
sequence program
Evangelos Kranakis, Carleton University, SCS (October 31, 2020)
Distributed Computing, COMP 4001 4
P0robabilistic Method
• Using probability to prove the existence of a mathematical
object is called the Probabilistic Method.
• It has many applications, especially in graph theory.
• It uses the following principle:
If, in a given set of objects, the probability that a randomly chosen object does not have a certain property
is less than 1 then then there must exist an object with this property. E) Eff
If Prf <1 then ME
set
of
Pr CE )
=
objects
so Ef
Diff .
Way
:
then
Evangelos Kranakis, Carleton University, SCS (October 31, 2020)
then Pr (01--0
If E=§
Pr
1. e .
implies that a n object in E must exist ,
I
⇒ Prfi I-
fit) showing that Pr
⇒
- -
I field
Distributed Computing, COMP 4001 5
#
Union Form of the Probabilistic Method
• Consider n events A1, A2, . . . , An (not necessarily independent).
from:
re EKA Xn
• The union (or Boole) Inequality states that "[n # Xn
Pr Ai Pr[Ai] i=1 i=1
I
• Therefore if we want to prove that
\n
(¬A)i 6= ;
i=1 it is enough to show that
Pr[Ai] < 1. i=1
0]=
k>0
Therefore
k>0 = E[X]
Pr[X > 0] E[X]
(1)
Evangelos Kranakis, Carleton University, SCS (October 31, 2020)
Distributed Computing, COMP 4001 7
Expectation Form of the Probabilistic Method
• Equation (1) is a special cas of Markov’s inequality wchich I
states that
Pr[X > kE[X]] 1 k
• Therefore using Equation (1) if we want to prove that
Pr[X =0]>0 it is enough to prove that
E[X] < 1.
Exercise
Evangelos Kranakis, Carleton University, SCS (October 31, 2020)
Distributed Computing, COMP 4001 8
Traversals
Evangelos Kranakis, Carleton University, SCS (October 31, 2020)
Distributed Computing, COMP 4001 9 Explorations
• Graph traversal (also known as graph search) refers to the process of visiting (checking and/or updating) each vertex in a
graph. E.g., – BFS
– DFS
993
than as
– typically a sequence of port labels that it must follow from node to node) which is used to traverse the graph.
• However, the program used may depend on the starting node. Evangelos Kranakis, Carleton University, SCS (October 31, 2020)
Breadth first Death n
search uIt
.
• Used in Search and Exploration.
• Each starting node is equipped with a program
Distributed Computing, COMP 4001 10
ofloibeds
Universal Traversals
• A sequence is universal for graphs with n vertices if for every graph and every start vertex, the walk defined by the (same) sequence will visit every vertex in the graph.
• Can you produce a universal traversal program that will work for every graph and every starting node of the graph?
• To produce a walk defined by a sequence, we need some notion of graph labeling.
– For each vertex u, label the edges adjacent to u (ports) from 1 to deg(u) (in fact any numbering will do).
– This is what we defined as port labelings!
• Then a sequence is a string of edge labels which determines some walk through the graph.
Evangelos Kranakis, Carleton University, SCS (October 31, 2020)
Distributed Computing, COMP 4001 11
Universal Traversals on Labyrinths
• A robot is placed in a labyrinth in a n ⇥ n square grid. • It runs a program: a sequence of commands of the form
N(orth), S(outh), E(ast), W(est), go
⇒
' •
labels -4¥
Port
• As an example consider the program NESWEW which is
given to every node.
• A robot has the sequence “NESWEW” and starting at a node makes movements following the sequence of labels.
-
Evangelos Kranakis, Carleton University, SCS (October 31, 2020)
fixed W EHswμr
Follow a trajectory determined
by t h e sequence of labels given to m e .
.
Distributed Computing, COMP 4001 12
Universal Traversals
• In addition to external walls on the whole perimeter, walls are also placed between cells.
• Executing each command, the robot moves in the prescribed direction if possible (and does nothing when there is a wall in this direction).
E.g., NESWEEEW
Evangelos Kranakis, Carleton University, SCS (October 31, 2020)
Distributed Computing, COMP 4001 13
• We can show that
Universal Traversals
not
{Theorem 1 (Universal Traversals) For any n, there exists a program that works correctly for all labyrinths of size at most n ⇥ n (independently of the positions of walls inside the square and the robot’s initial position).
• “Works correctly” means that the robot visits all reachable cells.
• To solve the traversal problem,
we prove that a su ciently long random program will
work with positive probability.
• We will do this using the union bound.
-
Evangelos Kranakis, Carleton University, SCS (October 31, 2020)
Distributed Computing, COMP 4001 14
Preorder Traversals (1/2)
• For each n ⇥ n labyrinth, there is a program of size 4n4 that works for it, as each cell is reachable in at most 4n2 steps (round-trip) and there are at most n2 admissible cells.
• To prove this note that for each starting cell there is a
spanning tree reaching all the n2 cells of a given labyrinth,
think of it as a distributed network.
too
I
• Assign ports to each vertex (edge labels associated to the edges connected)
H
D
BC EFG
A
J
Evangelos Kranakis, Carleton University, SCS (October 31, 2020)
Distributed Computing, COMP 4001 15
Preorder Traversals (2/2)
• Using a pre-order traversal of this spanning tree (which has length at most 4n2) every cell will be visited in at most 4n2 v
steps (round trip).
For every vertex
me how a traversal
41 labels
of
n 2×4 '
n
• Therefore, a random~program of size N = 4n4 will work with probability at least ✏ = (1/4)4n4 and fail with probability at most 1 ✏.
Evangelos Kranakis, Carleton University, SCS (October 31, 2020)
Distributed Computing, COMP 4001 16
Universal Traversals
• Select among such programs of size N = 4n2 independently and uniformly at random.
times
– By independence, a random program of size 2N will fail with probability at most (1 ✏)2
– More generally, a random parogram of size kN will fail with probability at most (1 ✏)k.
• Now for each k concatenate k such programs:
~- P1P2 ···Pk
f
they
• This probability is computed for a fixed labyrinth L.
• Let FL be the event that a program of size kN fails for the
labyrinth L.
• It follows from the above that Pr[FL] (1 ✏)k.
Evangelos Kranakis, Carleton University, SCS (October 31, 2020)
Distributed Computing, COMP 4001 17 Universal Traversals
• Now take the union SL FL, where L runs over all labyrinths. As a consequence,
Pr"[FL# XPr[FL] LL