Document Sample

University of Ottawa School of Information Technology and Engineering Genetic Algorithm for Graphs Drawing Mehrdad Nojoumian Dec. 5, 2005 COMP 5206 Professor Franz Oppacher 1 Contents Introduction: Main Idea of the Embedding Problem and It’s Goals Definitions: Pagenumber and Pagewidth Application in Different Engineering Fields: Electrical Eng., Civil Eng., Chemical Eng., Flight Eng., etc. Standard Graphs Embedding: (1) Outerplanar Graph (2) The Pinwheel Graph (3) The Sum of Triangles Graph (4) Complete Binary Tree (5) Square Grids (6) X-Tree (7) The Complete Graph K(n) Genetic Algorithms for Graph Drawimg: (1) Embedding a Graph by Genetic Algorithm Crossover, Mutation, Evaluation, Fitness Function and Practical Result (2) Drawing a Graph on a page by Genetic Algorithm Crossover, Mutation, Fitness Function and Practical Result Conclusion: References: 2 Introduction Main Idea: Embedding a graph in a book with its vertices in a line along the spine of the book and its edges on the pages in such a way that edges on the same page do not cross. Pagenumber: The number of pages that we use to draw the graph. Pagewidth: The maximum number of edges that cross any line perpendicular to the spine of the book. Order of inputs and Genetic Algorithms: If we arrange our inputs (vertices) in different ways, we can achieve different results, that is why GA has a very efficient role in this respect. Spine of the book d c d c d b c Perpendicular b Line, Width = 1 b a Perpendicular Line, Width = 2 a a 3 Page 1 Page 2 Page 1 Application in Different Engineering Fields Electrical Eng. : Designing Electrical Circuits Civil Eng. : City Architecture Chemical Eng. : To build Refinery Facilities Flight Eng. : Airlines Traffic Control Etc. Applied Goals: To minimize the use of the space To shorten the path To save resources (Money, Time, etc.) To simplify complex design (Understandable Design) To maintain security and safety (e.g. Reducing the intersection points in Airlines) And so on. 4 1- Outerplanar Graph Theorem: A graph can be embedded in a one-page book if, and only if, it is outerplanar. Definition: A graph G is outerplanar just when its vertices can be placed on a circle so that its edges become noncrossing chords of the circle. Sample of Outerplanar Graph 5 Outerplanar graph (Ctd) If we cut the circle between any two vertices and opening it out to form a line then it can be embedded in one page. Cutting An Embedding strategy: 1- Embedding the vertices of Graph in a circle by finding a hamiltonian cycle in G (even by adding some additional edges). 2- Transforming the edges of G into the chords of the circle. 2- Pinwheel Graph The depth-n pinwheel graph P(n) has 2n vertices. We must decompose the pinwheel graph into two adjacent butterflies, and continue this process: a1 b1 a1 b1 a2 b2 a2 b2 a3 b3 a3 b3 a4 b4 a4 b4 a5 b5 a5 b5 a6 b6 a6 b6 a7 b7 a7 b7 a8 b8 a8 b8 7 a1 b1 Pinwheel Graph (Ctd) a2 b2 a3 b3 a4 b4 The first two butterflies Pinwheel graph is 3-page The second two butterflies a5 b5 embeddable a6 b6 a7 b7 a8 b8 a1 b1 a8 b8 b7 a7 b2 a2 a3 b3 a6 b6 b5 a5 b4 a4 Page 1: Top of the vertices Page 2: Bottom of the vertices Page 3: Dotted lines 8 3- The Sum of Triangles Graph The depth-n sum of triangles graph T(n) has vertices: {ai, bi, ci: 1≤ i≤ n} and edges connecting each triple (ai, bi, ci) into a triangle, T(n) is 3(n)⅓-page embeddable: 3(n)⅓ = 3(3)⅓ = 3 3-page embeddable b1 a1 b2 c1 a2 a1 a2 a3 b3 b2 b1 c1 c2 c3 b3 c2 a3 c3 Order of Vertices: a1, a2, a3 - b3, b2, b1 - c1, c2, c3 Page 1: Top of the vertices, Page 2: Bottom of the vertices Page 3: Dotted lines 9 4- Complete Binary Tree 1 Complete Binary Tree needs one page to be 2 3 embedded and its pagewidth is (Log n) : Height = (Log n) 4 5 6 7 Without any arrangement: 2-page embeddable 1 2 3 4 5 6 7 Pagewidth = 2 In-Order (Left-Root-Right) 1-page embeddable 4 2 5 1 6 3 7 Pagewidth = 2 Pre-Order (Root-Left-Right) 1-page embeddable 1 2 4 5 3 7 6 Pagewidth = 3 10 5- Square Grids 16 12 1 2 3 4 15 11 14 10 5 6 7 8 9 Cutting 9 10 11 12 1 5 2 6 13 14 15 16 3 7 (n*n) square grid is planar and subhamiltonian, 4 8 hence 2-page Embeddable. By adding an edge (13-1) we can find Hamiltonian cycle. Page1 13 14 15 16 12 11 10 9 5 6 7 8 4 3 2 1 Page 2 11 6- X-Tree The depth-d X-Tree X(d) is the edge augmentation of the depth-d complete binary tree that adds edges going across each level of the tree in left-to-right order. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Proposition: The depth-d X-Tree admits a 2-page embedding, with one page of width 2d and one of width 3d. 12 1 X-Tree 13 7 (Ctd) 14 6 15 12 2 3 11 8 10 4 5 6 7 4 9 8 9 10 11 12 13 14 15 2 5 1 3 8 4 2 1 3 5 9 10 11 12 6 7 13 14 15 13 2 pages 7- The Complete Graph K(n) The K(n) is a complete graph, in which every pair of vertices is adjacent. Proposition: The complete graph is embeddable in (n/2) pages. 1 2 6 3 N=6 3 pages 1 2 3 6 5 4 5 4 14 Embedding a Graph by Genetic Algorithm Initialization: (1) Random Initialization: Create a layout randomly (2) Heuristic Method: Create a layout in which there are edges between all adjacent nodes, this one is better than the other one a1 a2 a3 a4 a5 a6 a7 a8 a1 a5 a3 a2 a8 a4 a6 a7 || E || = 7 and two different layout according to the order of vertices Crossover: (1) Cycle Crossover (2) Partially Mapped Crossover (3) Order Crossover Mutation: (1) Scramble (2) Move Block (3) Swap Block (4) Insert Evaluation: Fitness is simply a function of Pagenumber and Edge Intersections Termination: Terminate if the best fitness has not been surpassed for a set number of generation 15 Crossover Cycle Crossover (CC): Parent-1: j h d e f i g c b a Parent-2: h g e b c j i a d f Child-1: h g d e f j i c b a Child-2: j h e b c i g a d f Partially Mapped Crossover (PMC): Parent-1: j h d e f i g c b a Child-1: e h d b c j g f i a Parent-2: hg e b c j i a d f Child-2: h g b e f i c a d j Order Crossover (OC): Parent-1: j h d e f i g c b a Child-1: h d e b c j f i g a Parent-2: hg e b c j i a d f Child-2: h g b e f i c j a d 16 Mutation Scramble: Select a random block of elements and randomly reorder the elements in it: P: j h e d i f g c b a Reorder C: j h c d e f g i b a Move Block: Select a random block & move it to a random position: P: j h e d i f g c b a Position=2 C: j d i f g c h e b a Swap Block: Swap two blocks of elements: P: j h e d i f g c b a Swap C: j g c i f h e d b a Insert: Select a random element & insert it at a random position: P: j h e d i f g c b a Insert C: j h c e d i f g b a 17 Evaluation Solution space is composed from both permutation of Nodes & Edges. Generally: ||E|| > ||N|| (# of E is more than # of N) Permutation of Nodes (N): we apply genetic operators such as crossover and mutation to test different permutation for this part Permutation of Edges (E): After setting nodes we have to select edges and put them in to the layout, It is not practical to test all permutation of edges. we just try on: (1) Random edge selection (2) Order of best solution which we have found in our GA so far (3) Lexicographic order: according to the physical layout 18 Fitness Function a) || P || : We just consider the number of pages as a fitness function Problem: Two solutions with the same pagenumber are equally good while one may be closer to a solution. 4 2 5 1 6 3 7 Is better than 1 2 4 5 3 6 7 || P || = 1 || P || = 1 b) ( n * || P || ) + ( || E || in the smallest page ) n : Coefficient , || P || : number of pages , || E || : number of edges smallest page : is the page that has the lowest number of edges Smallest page has 2 edges Second page has 4 edges Largest page has 8 edges We take into account the || E || in smallest page which is a good potential for reducing the pagenumber 19 Fitness Function (Ctd) c) ( 0 * || E || in the 1st page ) + … + ( (k-1) * || E || in the Kth page ) we take into account the distribution of edges through pages but we do not have any strategy to define which one is the first page, etc d) ( 0 * || E || in the largest page )+…+( (k-1) * || E || in the smallest page) we take into account the distribution of edges and improve the previous function by ordering pages, so pages with less edges increase fitness value: ( 0 * 8 ) + ( 1 * 4 ) + ( 2 * 2 ) = 8 Smallest page has 2 edges Second page has 4 edges Largest page has 8 edges e) Number of edge crosses for a tested permutation of nodes, assuming all nodes and edges are embedded on a single page Edges are embedded on a single page and Number of edge crosses is 15 20 Practical Result Heuristic Method for initialization, in which there are edges between all adjacent nodes improved Genetic Algorithm three times as many optimal solution as the random initialization Mutation operators are not intended to find a better solution, their purpose is to ensure that breadth of search is maintained The last fitness function which is independent from pagenumber and distribution of edges through pages worked better than the other methods 21 Graph Drawing by Genetic Algorithm Encoding: 2 A genotype consist in a vector: { ( X1 , Y1 ) , ( X2 , Y2 ) , … , ( Xn, Yn ) } 4 where ( Xi , Yi ) are the coordinates of i th vertex of the graph Vertices: ( -3 , -2 ) , ( -2 , 2 ) , ( 1 , -3 ) , ( 2 , 1 ) Edges: (n1 - n2) , (n2 - n3) , (n2 - n4) , (n3 - n4) 1 3 Initialization: Initial vertex position for each individual is randomly generated Crossover: Uniform Crossover - Convex Hall Crossover - Single Point Crossover Mutation: Random Mutation Evaluation: The number of edge crossing The length of each edge The angles between edges incident into the same vertex 22 Crossover Uniform Crossover: Vertex positions have the same probability of being inherited from either parent: 2 2 2 4 4 4 1 1 3 1 3 3 Convex Hall Crossover: Parent-1: … ( Xi , Yi ) … … Child: ( Xi + M i / 2 , Yi + Ni / 2 ) … Parent-2: … ( M i , Ni ) … Single Point Crossover: Parent-1: (X1,Y1) , (X2,Y2) , (X3,Y3) , (X4,Y4) , (X5,Y5) , (X6,Y6) Parent-2: (M1,N1) , (M2,N2) , (M3,N3) , (M4,N4) , (M5,N5) , (M6,N6) Child-1: (X1,Y1) , (X2,Y2) , (X3,Y3) , (M4,N4) , (M5,N5) , (M6,N6) Child-2: (M1,N1) , (M2,N2) , (M3,N3) , (X4,Y4) , (X5,Y5) , (X6,Y6) 23 Mutation Random Mutation: ( X , Y ) Mutate ( M , N ) Where M & N are two independent distributed random variables with the mutation variance ^2, which is a constant parameter of the Genetic Algorithm ^2 = [ ( X1^2 + X2^2 + … + Xn^2) / n ] – [ (X1 + X2 + … + Xn ) / n ]^2 For example: We want to mutate point 3 : ( 2 , -2 ) Assume that our two random variables are as follow : ( -1 , 1 ) 2 2 4 Mutation 4 3 1 1 3 24 Fitness Function 1/(+1) + 1/(+1) + 1/(+1) The number of edge crossing There should be as few edge crossing as possible, # of edge crossing : The length of each edge The length of each edge should be as close as possible to a parameter “ L “ which is a constant parameter of the Genetic Algorithm = 1 / ||E|| [ ( ||e|| - L) / L ] ^ 2 || E || : Number of Edges || e || : Length of edges eЄE L : Constant The angles between edges incident into the same vertex The angles between edges incident into the same vertex should be as uniform as possible NV Nv : # of edges incident = [ ( ) – (2 / N ) ] ^ 2 v Є V K=1 k v v into vertex “v” k(v) : angles between adjacent vertices 25 Fitness Function (Ctd) 1/(+1) + 1/(+1) + 1/(+1) Assume L = 4.2 = 1 / ||E|| [ ( ||e|| - L) / L ] ^ 2 || E || : Number of Edges || e || : Length of edges eЄE L : Constant ||e|| = 4 cm & ||E|| = 4 ||e|| = 5 cm & ||E|| = 4 = ¼{ [(4 - 4.2)/4.2]^2 + [(4 - 4.2)/4.2]^2 + [(4 - 4.2)/4.2]^2 + [(4 - 4.2)/4.2]^2 = 0.0023 this one increases the fitness value = ¼{ [(5 - 4.2)/4.2]^2 + [(5 - 4.2)/4.2]^2 + [(5- 4.2)/4.2]^2 + [(5 - 4.2)/4.2]^2 = 0.0361 this one decreases the fitness value The graph in the left side has a better fitness value since L = 4.2 and the length of its edges is 4 while the length of edges in the other one is 5, if we change L into the , for example, 4.8 then the other graph will have a better fitness value 26 Fitness Function (Ctd) 1/(+1) + 1/(+1) + 1/(+1) Assume we have 5 vertices in the following two pictures NV [ ( ) – (2 / N ) ] ^ 2 Nv : # of edges incident = k v v into vertex “v” k(v) : angles between v Є V K=1 adjacent vertices a b a b 90 c c 90 90 d 90 e e d = (5/6-2/1)^2 + (/6-2/1)^2 + (11/6-2/1)^2 + (10/6-2/1)^2 + [(5/6-2/4)^2 + (/6-2/4)^2 + (11/6-2/4)^2 + (10/6-2/4)^2 ] = 8.2 ^2 = (3/4-2/1)^2 + (/4-2/1)^2 + (7/4-2/1)^2 + (5/4-2/1)^2 + [(3/4-2/4)^2 + (/4-2/4)^2 + (7/4-2/4)^2 + (5/4-2/4)^2 ] = 7.5 ^2 The graph in the right side has a better fitness value since angles between adjacent vertices are equal 27 Practical Result G represents the road plan of a neighbourhood of Milan and contains ||V|| = 39 vertices and ||E|| = 58 edges An example of random layout for A layout of Graph G, found by the Graph G, having fitness 0.006193 algorithm with uniform crossover after 10,000 generations, having fitness 0.221208 28 Conclusion Embedding graphs in books is a kind of Optimization Problem which has a lot of useful applications Genetic Algorithms have very good practical results for graphs drawing since the landscape is large We can minimize our parameters based on various structural properties of the graph Embedding a graph in a book is a NP-complete problem since it depends on permutation of Nodes and Edges 29 References 1. N. Kapoor and et al, “A Genetic Algorithm for Finding the Pagenumber of Interconnection Networks”, Journal of Parallel and Distributed Computing 62, 2002. 2. A. Tettamanzi, “Drawing Graphs With Evolutionary Algorithms”, Genetica - Advanced Software Architectures, Italy, 1998. 3. Timo Eloranta and Erkki Makinen, “TimGA - A Genetic Algorithm for Drawing Undirected Graphs”, University of Tampere,1996. 4. J. Branke, F. Bucher, H. Schmeck, “Using Genetic Algorithm for Drawing Undirected Graphs”, University of Karlsruhe, 1996. 5. F. Chung and et al, “Embedding Graphs in Books: a layout problem with applications to VSLI design”, SIAM Journal on Algebraic & Discrete Methods 8, 1987. 6. Joseph L. Ganley and Lenwood S. Heath, “The Pagenumber of Trees”, Virginia University, 2000. 7. Janos Pach and Rephael Wenger, “Embedding Planar Graphs at Fixed Vertex Locations”, Ohio State University, 1999. 8. M. Alzohairi, “The Pagenumber of Ordered Sets”, PhD Thesis, University of Ottawa, Sep. 1996. 30

DOCUMENT INFO

Shared By:

Categories:

Tags:

Stats:

views: | 8 |

posted: | 12/18/2011 |

language: | |

pages: | 30 |

OTHER DOCS BY ajizai

How are you planning on using Docstoc?
BUSINESS
PERSONAL

By registering with docstoc.com you agree to our
privacy policy and
terms of service, and to receive content and offer notifications.

Docstoc is the premier online destination to start and grow small businesses. It hosts the best quality and widest selection of professional documents (over 20 million) and resources including expert videos, articles and productivity tools to make every small business better.

Search or Browse for any specific document or resource you need for your business. Or explore our curated resources for Starting a Business, Growing a Business or for Professional Development.

Feel free to Contact Us with any questions you might have.