1 / 32

ECE 669 Parallel Computer Architecture Lecture 10 Graph Applications

ECE 669 Parallel Computer Architecture Lecture 10 Graph Applications. Outline. Many applications can be modeled as graphs Graphs require determination of shortest paths, adjacency, and other values Efficient parallel algorithms exist which break up the search Used to model many applications

felice
Download Presentation

ECE 669 Parallel Computer Architecture Lecture 10 Graph Applications

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. ECE 669Parallel Computer ArchitectureLecture 10Graph Applications

  2. Outline • Many applications can be modeled as graphs • Graphs require determination of shortest paths, adjacency, and other values • Efficient parallel algorithms exist which break up the search • Used to model many applications • VLSI CAD • Mapping • Sales planning

  3. A graph is a pair (V, E), where V is a set of nodes, called vertices E is a collection of pairs of vertices, called edges Vertices and edges are positions and store elements Example: A vertex represents an airport and stores the three-letter airport code An edge represents a flight route between two airports and stores the mileage of the route Graph 849 PVD 1843 ORD 142 SFO 802 LGA 1743 337 1387 HNL 2555 1099 1233 LAX 1120 DFW MIA

  4. Edge Types • Directed edge • ordered pair of vertices (u,v) • first vertex u is the origin • second vertex v is the destination • e.g., a flight • Undirected edge • unordered pair of vertices (u,v) • e.g., a flight route • Directed graph • all the edges are directed • e.g., route network • Undirected graph • all the edges are undirected • e.g., flight network flight AA 1206 ORD PVD 849 miles ORD PVD

  5. Applications • Electronic circuits • Printed circuit board • Integrated circuit • Transportation networks • Highway network • Flight network • Computer networks • Local area network • Internet • Web • Databases • Entity-relationship diagram

  6. V a b h j U d X Z c e i W g f Y Terminology • End vertices (or endpoints) of an edge • U and V are the endpoints of a • Edges incident on a vertex • a, d, and b are incident on V • Adjacent vertices • U and V are adjacent • Degree of a vertex • X has degree 5 • Parallel edges • h and i are parallel edges • Self-loop • j is a self-loop

  7. Terminology • Path • sequence of alternating vertices and edges • begins with a vertex • ends with a vertex • each edge is preceded and followed by its endpoints • Simple path • path such that all its vertices and edges are distinct • Examples • P1=(V,b,X,h,Z) is a simple path • P2=(U,c,W,e,X,g,Y,f,W,d,V) is a path that is not simple V b a P1 d U X Z P2 h c e W g f Y

  8. Terminology • Cycle • circular sequence of alternating vertices and edges • each edge is preceded and followed by its endpoints • Simple cycle • cycle such that all its vertices and edges are distinct • Examples • C1=(V,b,X,g,Y,f,W,c,U,a,) is a simple cycle • C2=(U,c,W,e,X,g,Y,f,W,d,V,a,) is a cycle that is not simple V a b d U X Z C2 h e C1 c W g f Y

  9. Edge List Structure • Vertex object • element • reference to position in vertex sequence • Edge object • element • origin vertex object • destination vertex object • reference to position in edge sequence • Vertex sequence • sequence of vertex objects • Edge sequence • sequence of edge objects u a c b d v w z z w u v a b c d

  10. Traveling Salesman Problem • Goal is to find the shortest route that starts at one city and visit each of a list of other cities exactly once before returning to the first city. • For n cities there are (n-1)! diferent paths starting and ending in city 1. • In practice an exact solution is infeasible except for small values of n. • Many approximation algorithms are developed.

  11. Backtracking Algorithm One sequential solution is to examine all feasible paths. A path is feasible if it is not longer than the best complete path that has been determined so far. We start with city 1, there are n-1 possible cities to visit next. From each of these, there are n-2 possible cities to visit and so on. 1 4 2 3 2 4 4 3 3 2 3 2 4 2 4 3

  12. Backtracking Algorithm The standard method to examine all the paths in a tree is to use depth-first search method (DFS). There is no need to consider a path that is known to be longer than the shortest completed path that has been found so far. 1 4 2 3 2 4 4 3 3 2 3 2 4 2 4 3

  13. Parallel Solution • The paths are independent; thus, we could examine all of them in parallel. • The approach is to provide a fixed number of slave processes that share a pool of tasks. • Each task consists of a partial path, the number of cities visited on a path, and the path length. • Each process takes a partial path and extends it with every city which has not been considered. • If the length of the path is longer than the length of the shortest complete path, the path is discarded.

  14. 5 2 2 • • 1 2 4 3 1 • • 4 7 2 6 2 5 • 3 • 6 1 6 Traveling Salesman • Example • Find shortest tour: E.g. (1 2 5 6 3 4) and then back to 1

  15. ,c=0 1 • 1 6 7 2 2 6 ,c=6 ,c=1 • • c=5 4 3 4 ,c=7 • • 3 ,c=4 • 2 2 4 • c=3 ,c=3 5 • • • • • ( ) - 1 ! n 2 Exhaustive Search • Find lowest c path, • But tours!!! • Can exploit parallelism though! X X X X 2

  16. Branch and Bound Algorithms - Prune! • Naive

  17. Branch and Bound Algorithms - Prune! • Naive • (1, 2 ...) Most promising, follow that lead -- greedy

  18. 1,c=0 • 1 2,c=1 • 2 7 6 • 3,c=2 • • 4,c=7 6,c=6 4 6 1 5 5 6 • 4 • • 2 • c=7 c=8 c=3 c=6 Branch and Bound Algorithms - Prune! • Naive • (1, 2 ...) Most promising, follow that lead -- greedy • (1, 3 ...) Most promising

  19. 1,c=0 • 1 2,c=1 • 2 7 4 6 • 2 3,c=2 2 3 • • 6,c=6 4,c=7 c=5 4 5 c=3 c=3 4 6 1 5 5 6 • 4 • • 2 • c=7 c=8 c=3 c=6 Branch and Bound Algorithms - Prune! • (1, 2 ...) Most promising, follow that lead -- greedy • (1, 3 ...) Most promising • • Continue ... till a tour is found

  20. 4 6 1 5 5 6 • 4 • • 2 • c=7 c=8 c=3 c=6 Branch and Bound Algorithms - Prune! 1,c=0 • 1 2,c=1 • 2 7 4 6 3,c=2 • 2 2 3 • • 6,c=6 4,c=7 c=5 (1 2 4 3 5 6) 4 5 c=3 BOUND: 21 c=3 19 2 c=5 6 • 1 c=6 3 • 6 c=12 • 4 7 c=19 • 1 • Continue ... ‘til a tour is found

  21. Representing agraph in an algorithm may be accomplished via two different methods: adjacency matrix and linked list. • Consider a graph with n vertices that are numbered 1,2,…, n. The adjacency matrix of this graph can be defined as n x n matrix A with the following properties: • 1 if (v(I), v(j)) E • A(i, j) = • 0 otherwise. Representing Graphs

  22. 2 4 2 2 2 6 1 9 3 1 6 4 4 2 Better Algorithm, but basically Branch and Bound • Little et al. • Basic Ideas: Cost matrix

  23. 2 4 2 5 0 4 2 2 2 6 1 9 3 1 6 4 4 2 Better Algorithm, but basically Branch and Bound • Little et al. • Notion of reduction: • Subtract same value from each row or column

  24. 2 4 2 2 2 6 1 9 3 1 6 4 4 2 Better Algorithm, but basically Branch and Bound Little et al. 4 2 5 0 1 0 1 1

  25. 2 4 2 2 2 6 1 9 3 1 6 4 4 2 Better Algorithm, but basically Branch and Bound Little et al. 4 2 5 0 1 0 1 1

  26. 2 5 0 0 4 4 2 0 5 1 1 4 4 2 2 2 6 0 2 1 9 0 1 3 1 0 1 1 6 4 2 1 1 4 2 Better Algorithm Reduce all rows & columns 10 is cost of opt. tour 1+1+2+1+1+4

  27. Further Analysis • In other words, the Traveling Salesman Problem is stated as: • Given a set of vertices and non-negative cost C(I,J) associated with each pair of vertices I and J, find a circuit containing every vertex in the graph so that the cost of the entire path is minimized. • The problem can be classified as • Symmetric Salesman Problem – C(I,J)=C(J,I) for all I,J • Asymmetric Traveling Salesman Problem - C(I,J) C(J,I) for all I, J.

  28. Another Example 5 1 9 2 3 8 5 6 5 9 2 7 4 3 5 4 1 8 7 4 2 6 3 2 7 4 6 3

  29. Graph Coloring Problem Let G be undirected graph and let c be an integer. Assignment of colors to the vertices or edges such that no two adjacent vertices are to be similarly colored. We want to minimize the number of colors used. The smallest c such that a c-coloring exists is called the graph’s chromatic number and any such c-coloring is an optimal coloring.

  30. Coloring of Graph • The graph coloring optimization problem: find the minimum number of colors needed to color a graph. • The graph coloring decision problem: determine if there exists a coloring for a given graph which uses at most m colors. Two colors No solution with two colors

  31. Coloring of Graphs Practical applications: scheduling, time-tabling, register allocation for compilers, coloring of maps. A simple graph coloring algorithm - choose a color and an arbitrary starting vertex and color all the vertices that can be colored with that color. Choose next starting vertex and next color and repeat the coloring until all the vertices are colored. Three colors are enough Four colors

  32. Summary • Many applications can be modeled as graphs • Graphs require determination of shortest paths, adjacency, and other values • Efficient parallel algorithms exist which break up the search • Used to model many applications • VLSI CAD • Mapping • Sales planning

More Related