INTRODUCTION TO GRAPH DRAWING - University...
Transcript of INTRODUCTION TO GRAPH DRAWING - University...
![Page 1: INTRODUCTION TO GRAPH DRAWING - University …innovis.cpsc.ucalgary.ca/innovis/uploads/Courses/GraphDrawing-201… · INTRODUCTION TO GRAPH DRAWING Fall 2010 Battista G D Battista,](https://reader034.fdocuments.net/reader034/viewer/2022051206/5b62cab77f8b9a09498e1572/html5/thumbnails/1.jpg)
INTRODUCTION TOGRAPH DRAWINGFall 2010
Battista G D Eades P Tamassia R and Tollis I G 1998 Battista, G. D., Eades, P., Tamassia, R., and Tollis, I. G. 1998 Graph Drawing: Algorithms for the Visualization of Graphs. 1st. Prentice Hall PTR.
![Page 2: INTRODUCTION TO GRAPH DRAWING - University …innovis.cpsc.ucalgary.ca/innovis/uploads/Courses/GraphDrawing-201… · INTRODUCTION TO GRAPH DRAWING Fall 2010 Battista G D Battista,](https://reader034.fdocuments.net/reader034/viewer/2022051206/5b62cab77f8b9a09498e1572/html5/thumbnails/2.jpg)
PLANARITY TESTING
![Page 3: INTRODUCTION TO GRAPH DRAWING - University …innovis.cpsc.ucalgary.ca/innovis/uploads/Courses/GraphDrawing-201… · INTRODUCTION TO GRAPH DRAWING Fall 2010 Battista G D Battista,](https://reader034.fdocuments.net/reader034/viewer/2022051206/5b62cab77f8b9a09498e1572/html5/thumbnails/3.jpg)
PLANARITY TESTING
1. Count edges and check Euler's formulag2. Find pieces of G3. For each piece P that is not a path
test planarity by recursion4. Compute interlacement graph of the pieces5 T t if th i t l t h i bi tit5. Test if the interlacement graph is bipartite
![Page 4: INTRODUCTION TO GRAPH DRAWING - University …innovis.cpsc.ucalgary.ca/innovis/uploads/Courses/GraphDrawing-201… · INTRODUCTION TO GRAPH DRAWING Fall 2010 Battista G D Battista,](https://reader034.fdocuments.net/reader034/viewer/2022051206/5b62cab77f8b9a09498e1572/html5/thumbnails/4.jpg)
PLANARITY TESTING
Graph is planar if and only if all its connected p p ycomponents are planarA connected graph is planar if and only if all its bi t d t lbiconnected components are planar
![Page 5: INTRODUCTION TO GRAPH DRAWING - University …innovis.cpsc.ucalgary.ca/innovis/uploads/Courses/GraphDrawing-201… · INTRODUCTION TO GRAPH DRAWING Fall 2010 Battista G D Battista,](https://reader034.fdocuments.net/reader034/viewer/2022051206/5b62cab77f8b9a09498e1572/html5/thumbnails/5.jpg)
REVIEW
A graph is connected if there is a path between ug p pand v for each pair (u,v) of vertices A cutvertex in a graph is a vertex whose removal di t th hdisconnects the graph.A connected graph with no cutvertices is biconnected.biconnected.A maximal biconnected subgraph of a graph is biconnected component.
![Page 6: INTRODUCTION TO GRAPH DRAWING - University …innovis.cpsc.ucalgary.ca/innovis/uploads/Courses/GraphDrawing-201… · INTRODUCTION TO GRAPH DRAWING Fall 2010 Battista G D Battista,](https://reader034.fdocuments.net/reader034/viewer/2022051206/5b62cab77f8b9a09498e1572/html5/thumbnails/6.jpg)
Decomposing the Graph into connected and p g pbiconnected components. Our problem will be restricted to testing the
l it f bi t d hplanarity of biconnected graphs.Use cycle to decompose a biconnected graph into pieces.pieces.
![Page 7: INTRODUCTION TO GRAPH DRAWING - University …innovis.cpsc.ucalgary.ca/innovis/uploads/Courses/GraphDrawing-201… · INTRODUCTION TO GRAPH DRAWING Fall 2010 Battista G D Battista,](https://reader034.fdocuments.net/reader034/viewer/2022051206/5b62cab77f8b9a09498e1572/html5/thumbnails/7.jpg)
PIECE P OF A GRAPH G WITH RESPECT TOPATH C
The subgrap induced by the edges of path C in a g p y g pclass is called a piece of G with respect to C
v6v4
v7v2
v7v2v3
4 v9
v1v5
' ( ' ')G V Ev9
v1v5
v8
1
v2
' ( ', ')'' ( ' ')
G V EV VE E V V
=⊆⊆ ∩ ×
( , )G V E= v8
1 v7
v9
v2
' ( ', ')'' ( ' ')
G V EV VE E V V
=⊆= ∩ × v8
v1v5
![Page 8: INTRODUCTION TO GRAPH DRAWING - University …innovis.cpsc.ucalgary.ca/innovis/uploads/Courses/GraphDrawing-201… · INTRODUCTION TO GRAPH DRAWING Fall 2010 Battista G D Battista,](https://reader034.fdocuments.net/reader034/viewer/2022051206/5b62cab77f8b9a09498e1572/html5/thumbnails/8.jpg)
PARTITIONING INTO PIECES
Let a biconnected graph G contain a cycle Cg p yPartition the edges of G not on C into classes:
Two edges of G are in the same class if there is a path b t th th t d t t i t f Cbetween them that dose not contain any vertex of C.
![Page 9: INTRODUCTION TO GRAPH DRAWING - University …innovis.cpsc.ucalgary.ca/innovis/uploads/Courses/GraphDrawing-201… · INTRODUCTION TO GRAPH DRAWING Fall 2010 Battista G D Battista,](https://reader034.fdocuments.net/reader034/viewer/2022051206/5b62cab77f8b9a09498e1572/html5/thumbnails/9.jpg)
SUB GRAPH INDUCED BY EDGES IN A CLASS ISCALLED A PIECE OF G WITH RESPECT TO C.
Pieces consisting of a single edge between two Pieces consisting of a single edge between two vertices of CPieces consisting of a connected graph with at least one vertex not in C
![Page 10: INTRODUCTION TO GRAPH DRAWING - University …innovis.cpsc.ucalgary.ca/innovis/uploads/Courses/GraphDrawing-201… · INTRODUCTION TO GRAPH DRAWING Fall 2010 Battista G D Battista,](https://reader034.fdocuments.net/reader034/viewer/2022051206/5b62cab77f8b9a09498e1572/html5/thumbnails/10.jpg)
ATTACHMENTS
Vertices of piece P which are also on cycle C are p ycalled attachments of P.Each piece has at least two attachments. (why?)
![Page 11: INTRODUCTION TO GRAPH DRAWING - University …innovis.cpsc.ucalgary.ca/innovis/uploads/Courses/GraphDrawing-201… · INTRODUCTION TO GRAPH DRAWING Fall 2010 Battista G D Battista,](https://reader034.fdocuments.net/reader034/viewer/2022051206/5b62cab77f8b9a09498e1572/html5/thumbnails/11.jpg)
SEPARATING CYCLE
Cycle C is separating if it has at least two pieces.y p g pAnd it is nonseparating if it has one piece.
separatingnonseparating
![Page 12: INTRODUCTION TO GRAPH DRAWING - University …innovis.cpsc.ucalgary.ca/innovis/uploads/Courses/GraphDrawing-201… · INTRODUCTION TO GRAPH DRAWING Fall 2010 Battista G D Battista,](https://reader034.fdocuments.net/reader034/viewer/2022051206/5b62cab77f8b9a09498e1572/html5/thumbnails/12.jpg)
LEMMA 3.4Let G be a biconnected graph and C be a g pnonseparating cycle of G with piece P. If P is not a path then G has a separating cycle C’ consisting of subpath of C and a path of Pof subpath of C and a path of P.
separatingnonseparating
![Page 13: INTRODUCTION TO GRAPH DRAWING - University …innovis.cpsc.ucalgary.ca/innovis/uploads/Courses/GraphDrawing-201… · INTRODUCTION TO GRAPH DRAWING Fall 2010 Battista G D Battista,](https://reader034.fdocuments.net/reader034/viewer/2022051206/5b62cab77f8b9a09498e1572/html5/thumbnails/13.jpg)
LEMMA 3.4 PROOF
Let u and v be 2 attachments of P that areti i th i l d iconsecutive in the circular ordering.
Let γ be a subpath of C between u and vwithout any attachments.Si P i t d th i γ
π
Since P is connected there is apath π in P between u and v.Let C’ be the cycle obtained from Cby replacing γ with π C
γe
by replacing γ with π.Now γ is a piece on G with respect to C’Let e be an edge on P not π.e exist Because P is not a pathe exist Because P is not a path.So there is a piece of C’ otherthan γ which contains e.Thus C’ is a separating cycle in G
C’
Thus C is a separating cycle in G.
![Page 14: INTRODUCTION TO GRAPH DRAWING - University …innovis.cpsc.ucalgary.ca/innovis/uploads/Courses/GraphDrawing-201… · INTRODUCTION TO GRAPH DRAWING Fall 2010 Battista G D Battista,](https://reader034.fdocuments.net/reader034/viewer/2022051206/5b62cab77f8b9a09498e1572/html5/thumbnails/14.jpg)
INTERLACEMENT
Each piece can be drawn either entirelyp yinside or outside of the cycleInterlacing pieces are ones that can’t be drawn on th id f C ith t ithe same side of C without crossing
Interlace
Not interlace
![Page 15: INTRODUCTION TO GRAPH DRAWING - University …innovis.cpsc.ucalgary.ca/innovis/uploads/Courses/GraphDrawing-201… · INTRODUCTION TO GRAPH DRAWING Fall 2010 Battista G D Battista,](https://reader034.fdocuments.net/reader034/viewer/2022051206/5b62cab77f8b9a09498e1572/html5/thumbnails/15.jpg)
INTERLACEMENT GRAPH
Vertices are pieces on G with respect to cycle Cp p yEdges are pairs of pieces that interlace (can’t reside on the same side of C without crossing).
![Page 16: INTRODUCTION TO GRAPH DRAWING - University …innovis.cpsc.ucalgary.ca/innovis/uploads/Courses/GraphDrawing-201… · INTRODUCTION TO GRAPH DRAWING Fall 2010 Battista G D Battista,](https://reader034.fdocuments.net/reader034/viewer/2022051206/5b62cab77f8b9a09498e1572/html5/thumbnails/16.jpg)
INTERLACEMENT TO PLANARITY
If G is planar graph then its interlacement graph p g p g pmust be bipartite
P3P1
P5P6
P2P4
P2
![Page 17: INTRODUCTION TO GRAPH DRAWING - University …innovis.cpsc.ucalgary.ca/innovis/uploads/Courses/GraphDrawing-201… · INTRODUCTION TO GRAPH DRAWING Fall 2010 Battista G D Battista,](https://reader034.fdocuments.net/reader034/viewer/2022051206/5b62cab77f8b9a09498e1572/html5/thumbnails/17.jpg)
THEOREM 3.8A biconnected graph G with cycle C is planar g p y pif and only if:For each piece P of G with respect to C, the graph bt i d b ddi P t C i lobtained by adding P to C is planar
The interlacement graph of the pieces of G with respect to C, is bipartiterespect to C, is bipartite
![Page 18: INTRODUCTION TO GRAPH DRAWING - University …innovis.cpsc.ucalgary.ca/innovis/uploads/Courses/GraphDrawing-201… · INTRODUCTION TO GRAPH DRAWING Fall 2010 Battista G D Battista,](https://reader034.fdocuments.net/reader034/viewer/2022051206/5b62cab77f8b9a09498e1572/html5/thumbnails/18.jpg)
PLANARITY TESTING
1. Count edges and check Euler's formulag2. Find pieces of G3. For each piece P that is not a path
test planarity by recursion4. Compute interlacement graph of the pieces5 T t if th i t l t h i bi tit5. Test if the interlacement graph is bipartite
![Page 19: INTRODUCTION TO GRAPH DRAWING - University …innovis.cpsc.ucalgary.ca/innovis/uploads/Courses/GraphDrawing-201… · INTRODUCTION TO GRAPH DRAWING Fall 2010 Battista G D Battista,](https://reader034.fdocuments.net/reader034/viewer/2022051206/5b62cab77f8b9a09498e1572/html5/thumbnails/19.jpg)
ALGORITHM PLANARITY TESTING
Input a biconnected graph G with n vertices and at p g pmost 3n-6 edges, and a separating cycle C.
Output an indication of whether G is planar
1 C t th i f G ith t t C (O( ))1. Compute the pieces of G with respect to C. (O(n))
![Page 20: INTRODUCTION TO GRAPH DRAWING - University …innovis.cpsc.ucalgary.ca/innovis/uploads/Courses/GraphDrawing-201… · INTRODUCTION TO GRAPH DRAWING Fall 2010 Battista G D Battista,](https://reader034.fdocuments.net/reader034/viewer/2022051206/5b62cab77f8b9a09498e1572/html5/thumbnails/20.jpg)
ALGORITHM PLANARITY TESTING
2. For each piece P of G that is not a path:p pLet P’ be the graph obtained by adding P to CLet C’ be the cycle of P’ obtained from C by replacing the portion of C between two consecutive attachments the portion of C between two consecutive attachments with a path P between themApply the algorithm recursively to graph P’ and cycle C’ If P’ i l t “ l ” (O( 2)) C’. If P’ is nonplanar, return “nonplanar”. (O(n2))
![Page 21: INTRODUCTION TO GRAPH DRAWING - University …innovis.cpsc.ucalgary.ca/innovis/uploads/Courses/GraphDrawing-201… · INTRODUCTION TO GRAPH DRAWING Fall 2010 Battista G D Battista,](https://reader034.fdocuments.net/reader034/viewer/2022051206/5b62cab77f8b9a09498e1572/html5/thumbnails/21.jpg)
ALGORITHM PLANARITY TESTING
3. Compute the interlacement graph I of the p g ppieces. (O(n2))
![Page 22: INTRODUCTION TO GRAPH DRAWING - University …innovis.cpsc.ucalgary.ca/innovis/uploads/Courses/GraphDrawing-201… · INTRODUCTION TO GRAPH DRAWING Fall 2010 Battista G D Battista,](https://reader034.fdocuments.net/reader034/viewer/2022051206/5b62cab77f8b9a09498e1572/html5/thumbnails/22.jpg)
ALGORITHM PLANARITY TESTING
4. Test whether I is bipartite. If I is not bipartite p preturn “nonplanar”. O(n2))
5. Return “planar”.
![Page 23: INTRODUCTION TO GRAPH DRAWING - University …innovis.cpsc.ucalgary.ca/innovis/uploads/Courses/GraphDrawing-201… · INTRODUCTION TO GRAPH DRAWING Fall 2010 Battista G D Battista,](https://reader034.fdocuments.net/reader034/viewer/2022051206/5b62cab77f8b9a09498e1572/html5/thumbnails/23.jpg)
OVERALL RUNTIME
Each recursive invocation takes O(n2)( )Each recursion is associated with at least one edge of GThere are O(n) edgesRuntime is O(n3)