1 / 36

Teacher: Chun-Yuan Lin

This book provides an introduction to distributed algorithms, covering Pascal-like pseudocode conventions, message passing operations, and control-oriented vs. event-driven notations. It also delves into graph theory terminologies, including undirected graphs, paths, cycles, connectivity, and planar graphs.

neuman
Download Presentation

Teacher: Chun-Yuan Lin

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to Distributed AlgorithmAppendix A: Pseudocode ConventionsAppendix B: Graphs and Networks Teacher: Chun-Yuan Lin Appendices A and B

  2. Appendix A: Pseudocode Conventions Appendices A and B

  3. Pascal-like pseudocode • The pseudocode used in this book very much resembles the language Pascal. • Process names can be used as array indices, and set variables are used. • The variableNeighpis the set of processes to which p is connected (the neighbors of p). • Assignment ("a :== expression"). • Conditional statement (“ifcondition thenstatemenf”, with an optional “elsestatemenf” part). • loop (“whilecondition dostatemenf”). • The forall statement has the form “forallx X dostatemenf”, where x is a formal parameter and X a set. Ex. forall qNeighp doRp[q]:=0. • begin and end. Appendices A and B

  4. Message passing(1) • The operations "send" and "receive" are used to describe message passing in the pseudocode. • Assume that each process must send to its neighbors its identity (process name) and its degree (number of neighbors). • This message is denoted as (info, a, b). • The send operation must be given a message (its type and the value of its data fields) and a destination. To send its identity and degree to process q, process p may execute: send <info, idp, |Neighp|> to q. • The shorthand "shout" is used to send a message to all neighbors. shout <info, idp, |Neighp|> as forall q  Neighp do send <info, idp, |Neighp|> to q . Appendices A and B

  5. Message passing(2) • To receive a message, its type as well as formal parameters for the data fields of the message and its sender must be specified. To receive the information regarding the identity and degree of a neighboring node, process p may execute: receive <info, a, b> from q . • A process may need to receive a message from a specific process, receive <info, a, b> from this q0 . • The communication between processes can be either asynchronousor synchronous. Appendices A and B

  6. Control-oriented versus event-driven notation • The control-oriented notation of an algorithm consists of a declaration of its variables and a semicolon-separated list of statements enclosed between begin and end. • Event-driven notation consists of a declaration of variables together with the initialization of these variables, followed by a list of actions. Appendices A and B

  7. Appendices A and B

  8. Appendix B: Graphs and Networks Appendices A and B

  9. Definitions and Terminology(1) • As the topology of a distributed system is usually modeled by a graph, some knowledge of graph theory and its terminology is useful in the study of distributed algorithms. • A graph can be thought of as a collection of points (called the nodesof the graph) some of which are connected by lines (the edges). Appendices A and B

  10. Undirected Graphs(1) • An undirected graph G is a pair (V, E), where Vis a set called the node set of G and Eis a collection of unordered pairs from V. • An element of E is a pair of {u, v} with u, vV. To shorten the notation, we write uvE instead of {u, v}E. (uv E is equivalent to vu E) • The edge uvis called an incident edge of u (and of v). • If uvE, the nodes u and v are said to be adjacent, or neighbors. • The degreeof a node is the number of edges incident to it, or, equivalently, its number of neighbors. • The graph is called regular if all nodes have the same degree. Appendices A and B

  11. Undirected Graphs(2) • A pathof length k between v0and vkis a sequence P = < v0, ... , vk > of nodes such that for each i < k, vivi+1E. • A cycle is a path of which the begin node equals the end node. • A path is called simpleif the nodes v0through vkare all different. A cycle is called simpleif the nodes v0 through vkare all different. • The distance between u and v, denoted d(u, v), is the length of a shortest path between u and v. • The diameter of G is the largest distance between any two nodes. • An undirected graph is connectedif there exists a path between each pair of nodes. • An undirected graph is called acyclicif it contains no simple cycle of length three or more. Appendices A and B

  12. Undirected Graphs(3) • A graph G’= (V’, E’)is called a subgraph of G if V’V and E’  E. • G’is called a spanning subgraphif V’=V . • G’is called an induced subgraphif E’= {uvE| uV’^v  V’}. • A connected component of G is a maximal connected induced subgraph G’ of G; that is, G’is a connected induced subgraph. • A graph is called a planar graphif it is possible to draw the graph in the plane without crossing edges. • A graph is called outerplanar if it is possible to draw the graph in the plane without crossing the edges and with all nodes on the border of the picture. Appendices A and B

  13. Undirected Graphs(4) • The following properties of planar and outerplanar graphs are of interest. Appendices A and B

  14. Directed Graphs(1) • A directed graph G is a pair (V, E), where Vis the node set, and Eis a collection of ordered pairs from V. • uv E is not equivalent to vu E. • The edge uv is called an outgoing edge of u and an incoming edge of v. • If uv E, v is called an out-neighbor of u, and u is called an in-neighbor of v. • The in-degreeof a node is the number of its incoming edges, and the out-degreeis the number of outgoing edges. The degree is the sum of the in-degree and the out-degree. • With same definitions for path, cycle, simple, distance by undirected graph. Appendices A and B

  15. Directed Graphs(2) • A directed graph is strongly connectedif there exists a path from each node to each other node. • A directed graph is called acyclicif it contains no simple cycle of length two or more. Appendices A and B

  16. Weighted Graphs • A (directed or undirected) graph is weightedif for each pair u, v with uvE, a numerical value Wuvis defined. • The weight assignment is called symmetricif, for each pair, Wuv= Wvu. • In a weighted graph, the weight of a path is defined as the sum of the edge weights over the edges in the path. • If no weight assignment is assumed for a graph, it is called unweighted. Appendices A and B

  17. Frequently Used Graphs • Some classes of graph that occur frequently in the study of distributed algorithms, namely, rings, trees, forests, grids, tori, cliques, and hypercubes. • In the sequel, G = (V, E)be a graph, Nthe number of its nodes, and Dthe diameter. Appendices A and B

  18. Rings • The ring topology is a circular arrangement of nodes, and is often used as a control topology in distributed computations. • Definition B.lA ring is an undirected, connected, regular graph of degree two. • Theorem B.2The following are equivalent for an undirected graph G. • A spanning ring can sometimes be defined in a graph G = (V, E); that is, a set E’  E is selected such that (V, E’)is a ring. • It is NP-complete to decide whether a given graph has spanning ring. (not every graph contains one) (virtual ring) Appendices A and B

  19. Trees, Forests, and Stars (1) • Trees • A tree is a graph that contains a minimal number of edges connecting its nodes, and as a result computations on tree-shaped networks may have a very low communication complexity. • Definition B.3A tree is an undirected, connected, acyclic graph. • Theorem B.4The following are equivalent for an undirected graph G. Appendices A and B

  20. Trees, Forests, and Stars (2) • A tree T = (V, E)is rootedif there is a unique designated node r called the root. • u is a node on the (unique) simple path between v and r, u is called an ancestorof v, and v is called adescendantof u. • u and v are neighbors, v is called a son(or child) of u, and u is called the father(or parent) of v. • The subgraph induced by the descendants of u is a rooted tree (with root u), called the subtree ofu. • The depth of the tree is the maximal length of any simple path from the root to a node. • Every connected graph G = (V, E)contains a spanning tree; that is, a set E’  E can be chosen, such that (V, E’)is a tree. Appendices A and B

  21. Trees, Forests, and Stars (3) • Low-diameter spanning tree • If the spanning tree must be chosen to minimize the total time necessary for a computation on it, it is desirable that the diameter is as small as possible. • Minimal-weight spanning tree • If the total communication cost for a computation in a spanning tree must be low, the subtree must be chosen so as to minimize the weight of the tree. (If all edge weights are different, the minimal-weight spanning tree is unique) • Restricted-degree spanning tree • If the computation overhead per node must be low, a spanning tree must be selected that has a low degree for each node. • Depth-first search tree • A spanning tree is a depth-first search spanning tree if each frond edge connects a node and a descendant of that node. Appendices A and B

  22. Trees, Forests, and Stars (4) • A graph consisting of a number of isolated trees is called a forest. • Definition B.5A forest is an undirected acyclic graph. • Theorem B.6The following are equivalent for an undirected graph G. • A forest is rooted if a root node is designated in every tree of the forest. • Every graph has a spanning forest, consisting of a spanning tree of each connected component of the graph. Appendices A and B

  23. Trees, Forests, and Stars (5) • A star is a graph with one special node, the center, and all other nodes are connected only to this center. • Definition B.7A star is a rooted tree of depth one. The root of the star is called the center. • Theorem B.8The following are equivalent for an undirected graph G. • Stars are not usual as a physical connection topology of a distributed systems; rather, stars are the virtual topology used in computations that are controlled by a central process. Appendices A and B

  24. Cliques • In a clique, sometimes also called a complete graph, each pair of nodes is directly connected by an edge. • Definition B.9A clique is a graph with diameter one. • Theorem B.l0The following are equivalent for an undirected graph G. • As is the case for stars, cliques are rarely used as a physical connection topology. (higher layer) Appendices A and B

  25. Grids and Tori (1) • In an n ×n grid there are N = n2nodes, arranged in n rows of n nodes each. Each node is connected to the nodes above it, right and left of it, and under it. • The n ×ntorus is similar, but in addition the leftmost and rightmost node of each row are adjacent, and the uppermost and lowermost node of each column are adjacent. • The n ×n grid has 2n(n -1) edges, contains nodes of degree two, three, and four, and its diameter is 2(n - 1). The n ×n torus has 2n2edges, is regular of degree four, and its diameter is Appendices A and B

  26. Grids and Tori (2) Appendices A and B

  27. Hypercubes(1) • Like grids and tori, hypercubes are often used in the design of multiprocessor computers. (Both diameter and degree equal logN, where N is the number of nodes) • Definition B.l2The n-dimensional hypercubeis a graph on N = 2n nodes where each node can be assigned a unique element from the set oflabels {(b0, ... , bn-1): bi= 0, 1} in such a way thatE = {uv : the labels of u and v differ in one bit}. • Theorem B.13The following are equivalent for an undirected graph G. Appendices A and B

  28. Hypercubes(2) • The hypercube is regular of degree n, and has diameter n. • An (n + 1 )-dimensional hypercube can be constructed by taking two n­dimensional hypercubes and connecting corresponding nodes. Appendices A and B

  29. Hypercubes(3) Appendices A and B

  30. Sense of Direction (1) • It was observed that the communication complexity of distributed computations is influenced by following factors • Topological awareness In order to exploit the advantages of a specific topology, it is sometimes necessary that the processes "know" that they are connected in a topology of this class. • Sense of direction The routing of information through a network can be done more efficiently if the edges incident to each node are labelled with the "direction" to wl1ich they lead in the network. Appendices A and B

  31. Sense of Direction (2) Appendices A and B

  32. Sense of Direction-Ring • As the ring is regular of degree two, there are only two directions in the ring; we call them “Pred” (previous) and “Next”. • Definition B.14A labeling of the ring is an assignment at every node of different labels from the set {Prev, Next} to the edges incident to that node. A labeling S of the ring constitutes a sense of direction if for all adjacent nodes u and v, Su(v) =Prev  Sv(u) = Next. Appendices A and B

  33. Sense of Direction-Cliques • The clique of N nodes has degree N - 1; its directions are numbered from 1 through N – 1. • Definition B.15A labeling of the clique is an assignment at every node of different labels from the set {1, ... , N - 1} to the edges incident to that node.A labeling S of the clique constitutes a sense of direction if the nodes of the clique can be numbered from 0 through N - 1, in such a way that for every i and j, Si(j)= (j - i) mod N. Appendices A and B

  34. Sense of Direction-Tori • The four directions of the torus are called up, down, right, and left, abbreviated U, D, R, L. Appendices A and B

  35. Sense of Direction-Hypercubes • The n dimensions of the n-dimensional hypercube are numbered from 0 through n - 1. There is a sense of direction if all parallel edges are labeled with the same number. Appendices A and B

  36. Sense of Direction (3) Appendices A and B

More Related