26
TRAVERSAL ALGORITHMS ABIOLA FAMUREWA & SAMUEL IDOWU D7022E - Formal methods in telecommunications engineering [email protected]

Traversal Algorithm

Embed Size (px)

DESCRIPTION

Distributed Algorithms & Formal Methods in Telecommunication Engineering

Citation preview

Page 1: Traversal Algorithm

TRAVERSAL ALGORITHMS

ABIOLA FAMUREWA & SAMUEL IDOWU

D7022E - Formal methods in telecommunications engineering 

[email protected]

Page 2: Traversal Algorithm

TABLE OF CONTENT

Traversal algorithms Traversing cliques Traversing tori Traversing hypercubes Traversing connected networks

▪ Tarry’s algorithm Time complexity: depth-first search

Classical depth-first search Awerbuch’s solution Cidon’s solution Depth-first search with neighbor knowledge

Page 3: Traversal Algorithm

TRAVERSAL ALGORITHMSTraversal algorithm is a wave algorithm with the following properties:

Each computation contains one initiator which starts computation by sending one message

when a process receives a message it either sends out one message or decides

The algorithm terminates in the initiator and when this happens, each process has sent a message at least once.

Page 4: Traversal Algorithm

F-TRAVERSAL ALGORITHM

Definition: An algorithm is an f-traversal algorithm (for a class of networks) if ;

It is a traversal algorithm

In each computation at least min (N, x + 1) processes have been visited after f (x) token passes.

Page 5: Traversal Algorithm

IMPLEMENTATIONS OF TRAVERSAL ALGORITHMS

The implementations of Traversal algorithm will be studied using the followings;

Sequential polling (Traversing cliques)

Traversing Toris

Traversing Hypercubes

Tarry’s algorithm

Page 6: Traversal Algorithm

SEQUENTIAL POLLING ALGORITHM

A clique is traversed by sequential polling but only one neighbor of the initiator is polled at a time. i.e. only

when a reply of one neighbor has been received is the next neighbor polled

*polling process is similar to polling algorithm.

Theorem: The sequential polling algorithm is a 2x –traversal algorithm for cliques.

Topology cliqueIt is centralizedMessage complexity 2N - 2Time complexity 2N – 2

TRAVERSING CLIQUES

Page 7: Traversal Algorithm

TRAVERSING TORI

The n × n torus graph is the graph G =(V, E ), where

V = Zn ×Zn ={(i, j) : 0 < i, j < n} &

E = {(i, j) (i', j’) : (i = i’∧ j’ = j’ ± 1) ∨ ( i= i’ ± 1∧j= j)}

The torus is an halmitonian graphIt has sense of directionThe coordinate pair (i, j) are used in defining

topology and its sense f of directionMessage complexity NTime complexity N

Theorem: The torus algorithm is an x -traversal algorithm for the torus.

Page 8: Traversal Algorithm

TRAVERSING TORI

Scenario: token moves from process p to process q by making UP-moves and RIGHT-moves.

Algorithm details: The initiator initiates the process by sending

token<num, 1> to UP Each process receives the token <num, k> If k = n2 then the process decides, else If n/k (i.e. a multiple of k) then send <num, k+1>

to UP Else send <num, k+1> to RIGHT

Decision Is taken after n2 times

Page 9: Traversal Algorithm

TRAVERSING HYPERCUBES The n –dimensional hypercube is a graph G = (V ,E ) Hypercube has sense of direction The topological knowledge is restricted to the channel

labels, and not known to the processes

Theorem: The hypercube algorithm is an x-traversal algorithm for the hypercube.

Message Complexity N Time complexity N Topology Hypercube

Page 10: Traversal Algorithm

TRAVERSING HYPERCUBESAlgorithm details

The initiator send <num, 1> token through channel n-1For each process, upon receipt of the token <num, k>Check if k=2n then decideIf k ≠ 2n let l be the largest number : 2l / kSend (num, k+1) through channel l

Page 11: Traversal Algorithm

TRAVERSING CONNECTED NETWORKS(TARRY’S ALGORITHM)

Tarry’s algorithm is an important algorithms for traversing connected networks.

Works for arbitrary networks. Initiator forwards token to one of neighbors, each

neighbor forwards token to all other nodes and when done returns the token.

A node is free to chose any node to forward token to. The time complexity 2|E| message complexity 2|E| Topology Arbitrary

Page 12: Traversal Algorithm

TARRY’S TRAVERSAL ALGORITHM

The algorithm is formulated in the following two rules:

R1. A node never forwards the token through the same channel twice.

R2. A node only forwards the token to its father when there is no other option.

Page 13: Traversal Algorithm

TARRY’S ALGORITHM

Tarry’s algorithm is a traversal algorithm and it terminates which can be proved with the following steps.

The channels incident to an initiator are used once in each direction

For each visited process (p), all channels incident to (p) have been used once in each direction.

All processes have been visited and each channel has been used once in both directions.

Page 14: Traversal Algorithm

DEPTH-FIRST SEARCHALGORITHMS

Classical Depth First SearchAwerbuch’s SolutionCidon’s Solution Depth First Search with neighbor

Knowledge

Page 15: Traversal Algorithm

DEPTH-FIRST SEARCH

A minor modification of Tarry’s algorithm i.e. restriction of the freedom of choice of the process enables the algorithm to compute DFS.

DFS algorithms are those that compute spanning trees with additional property:

Each frond edge connects two node, one of which is an ancestor of the other.

Frond Edge: An edge that does not belong to the spanning tree.

Given a rooted spanning tree T of G, for each process P, ∃ T[p] denotes the set of processes in the sub-tree of P, and

∃ A[p] denotes the ancestors of p

q ∈ T[p] ⇔ p ∈ A[q]

Page 16: Traversal Algorithm

DEPTH-FIRST SEARCH

A spanning tree T of G is a DFS tree if, for each frond edge pq, q ∈ T[p] v q ∈ A[p]

Uses: used in many graph algorithms. E.g. graphs for testing planarity, bi-connectivity and for the construction of interval labeling schemes.

The resulting algorithm after the tweak on Tarry’s algorithm Classical Depth-first Search algorithm

Topology of DFS is Arbitrary

DSF algorithms are centralized since ∃ only one initiator at each computation

Page 17: Traversal Algorithm

Classical Depth-first Search

Time complexity of distributed algorithms:The maximum time taken by a computation of an algorithm

Assumption: (correctness of algorithm doesn’t depend on assumptions) T1: A process can execute any finite number of

events in Zero time. T2: The time between sending and receipt of a

message is at most one time unit. Message complexity 2|E| Time complexity 2 |E|

NOTE: for traversal algorithm, the time complexity equals the message complexity since messages are exchanged serially, and each may take one time unit.

Page 18: Traversal Algorithm

Distributed Depth-first Search

Classical DFS algorithm is obtained when freedom in Tarry’s algorithm is restricted by adopting the following third rule:

R3: When a process receives the token it sends it back through the same channel if this is allowed by R1 and R2

R1. A node never forwards the token through the same channel twice.R2. A node only forwards the token to its father when there is no otheroption.

Theorem: The classical depth-first search algorithm computes a depth-first search spanning tree using 2|E| messages and 2|E| time units.

Page 19: Traversal Algorithm

DFS Algorithm (Linear Time)

Classical DFS is characterized by high time complexity because all edges, tree edges and fronds are traversed serially.

Token <tok> message traverse all frond edges and return immediately in classical DFS

To achieve lower time complexity: Token <tok> only traverses tree edges. This gives a

linear time since there are only N- 1 edges

Page 20: Traversal Algorithm

Awerbuch’s Solution

Algorithm include mechanism that prevents the transmission of the token through a frond edge.

Ensures that each process knows at the moment when it must forward the token. Which of its neighbors have been visited already.

A process chooses an unvisited neighbor or sends the token to its own father if no such neighbor exists.

When process p is first visited by a <tok>, p informs each neighbor r, except its father of the visit by sending a <vis> message to r.

Page 21: Traversal Algorithm

Awerbuch’s Solution

The forwarding of the token is suspended until p has received and <ack> message from each neighbor.

When later, the token arrives at r, r will not forward the token to P, unless P is r’s father.

Awerbuch’s algorithm computes a depth-first search tree in 4N – 2 time units and uses 4.|E| messages

The sending of <vis> message can be omitted for the neighbor to which a process forwards the token. This improvement saves 2 messages per tree edge and hence reduces the message complexity by 2N-2 messages

Page 22: Traversal Algorithm

Cidon’s Solution

AIM: To improve on the time complexity of Awerbuch’s algorithm by not sending the <ack> message used in Awerbuch.

Algorithm description

In Cidon’s modified algorithm, the token is forwarded immediately i.e. it cancelled the two time unit delay introduced in Awerbuch’s algorithm(by waiting for <ack>)

Special Situation

A process p sent a <vis> message to its neighbor r after receiving a <tok> message

The token later visits r, but at the moment r receives the token, the <vis> message of p has not yet reached r.

Page 23: Traversal Algorithm

Cidon’s Solution

In this case, r may forward the token to p via the frond edge (differs from Awerbuch’s because, there is a need for <ack> to be received in Awerbuch’s solution).

Process p records neighbors it most recently sent the token in a variable mrsp.

Process r receives p’s <vis> message after sending the token to p, i.e. r, receives a <vis> message from neighbour mrsr.

In the above case, r acts as if no token has been sent to p; r selects a next neighbor and forwards the token.

Cidon’s Algorith computes a DFS tree in 2N-2 time units using 4.|E| messages.

Page 24: Traversal Algorithm

Cidon’s Solution

Analysis: Cidon’s algorithm sends fewer messages than Awerbuch’s algorithm in many cases

The above analysis of the number of messages assumes the most pessimistic case: Token message is sent through each frond in both

directions

Observation: Cidon observes that even though the algorithm may send the token to previously visited nodes, it has a better time, communication complexity than Awerbuch’s algorithm, which prevents such undesireable transmission.

Suggestion: less time and fewer messages may be spent in recovering from unnecessary actions than in avoiding these actions.

Page 25: Traversal Algorithm

DFS with Neighbor Knowledge

A list L of visited processes included in a token can be used to avoid traversal of fronds by token ⇔processes know the identity of their neighbors.

A process p, receiving the token with list L, does not forward the token to a process in list L.

The DFS algorithm with neighbor knowledge is a traversal algorithm and computes a depth-first search tree using 2N-2 messages in 2N-2 time units.

Observation: bit complexity is high ; if w is the no. of bits needed to represent one identity list L may require up to N.w bits.

Page 26: Traversal Algorithm

summary