Presentation is loading. Please wait.

Presentation is loading. Please wait.

COMP4048 Planar and Orthogonal Graph Drawing Algorithms Richard Webber National ICT Australia.

Similar presentations


Presentation on theme: "COMP4048 Planar and Orthogonal Graph Drawing Algorithms Richard Webber National ICT Australia."— Presentation transcript:

1 COMP4048 Planar and Orthogonal Graph Drawing Algorithms Richard Webber National ICT Australia

2 Lecture Overview Planarity Testing Planarity Tessellation Drawings Visibility Drawings Polyline Drawings Orthogonal Drawings via Visibility Drawings Orthogonal Drawings via Network Flow Degree > 4 Bend Stretching Degree > 4 again

3 Planarity A graph is planar if it can be drawn such that no edges cross A drawing is planar if it is drawn with no edges crossing

4 Planarity Straight-line drawing with no edge crossings = Fáry Drawing (Fáry 1948) 2D Fáry Drawing = Planar (Graph) Drawing  Planar Drawing   Planar Embedding  Planar Graph Plane Graph (drawing) = 2d

5 Planarity Simple Planar Embedding  n + f = m + 2  m = O(n) and f = O(n)  m  3n-6 Euler (http://www-history.mcs.st-andrews.ac.uk/Biographies/Euler.html)http://www-history.mcs.st-andrews.ac.uk/Biographies/Euler.html

6 Testing Planarity (Di Battista et al. 1999, Goldstein 1963) Trees and SP Digraphs = planar Graph = planar  connect components = planar Connect components = planar  biconnected components = planar –Biconnected  two vertex-disjoint paths

7 Testing Planarity 1.Find a cycle C in G (biconnected  cycle must exist) 2.Decompose remaining edges into pieces P i –Connected without passing vertices of C –Incident vertices in C are attachments of P i –If C  2+ pieces then C is separating –If C  1 piece then C is non-separating –C non-separating and P 1  a path   separating C

8 Testing Planarity

9 Each piece must lie entirely inside or outside C Two pieces interlace if they cannot both be inside (outside) C without breaking planarity Interlacement graph I of G with respect to C –Vertices = pieces of G –Edges between interlacing pieces

10 Testing Planarity Biconnected G with cycle C is planar iff 1.For each piece P, P’ = P  C is planar; and 2.Interlacement graph I is bipartite Planarity of P’ determined recursively

11 Testing Planarity 1.Compute piece of G with respect to C 2.For each non-path piece P 1. P’ = P  C 2. C’ = cycle of P’ by replacing C between consecutive attachments with a path through P 3.Recursively test P’ with C’ – return if “non-planar” 3.Compute interlacement graph I 4.Return “non-planar” if I not bipartite 5.Return “planar”

12 Testing Planarity Computing pieces and finding C’ : O(n) Computing I and testing bipartite: O(n 2 ) Each invocation = O(n 2 ), O(n) invocations  O(n 3 ) running time Can be improved to O(n) (Hopcroft+Tarjan 1974) Can construct planar embedding –use bipartite interlacement graph to alternate inside/outside pieces –path-pieces trivially inserted –non-path-pieces constructed recursively

13 Planar st-Graphs (Di Battista et al. 1999, Lempel et al. 1967) Digraphs only s = source, t = sink – only one of each –Add dummies if needed Topological numbering – number(v) for v  V such that (u, v)  E  number(v) > number(u) Topological sorting – numbering  [0..n-1] For weighted edges number(v)  number(u) + weight(u, v) number(s) = 0 ; number(v) by max over BFS –optimal in O(n + m) time

14 Planar st-Graphs

15 F = faces of planar st -graph G such that external face split: left s* and right t* orig(e), dest(e), left(e), right(e) left(v), right(v), orig( f ), dest( f ) orig(v) = dest(v) = v ; left( f ) = right( f ) = f G* = ( F, { ( left(e), right(e) ) | e  E } ) –G* is also planar st -graph

16 Planar st-Graphs

17

18 Tessellation Drawings (Di Battista et al. 1999, Tamassia+Tollis 1989) Vertices / Edges / Faces = Objects Object o drawn as a rectangle  (o) –Possibly degenerate  (o 1 )   (o 2 ) =  Union over all o  V  E  F = rectangle  (o) s horizontally adjacent  o s left/right  (o) s vertically adjacent  o s orig/dest

19 Tessellation Drawings 1. G* from G 2.Topological numbering Y of G 3.Topological numbering X of G* 4.For each o  V  E  F –x L (o) = X(left(o)) –x R (o) = X(right(o)) –y B (o) = Y(orig(o)) –y T (o) = Y(dest(o)) O(n) time and O(n 2 ) area

20 Tessellation Drawings

21 Visibility Drawings (Di Battista et al. 1999, Tamassia+Tollis 1986) Vertices = Horizontal lines Edges = Vertical lines Intersections only where edges meet end- points Tessellation Drawing  Visibility Drawing –degenerate vertices, non-degenerate faces

22 Visibility Drawings 1.G* from G 2.weight(e) = 1 – Optimal topological numbering Y of G 3.weight(e*) = 1 – Optimal topological numbering X of G* 4.For each v  V –y (v) = Y(v) ; x L (v) = X(left(v)) ; x R (v) = X(right(v))-1 5.For each e  E –x (e) = X(left(e)) ; y B (e) = Y(orig(e)) ; y T (e) = Y(dest(e)) O(n) time and O(n 2 ) area

23 Visibility Drawings

24 Constrained Visibility (Di Battista et al. 1999, Di Battista et al. 1992) Identify non-intersecting paths  i in G –No common edges –No “crossings” –Can “touch” at vertices

25 Constrained Visibility Set of paths  covers G – Add single-edge paths 1.Duplicate each path, adding faces to G* gives G  2. weight(e) = 1, Y(s) = 0 – Optimal topological numbering Y of G 3. weight(e*) = 0.5, X(s*) = -0.5 – Optimal topological numbering X of G 

26 Constrained Visibility 4.For each    : for each e   –x (e) = X(  ) –y B (e) = Y(orig(e)) –y T (e) = Y(dest(e)) 5.For each v  V –y(v) = Y(v) –x L (v) = min v   X(  ) –x R (o) = max v   X(  ) O(n) time and O(n 2 ) area

27 Constrained Visibility

28 Polyline Drawings (Di Battista et al. 1999, Di Battista et al. 1992) 1.Construct a visibility drawing 2.Place vertex v i at an arbitrary p i on its line segment 3.Draw short edge (v i, v j ) as line p i  p j 4.Draw long edge (v i, v j ) as polyline p i  (x (u, v), y u +1)  (x (u, v), y v -1)  p j

29 Polyline Drawing Place vertex at mid-point of its line segment O(n) time and O(n 2 ) area  6n-12 bends (2 per edge)

30 Polyline Drawing Place vertex above long edges if they exist O(n) time and O(n 2 ) area  (10n-31)/3 bends

31 Polyline Drawing Use constrained visibility Place vertex on path O(n) time and O(n 2 ) area  4n-10 bends

32 Orthogonal via Visibility (Di Battista et al. 1999) Input = planar st -graph 1.Create subpaths  v for v  {s,t} –2 incoming edges  leftmost-in  rightmost-out –1 or 3 incoming edges  median-in  median- out

33 Orthogonal via Visibility

34 2.Unify subpaths with common edges to give  3.Apply Constrained-Visibility algorithm

35 Orthogonal via Visibility 4.Create orthogonal drawing –Place vertex v  {s,t} on path  v –Place s ( t ) on path of median of out (in) edges –Routes general edges via paths –Route s ( t ) edges as … 

36 Orthogonal via Visibility O(n) time, O(n 2 ) area,  2n+4 bends

37 Orthogonal via Network Flow (Di Battista et al. 1999, Tamassia 1987) Visibility guarantees O(1) bends per edge Want to minimise total bends for embedding –minimising over all embeddings in NP-hard Represent angles as a commodity –Produced by vertices, consumed by faces, transferred by bends Apply a cost to each bend –Minimising bends = minimising cost of flow!

38 Orthogonal via Network Flow Replace each (undirected) edge (u, v) with two darts (u, v) and (v, u) –dart = counterclockwise for f  f is on left  (u, v)·  /2 = angle from dart (u, v) to next dart counterclockwise about u  (u, v) = number of “left” bends in (u, v) Orthogonal representation = all ( ,  ) –Same representation  same number bends

39 Orthogonal via Network Flow

40 Network N such that… Source (sink) v produces (consumes)  (v ) Arc (u, v) has –Lower bound (u, v) –Capacity  (u, v) –Cost  (u, v) –Flow  (u, v) such that (u, v)   (u, v)   (u, v) Sum  into v  {s,t} = sum  out Cost of flow  in N = sum all  (u, v)·  (u, v)

41 Orthogonal via Network Flow Embed Graph G into Network N by… Nodes of N = vertices and faces of G Vertex-node v produces  (v) = 4 Internal face-node f consumes  (f) = 2a(f)-4 External face-node f consumes  (f) = 2a(f)+4 –a(f) = number vertex-angles in face f

42 Orthogonal via Network Flow Dart (u, v) with left (right) face f ( g )  –arc (u, f) : (u, f) = 1,  (u, f) = 4,  (u, f) = 0   (u, v) –arc (f, g) : (f, g) = 0,  (f, g) = ,  (f, g) = 1   (u, v)

43 Orthogonal via Network Flow 1.Construct N from G – O(n) time 2.Compute minimum cost flow for N – O (n 2 log n) (Ahuja et al. 1993) or O(n 7/4 log n) (Garg+Tamassia 1997) time 3.Map N to orthogonal representation for G – O(n) time

44 Orthogonal via Network Flow To map orthogonal representation to drawing… 1.Divide the faces into rectangles e  corner(e)  next(e) – counterclockwise turn(e) = +1 (left), 0 (straight), –1 (right) front(e) = 1st next(e’) s.t. sum e..e’ = +1 If turn(e) = –1 then insert –Vertex project(e) in front(e) –Edge extend(e) = (corner(e), project(e))

45 Orthogonal via Network Flow External face by enclosing in a rectangle Total O(n+b) time – b = number of bends

46 Orthogonal via Network Flow 2.Assign edge lengths Minimising lengths/area – compaction Interior rectangles:  (u, v)  2,  (u, v) = 0 Exterior rectangle:  (u, v)  2,  (u, v) = 0 Use horizontal and vertical flow networks, N hor and N ver

47 Orthogonal via Network Flow Horizontal Flow Network N hor –Nodes = interior faces of G plus lower s and upper t outer face –Arcs (f, g)  face f shares horizontal edge with face g – f below g – (f, g) = 1,  (f, g) = ,  (f, g) = 1 –  (f, g) = length of horizontal edge N ver is analogous

48 Orthogonal via Network Flow

49 Run-time dominated by network flow –O(n 2 log n) or O(n 7/4 log n) –Guarantees minimal width/height/length/area Alternative Method –Place dummy vertices in external corners –Treat vertical (horizontal) paths as vertices –Calculate topological ordering X ( Y ) –Edge length = X(v)-X(u) ( Y(v)-Y(u) ) –O(n) time, but no guarantee of minimal total edge length

50 Degree > 4 (Di Battista et al. 1999, Fößmeier+ Kaufmann 1996) Replace vertex v of degree d > 4 with a cycle v 1, …, v d – each v i incident to one edge incident to v Solve using Network Flow such that cycle edges have no bends… –For edge (u, v) separating faces f and g,  (f, g) =  (g, f) = 0 By planarity, still O(n) vertices

51 Degree > 4

52 Bend Stretching (Di Battista et al. 1999, Tamassia+Tollis 1989) 1.Take any planar orthogonal drawing 2.Identify configurations that can be transformed to reduce bends 3.Iterate General case requires O(n 2 ) Identifying special cases requires O(n)

53 Bend Stretching   

54

55

56

57

58 Alternative Degree > 4 (Di Battista et al. 1999, Papakostas+Tollis 1997) Vertices are rectangular boxes –width = max(1, out-degree-1) –height = max(1,  in-degree/2  -1) Place vertices in order by st -numbering –Place above previous vertex –Place between median in-coming edges –Route in-coming edges to left and right sides –Route out-going edges from top

59 Degree > 4

60 References I. Fáry (1948): “On Straight Lines Representations of Planar Graphs” in Acta Scientiarum Mathematicarum, 11:229-233 G. Di Battista, P. Eades, R. Tamassia, I. G. Tollis (1999): Graph Drawing: Algorithms for the Visualization of Graphs, Prentice-Hall A. J. Goldstein (1963): “An Efficient and Constructive Algorithm for Testing Whether a Graph can be Embedded in the Plane”, Proc. Graph and Combinatorics Conf. J. Hopcroft, R. E. Tarjan (1974): “Efficient Planarity Testing”, J. ACM, 21(4):549-568 A. Lempel, S. Even, I. Celerbaum (1967): “An Algorithm for Planarity Testing of Graphs”, Proc. Int. Symp. Theory of Graphs (1966), pp. 215-232, Gordon and Breach

61 References R. Tamassia, I. G. Tollis (1989): “Tessellations Representations of Planar Graphs”, Proc. 27th Allerton Conf. Communication, Control and Computing R. Tamassia, I. G. Tollis (1986): “A Unified Approach to Visibility Representations of Planar Graphs”, Discrete and Computational Geometry, 1(4):321-341 G. Di Battista, R. Tamassia, I. G. Tollis (1992): “Constrained Visibility Representations of Graphs”, Information Processing Letters, 41:1-7 R. Tamassia (1987): “On Embedding a Graph in the Grid with the Minimum Number of Bends”, SIAM J. Computing, 16(3):421-444 R. K. Ahuja, T. L. Magnanti, J. B. Orlin (1993): Network Flows: Theory, Algorithms and Applications, Prentice-Hall

62 References A. Garg, R. Tamassia (1997): “A New Minimum Cost Flow Algorithm with Applications to Graph Drawing”, Proc. Graph Drawing (1996), Springer-Verlag, LNCS 1190:193- 200 U. Fößmeier, M. Kaufmann (1996): “Drawing High Degree Graphs with Low Bend Numbers”, Proc. Graph Drawing (1995), Springer-Verlag, LNCS 1027:254-266 R. Tamassia, I. G. Tollis (1989): “Planar Grid Embedding in Linear Time”, IEEE Trans. Circuits and Systems, 36(9):1230-1234 A. Papakostas, I. G. Tollis (1997): “Orthogonal Drawing of High Degree Graphs with Small Area and Few Bends”, Proc. 5th Work. Algorithms and Data Structures, Springer- Verlag, LNCS, 1272:354-367


Download ppt "COMP4048 Planar and Orthogonal Graph Drawing Algorithms Richard Webber National ICT Australia."

Similar presentations


Ads by Google