Presentation on theme: "Planar straight line graph A planar straight line graph (PSLG) is a planar embedding of a planar graph G = (V, E) with: 1.each vertex v V mapped to a."— Presentation transcript:
Planar straight line graph A planar straight line graph (PSLG) is a planar embedding of a planar graph G = (V, E) with: 1.each vertex v V mapped to a distinct point in the plane, 2.and each edge e E mapped to a segment between the points for the endpoint vertices of the edge such that no two segments intersect, except at their endpoints. edge (14) vertex (10) face (6) Observe that PSLG is defined by mapping a mathematical object (planar graph) to a geometric object (PSLG). That mapping introduces the notion of coordinates or location, which was not present in the graph (despite its planarity). We will see later that PSLGs will be useful objects. For now we focus on a data structure to represent a PSLG.
Doubly connected edge list (DCEL) The DCEL data structure represents a PSLG. It has one entry for each edge e in the PSLG. Each entry has 6 fields: V1Origin of the edge V2Terminus (destination) of the edge; implies an orientation F1Face to the left of edge, relative to V1V2 orientation F2Face to the right of edge, relative to V1V2 orientation P1Index of entry for first edge encountered after edge V1V2, when proceeding counterclockwise around V1 P2Index of entry for first edge after edge V1V2, when proceeding counterclockwise around V2 v3v3 v1v1 v2v2 v4v4 e3e3 e5e5 e1e1 e4e4 e2e2 f2f2 f3f3 f1f1 f4f4 Example (both PSLG and DCEL are partial)
F1 F2 F3 F4 F5 F6 Edge V1 V2 LeftF RightF PredE NextE F6 F F6 F F6 F F3 F F5 F F5 F F5 F F6 F F1 F F1 F F4 F F4 F F2 F1 2 10
Data structures If the PSLG has N vertices, M edges and F faces then we know N - M +F = 2 by Euler’s formula. DCEL can be described by six arrays: V1[1:M], V2[1:M], LeftF[1:M] Right[1:M], PredE[1:M] and NextE[1:M]. Since both the number of faces and edges are bounded by a linear function of N, we need O(N) storage for all these arrays. Define array HV[1:N] with one entry for each vertex; entry HV[i] denotes the minimum numbered edge that is incident on vertex v i and is the first row or edge index in the DCEL where v i is in V1 or V2 column. Thus for our example in the preceding slide HV=(1,1,2,3,7,5,6,10,4]. Similarly, define array HF[1:F] where F= M-N+2, with one entry for each face; HF[i] is the minimum numbered edge of all the edges that make the face HF[i] and is the first row or edge index in the DCEL where Fi i is in LeftF or RightF column. For our example, HF=(1,2,3,6,5,1). Both HV and HF can be filled in O(N) time each by scanning DCEL.
1procedure EdgesIncident(j) 2begin 3a = HV[j]/* Get first DCEL entry for v j, a is index. */ 4a 0 = a/* Save starting index. */ 5A = a 6i = 2/* i is index for A */ 7if (V1[a] = j) then /* vertex j is the origin */ 8a =PredE[a]/* Go on to next incident edge. */ 9else /* vertex j is the destination vertex of edge a */ 10a =NextE[a]/* Go on to next incident edge. */ 11endif 12while (a a 0 ) do/* Back to starting edge? */ 13A[i] = a 14if (V1[a] = j) then 15a = PredE[a]/* Go on to next incident edge. */ 16else 17a = NextE[a]/* Go on to next incident edge. */ 18endif 19i = i endwhile 21end a NextE[a] PredE[a] V1[a] V2[a] DCEL operations Procedure EdgesIncident use a DCEL to report the edges incident to a vertex vj in a PSLG. The edges incident to vj are given as indexes to the DCEL entries for those edges in array A [1: 3N-6] since M<= 3N-6.
If we make the following changes, it will become a procedure Faceincident[j] giving all the edges that constitute a face: 3: a = HF[j] And sustitute HV by HF and V1 by F1. A will have a size A[1:N]. Both EdgesIncident and Faceincident requires time proportional to the number of incident edges reported. How does that relate to N, the number of vertices in the PSLG? We have these facts about planar graphs (and thus PSLGs): (1)v - e + f = 2Euler’s formula (2)e 3v - 6 (3)f 2/3e (4)f 2v - 4 wherev = number of vertices = N e = number of edges=M f = number of faces=F v O(N) by definition e O(N) by (2) EdgesIncident requires time O(N) and DCEL requires storage O(N), one entry per edge.