I NTRODUCTION TO G RAPH DRAWING Fall 2010 Battista, G. D., Eades, P., Tamassia, R., and Tollis, I. G. 1998 Graph Drawing: Algorithms for the Visualization.

Slides:



Advertisements
Similar presentations
Octagonal Drawing Johan van Rooij. Overview What is an octagonal drawing Good slicing graphs Octagonal drawing algorithm for good slicing graphs Correctness.
Advertisements

INTERVAL TREE & SEGMENTATION TREE
Divide and Conquer. Subject Series-Parallel Digraphs Planarity testing.
I NTRODUCTION TO G RAPH DRAWING Fall 2010 Battista, G. D., Eades, P., Tamassia, R., and Tollis, I. G Graph Drawing: Algorithms for the Visualization.
Chapter 10: Trees. Definition A tree is a connected undirected acyclic (with no cycle) simple graph A collection of trees is called forest.
Efficient access to TIN Regular square grid TIN Efficient access to TIN Let q := (x, y) be a point. We want to estimate an elevation at a point q: 1. should.
Lecture 3: Parallel Algorithm Design
AVL Trees1 Part-F2 AVL Trees v z. AVL Trees2 AVL Tree Definition (§ 9.2) AVL trees are balanced. An AVL Tree is a binary search tree such that.
Dynamic Planar Convex Hull Operations in Near- Logarithmic Amortized Time TIMOTHY M. CHAN.
2/14/13CMPS 3120 Computational Geometry1 CMPS 3120: Computational Geometry Spring 2013 Planar Subdivisions and Point Location Carola Wenk Based on: Computational.
Greedy Algorithms Greed is good. (Some of the time)
Divide and Conquer: Rooted Trees. 2 Introduction Rooted trees: acyclic graphs (no cycles) all edges directed away from root. downward planar drawing (child.
Brute-Force Triangulation
The Divide-and-Conquer Strategy
Convex Hulls in Two Dimensions Definitions Basic algorithms Gift Wrapping (algorithm of Jarvis ) Graham scan Divide and conquer Convex Hull for line intersections.
Seminar Graph Drawing H : Introduction to Graph Drawing Jesper Nederlof Roeland Luitwieler.
Tree Drawing Algorithms and Visualization Methods Kai (Kevin) Xu.
Advanced Topics in Algorithms and Data Structures Lecture 7.1, page 1 An overview of lecture 7 An optimal parallel algorithm for the 2D convex hull problem,
Computational Geometry
1 Trees. 2 Outline –Tree Structures –Tree Node Level and Path Length –Binary Tree Definition –Binary Tree Nodes –Binary Search Trees.
Lists A list is a finite, ordered sequence of data items. Two Implementations –Arrays –Linked Lists.
Dynamic Set Binary Trees G.Kamberova, Algorithms Dynamic Set ADT Binary Trees Gerda Kamberova Department of Computer Science Hofstra University.
Voronoi Diagrams.
Data Structures Using C++ 2E Chapter 11 Binary Trees and B-Trees.
AALG, lecture 11, © Simonas Šaltenis, Range Searching in 2D Main goals of the lecture: to understand and to be able to analyze the kd-trees and.
Binary Trees Chapter 6.
Graph Algorithms Using Depth First Search Prepared by John Reif, Ph.D. Distinguished Professor of Computer Science Duke University Analysis of Algorithms.
Advanced Data Structures and Algorithms COSC-600 Lecture presentation-6.
Orthogonal Range Searching I Range Trees. Range Searching S = set of geometric objects Q = query object Report/Count objects in S that intersect Q Query.
I NTRODUCTION TO G RAPH DRAWING Fall 2010 Battista, G. D., Eades, P., Tamassia, R., and Tollis, I. G Graph Drawing: Algorithms for the Visualization.
UNC Chapel Hill M. C. Lin Orthogonal Range Searching Reading: Chapter 5 of the Textbook Driving Applications –Querying a Database Related Application –Crystal.
1 Trees 2 Binary trees Section Binary Trees Definition: A binary tree is a rooted tree in which no vertex has more than two children –Left and.
1 Section 1.4 Graphs and Trees A graph is set of objects called vertices or nodes where some pairs of objects may be connected by edges. (A directed graph.
Binary Trees, Binary Search Trees RIZWAN REHMAN CENTRE FOR COMPUTER STUDIES DIBRUGARH UNIVERSITY.
Lecture 8 Tree.
2IL50 Data Structures Fall 2015 Lecture 9: Range Searching.
1 Prune-and-Search Method 2012/10/30. A simple example: Binary search sorted sequence : (search 9) step 1  step 2  step 3  Binary search.
A Study of Balanced Search Trees: Brainstorming a New Balanced Search Tree Anthony Kim, 2005 Computer Systems Research.
Preview  Graph  Tree Binary Tree Binary Search Tree Binary Search Tree Property Binary Search Tree functions  In-order walk  Pre-order walk  Post-order.
Paradigms for Graph Drawing Graph Drawing: Algorithms for the Visualization of Graphs - Chapter 2 Presented by Liana Diesendruck.
Priority Queues and Heaps. October 2004John Edgar2  A queue should implement at least the first two of these operations:  insert – insert item at the.
Agenda Review: –Planar Graphs Lecture Content:  Concepts of Trees  Spanning Trees  Binary Trees Exercise.
Review 1 Queue Operations on Queues A Dequeue Operation An Enqueue Operation Array Implementation Link list Implementation Examples.
CSE554Contouring IISlide 1 CSE 554 Lecture 5: Contouring (faster) Fall 2015.
CSE554Contouring IISlide 1 CSE 554 Lecture 3: Contouring II Fall 2011.
Lecture 7: Searching a Tree Neil Ghani University of Strathclyde.
Chapter 11. Chapter Summary  Introduction to trees (11.1)  Application of trees (11.2)  Tree traversal (11.3)  Spanning trees (11.4)
Polygon Triangulation
I NTRODUCTION TO G RAPH DRAWING Fall 2010 Battista, G. D., Eades, P., Tamassia, R., and Tollis, I. G Graph Drawing: Algorithms for the Visualization.
Tree Representation and Terminology Binary Trees Binary Search Trees Pointer-Based Representation of a Binary Tree Array-Based Representation of a Binary.
UNC Chapel Hill M. C. Lin Geometric Data Structures Reading: Chapter 10 of the Textbook Driving Applications –Windowing Queries Related Application –Query.
Trees.
CSE 554 Lecture 5: Contouring (faster)
Data Structure and Algorithms
Lecture 3: Parallel Algorithm Design
CSC 421: Algorithm Design & Analysis
CSC 421: Algorithm Design & Analysis
Source Code for Data Structures and Algorithm Analysis in C (Second Edition) – by Weiss
CSC 421: Algorithm Design & Analysis
12. Graphs and Trees 2 Summary
Heaps © 2010 Goodrich, Tamassia Heaps Heaps
Graph Algorithms Using Depth First Search
5-Minute Review How does the Inorder tree layout algorithm work? Which tree drawing requirements does it (not) fulfill? What is its main drawback? How.
Taibah University College of Computer Science & Engineering Course Title: Discrete Mathematics Code: CS 103 Chapter 10 Trees Slides are adopted from “Discrete.
Depth Estimation via Sampling
CSC 421: Algorithm Design & Analysis
Introduction to Graph drawing
Data Structures Using C++ 2E
Presentation transcript:

I NTRODUCTION TO G RAPH DRAWING Fall 2010 Battista, G. D., Eades, P., Tamassia, R., and Tollis, I. G Graph Drawing: Algorithms for the Visualization of Graphs. 1st. Prentice Hall PTR.

D IVIDE AND CONQUER Rooted tree Layered Drawing : vertices are placed on horizontal layers Radial Drawing : layers are mapped on concentric circles HV-Drawing : edges are drawn as rightward horizontal or downward vertical segment. Recursive Winding : drawings with constant aspect ratio and small area

T ERMINOLOGY Tree: Acyclic graph Rooted tree Root: a distinguished vertex in tree Usually treated as a directed graph: all edges oriented away from the root Direct edge u --> v : u is the parent of v and v is the child of u Leaf: no child Ordered tree: rooted tree with an ordering for the children of every vertex

T ERMINOLOGY Binary tree: rooted tree with every node has at most two children Left and right child One child, either left or right Subtree rooted at v : the subgraph induced by all vertices that have v as their “ancestor” Binary tree: left and right subtree Depth of a vertex: number of edges between it and the root Height of a tree: maximum depth

T REE D RAWING A LGORITHM Layered Drawing Radial Drawing HV-Drawing Recursive Winding

A simple method for constructing downward planar drawing: Vertex with depth i is placed into layer L i Root placed in the top layer L 0 Layered drawing is strictly downward. Vertex v of depth i has y(v) = - i L AYERING

In-Order Traversal: Vertex v is j -th vertex encountered in inorder traversal of the tree, then x(v) = j Problems: Much wider than necessary Parent not centered with respect to children

T REE T RAVERSALS – SHORT REVIEW In Order:A,B,C,D,E,F,G,H,I Pre Order:F,B,A,D,C,E,G,I,H Post Order:A,C,E,D,B,H,I,G,F

input= binary tree T output= layered drawing of T Divide and conquer Reduce width Horizontally centers parent vertex Yields aesthetically pleasing drawings L AYERED -T REE -D RAW A LGORITHM

Base Case: If T has only 1 vertex, drawing is trivially defined Divide: recursively apply algorithm to draw left and right subtrees of T. Conquer: move drawings of subtrees until horizontal distance = 2. place the root r vertically one level above and horizontally half way between its children. If only one child, place root at horizontal distance 1 from child. L AYERED -T REE -D RAW A LGORITHM

Base Case: If T has only 1 vertex, drawing is trivially defined Divide: recursively apply algorithm to draw left and right subtrees of T. Conquer: move drawings of subtrees until horizontal distance = 2. place the root r vertically one level above and horizontally half way between its children. If only one child, place root at horizontal distance 1 from child.

L AYERED -T REE -D RAW A LGORITHM left contour: Sequence of vertices v 0 … v h such that v i is the leftmost vertex of T with depth i ( right contour is defined similarly) In the conquer step, follow right contour of left subtree and left contour of right subtree

L AYERED -T REE -D RAW A LGORITHM Compute left and right contour of vertex v : scan right contour of left subtree ( T’ ) and left contour of right subtree ( T’’ ) gather displacements of vertices on the left & right contour keep the max increasing displacement at any depth

L AYERED -T REE -D RAW A LGORITHM L(T) = left contour list R(T) = right contour list case 1: height(T’) = height(T’’) L(T) = L(T’) + v R(T) = R(T’’) + v case 2: height(T’) < height(T’’) R(T) = R(T’’) + v L(T) = v + L(T’) + {part of L(T’’) starting from w} h’: depth of T’ w: the vertex on L(T’’) whose depth = h’+1 case 3: height(T’) > height(T’’) : similar to case2

L AYERING S UMMARY Time Complexity: Pre order: linear Post order: linear Hence, algorithm runs in linear time.

T REE D RAWING A LGORITHM Layered Drawing Radial Drawing HV-Drawing Recursive Winding

17 R ADIAL D RAWING A variation of layered drawing Root at the origin Layers are concentric circles centered at the origin Vertices of depth i placed on circle C i

18 R ADIAL D RAWING : W EDGE A NGLE Subtree rooted at vertex v is drawn within annulus wedge W v. It may seem reasonable to choose wedge angle to be proportional to l(v) = number of leavs in the subtree rooted at v This can lead to edge crossings, because edge with endpoints within W v can extend outside W v and intersect other edges.

19 R ADIAL D RAWING : W EDGE A NGLE Prevent edge crossings - restrict vertices to convex subset of wedge. Suppose: vertex v lies on C i, tangent to C i through v meets C i+1 at a and b. Region F v is convex. We restrict subtree rooted at v to lie within F v Children of v arranged on C i+1 according to # of leaves in their respective subtrees. More precisely - for each child u of v, the angle β u of wedge W u is β u = min( [ β v * l(u) / l(v )], τ ) β v = angle of W v, τ = angle formed by F v child u is placed on C i at the center of W v.

T REE D RAWING A LGORITHM Layered Drawing Radial Drawing HV-Drawing Recursive Winding

HV-D RAWING – B INARY T REE HV-drawing of a binary tree T : straight-line grid drawing such that for each vertex u, a child of u is either horizontally aligned with and to the right of u, or vertically aligned with and below u the bounding rectangles of the subtrees of u do not intersect Planar, straight-line, orthogonal, and downward

D IVIDE & C ONQUER M ETHOD Divide: recursively construct hv-drawings for the left & right subtrees Conquer: perform either a horizontal combination or a vertical combination The height & width are each at most n-1

R IGHT -H EAVY -HV-T REE -D RAWING ALGORITHM *** 1. Recursively construct drawing of the left & right subtrees 2. Using only horizontal combination, place the subtree with the largest number of vertices to the right of the other one.

L EMMAS AND THEOREMS Let T be a binary tree with n vertices, the height of the drawing of T constructed by the Right-Heavy-HV- Tree-Drawing Algorithm is at most logn. Let T be a binary tree with n vertices, Right-Heavy- HV-Tree-Drawing Algorithm construct a drawing Γ of T in O( n ) time, such that: Γ is an hv-drawing The area of Γ is O( nlogn ) The width of Γ is at most n-1 The height of Γ is at most logn

R IGHT -H EAVY -HV-T REE -D RAWING HV-drawing (downward, planar, grid, straight-line and orthogonal) Width is at most n-1 Height is at most logn The larger subtree is always placed to the right The size of parent subtree is at least twice the size of vertical child subtree area O(nlogn)

A REA -A SPECT R ATIO Right-Heavy-HV-Tree-Draw Good area bound, but bad aspect ratio Better aspect ratio: use both vertical and horizontal combinations Alternating the combination Odd level: horizontal, even level: vertical O(n) area and constant aspect ratio

It is possible to construct an HV-drawing of a binary tree that is optimal with respect to area or perimeter in O(n 2 ) time. Right-Heavy-HV-Tree-Drawing can be extended to general rooted tree Downward, planar, grid, straight-line Area O(nlogn) Width is at most n-1 Height is at most logn O PTIMIZATION AND E XTENSION Largest subtree

T REE D RAWING A LGORITHM Layered Drawing Radial Drawing HV-Drawing Recursive Winding

R ECURSIVE W INDING Similar to HV- drawing For binary tree Produce planar downward straight- line grid drawing Constant aspect ratio Almost linear area T1T1 T k-2 T k-1 T’ T’’ …

R ECURSIVE W INDING Input: a binary tree with n vertices and l leaves. n=2 l -1 For a vertex v : left(v) : left child; right(v) : right child T(v) : subtree rooted at v l (v): number of leaves in T(v) Recursive winding tree drawing H( l ): height of the drawing of T with l leaves W( l ): width of the drawing of T with l leaves t( l ) : running time

R ECURSIVE W INDING T REE D RAWING Arrange the tree so that l (left(v)) ≤ l (right(v)) at every vertex v ; Give a parameter A>1,if l ≤A, then draw the tree using right-heavy-HV-tree; H( l ) ≤log 2 l, W( l )≤A, and t( l )=O(A) ; If l >A, define a sequence { v i }: v 1 is the root and v i +1=right(v i ) for i=1,2,… ; Let k≥1 be an index with l (v k )> l -A and l (v k+1 )≤ l -A. Such a k can be found in O(k) time, since l (v 1 ), l (v 2 ), … is a strictly decreasing order

R ECURSIVE W INDING T REE D RAWING Let T i =T(left(v i )) and l i = l (left(v i )) for i=1,…,k-1 Let T’=T(left(v k )), T’’=T(right(v k )), l ’= l (left(v k )), and l ’’= l (right(v k )) Note that l ’≤ l ’’, since T is right heavy l 1 + … + l k-1 = l - l (v k ) < A Max { l ’, l ’’ } = l (v k +1)≤ l -A v1v1 T1T1 v2v2 T2T2 … V k-2 T k-2 V k-1 T k-1 vkvk T’T’’

R ECURSIVE W INDING T REE D RAWING If k=1, T’ and T’’ are drawn recursively below v 1 ; If k=2, T 1 is drawn with right-heavy-HV-tree, while T’ and T’’ are drawn recursively; If k=3, T 1,…T k-2 are drawn from left to right with right-heavy-HV-tree. T k-1 is drawn right-heavy-HV- tree and then reflected around y-axis and rotated by π/2. T’ and T’’ are drawn recursively below and then reflected around y-axis so that their roots are placed at upper right- hand corners. (This is the “recursive winding”) v1v1 T’ T’’ k=1 v1v1 T1T1 T’’ T’ k=2 T1T1 T k-2 T k-1 T’ T’’ … k>2

R ECURSIVE W INDING T REE D RAWING Bounds: H( l ) ≤ max{H( l ’) + H( l ’’) + log 2 A + 3, l k-1 -1} W( l ) ≤ max{W( l ’) + 1, W( l ’’), l 1 +…+ l k-2 } + log 2 l k t( l ) ≤ t( l ’) + t( l ’’) + O( l 1 + … + l k-1 + 1) Because L 1 + … + l k-1 = l - l (v k ) < A, H( l ) ≤ max{H( l ’) + H( l ’’) + O(logA), A} W( l ) ≤ max{W( l ’), W( l ’’), A} + O(log 2A ) t( l ) ≤ t( l ’) + t( l ’’) + O(A) Because Max{ l ’, l ’’}= l (v k +1)≤ l -A, W( l ) = O( l /A·logA + A)

R ECURSIVE W INDING T REE D RAWING The running time is O(n) ; By setting A as A = √( l ·log 2 l ), the height and width of the drawing are both O(√nlogn). An example