On planar path transformation

7
This article was published in an Elsevier journal. The attached copy is furnished to the author for non-commercial research and educational use, including for instruction at the author’s institution, sharing with colleagues and providing to institution administration. Other uses, including reproduction and distribution, or selling or licensing copies, or posting to personal, institutional or third party websites are prohibited. In most cases authors are permitted to post their version of the article (e.g. in Word or Tex form) to their personal website or institutional repository. Authors requiring further information regarding Elsevier’s archiving and manuscript policies are encouraged to visit: http://www.elsevier.com/copyright

Transcript of On planar path transformation

This article was published in an Elsevier journal. The attached copy is furnished to the author for non-commercial research and

educational use, including for instruction at the author’s institution, sharing with colleagues and providing to institution administration.

Other uses, including reproduction and distribution, or selling or

licensing copies, or posting to personal, institutional or third party websites are prohibited.

In most cases authors are permitted to post their version of the

article (e.g. in Word or Tex form) to their personal website or institutional repository. Authors requiring further information

regarding Elsevier’s archiving and manuscript policies are encouraged to visit:

http://www.elsevier.com/copyright

Author's Personal Copy

Information Processing Letters 104 (2007) 59–64

www.elsevier.com/locate/ipl

On planar path transformation

Selim G. Akl, Md. Kamrul Islam ∗, Henk Meijer

School of Computing, Queen’s University Kingston, Ontario, Canada K7L 3N6

Received 11 November 2006

Available online 24 May 2007

Communicated by F. Dehne

Abstract

A flip or edge-replacement is considered as a transformation by which one edge e of a geometric object is removed and an edgef (f �= e) is inserted such that the resulting object belongs to the same class as the original object. Here, we consider Hamiltonianplanar paths as geometric objects. A technique is presented for transforming a given planar path into another one for a set S ofn points in convex position in the plane. Under these conditions, we show that any planar path can be transformed into anotherplanar path by at most 2n − 5 flips. For the case when the points are in general position we provide experimental results regardingtransformability of any planar path into another. We show that for n � 8 points in general position any two paths can be transformedinto each other. For n points in convex position we show that there are n2n−2 directed Hamiltonian planar paths. An algorithm ispresented which uses flips of size 1 and flips of size 2 to generate all such paths with O(n) time between the generation of twosuccessive paths.© 2007 Elsevier B.V. All rights reserved.

Keywords: Flip; Hamiltonian planar path; Directed path; Enumeration; Computational geometry

1. Introduction

The problem of transformations of a certain classof geometric objects consisting of straight line seg-ments and points in the plane by applying small changesor flips (e.g., removing an edge and replacing it withanother) in the object has been studied extensively[12,11,4,8]. Given two objects, two usual questions thatare studied are whether the two objects can be trans-formed to each other and how many transformations arerequired. In this Letter, we study the transformation ofHamiltonian planar paths using flips for a set of pointsin convex position and in general position in the plane

* Corresponding author.E-mail address: [email protected] (M.K. Islam).

0020-0190/$ – see front matter © 2007 Elsevier B.V. All rights reserved.doi:10.1016/j.ipl.2007.05.009

and also determine bounds on the number of transfor-mations needed.

Although flips are studied extensively in triangula-tions, there are a number of other examples in com-putational geometry that illustrate this particular com-putational problem of transformation related to flips.For instance, flips have been used in other classes ofobjects, such as spanning trees, Euclidean matchings[9,10], linked-edge lists, pseudo-triangulations [14], etc.Algorithms for such transformation as well as lower andupper bounds on achieving transformation results canbe found in [8–11]. One of the best-known results in thecase of planar tree transformation is by Avis and Fukuda[4] who showed that for a point set in general positionevery planar tree can be transformed into another planartree by means of at most 2n − 4 flips.

Author's Personal Copy

60 S.G. Akl et al. / Information Processing Letters 104 (2007) 59–64

We show that any planar Hamiltonian path on a setof points in convex position can be transformed into an-other planar Hamiltonian path by at most 2n − 5 flips.This implies that the meta graph, where the vertices arethe planar Hamiltonian paths and two vertices are joinedby an edge if the corresponding paths differ by an edge,is connected. A relevant result by [16] shows that themeta graph is also Hamiltonian. However, the authorsdid not show the number of flips or the bounds in termsof the number of flips required to achieve such transfor-mation from one planar path to other.

Although the planar Hamiltonian path transforma-tion for points in general position has been taken intoconsideration by researchers in this field, apparently nosignificant progress has been found as reported in [5].In [9], the authors consider general simple polygons ona fixed point set for which it is still not known whetherthe class of polygons on the set is connected via aconstant-size local transformation. They show a simplelocal transformation for which the classes of (weakly)edge-visible and (weakly) externally visible polygonsare connected. The latter class is robust as it is the mostgeneral polygon class known to be connected under lo-cal transformation.

In this Letter, for points in general positions, weshow that all planar Hamiltonian paths on a set of atmost 8 points can be transformed into each other bysingle edge flips. That is, the meta graph of planarHamiltonian paths for this small point sets is connected.Based on experimental results even for larger point sets(n � 14) we conjecture that the meta graph for any setof points in general position is connected. As far as weknow, we are the first to provide this result for smallsets of points in general position (as mentioned above inthe paper [5]). We limit our experiments for small pointsets as our experiments are based on exhaustive searchwhich takes a lot of time for larger point sets.

The problem of generating all objects that satisfya specified property has enjoyed some interest amongmathematicians and geometers for many years. Gener-ating such objects is also useful in the field of com-putational geometry, combinatorics and operations re-search. There are a number of techniques to handle theproblem of enumeration of geometric objects [2]. Alsothere are some general-purpose strategies for enumera-tion of combinatorial structures and geometric figures.One such technique is the reverse search scheme due toAvis and Fukuda [4,3] that has been used to enumeratefaces of convex polyhedra [7], spanning trees of graphsand triangulations of a set of points in the plane, allconnected induced subgraphs of a graph, etc. Nice treat-ments of algorithms for enumerating geometric objects

can be found in [4,8]. In [17], an algorithm is describedthat enumerates simple polygons for a fixed point setwhich are monotone with respect to the x-direction.

We show that for a set of n points in convex posi-tion there are n2n−2 planar directed paths. Although thenumber of such paths can be counted using the genericframework of [6] or can be obtained from the asymp-totics mentioned in [13], we use a very simple recursivealgorithm to directly obtain the number. The countingmethods used in [13] exploit the combination of rota-tional and axial symmetry techniques. However, for thefirst time, we introduce a new way of counting basedon flips and demonstrate its simplicity. We also presentan algorithm to generate directed planar Hamiltonianpaths for points in convex position. In enumerating alldirected paths through edge flips, our algorithm requireslinear space and also the time delay between generationof two consecutive paths is linear.

The organization of the remainder of the paper is asfollows. In Section 2 we provide definitions and nota-tions to be followed throughout the paper. Section 3describes the transformation results of planar paths onconvex sets, accompanied by experimental results whenthe points are in general position. In Section 4 we intro-duce a recursive technique to count the number of pathsin convex position, followed by an algorithm for enu-merating directed paths in Section 5. Finally, we sum-marize and conclude with an open problem in Section 6.

2. Preliminaries

Let P denote a set of points in the plane in gen-eral position. Let CH(P ) denote the convex hull of P .Throughout this paper S will denote a set of points inconvex position, so all points in S are extreme pointsof CH(S). The length of a path is defined as the num-ber of edges in the path. Let P(P ) denote the set of allundirected Hamiltonian planar paths on P .

Let Pi (P ,p) denote a set of paths of length i suchthat each path P ′ ∈ Pi (P ,p) can be expanded into apath in P(P ) with an endpoint p. We define the qualityof a path P ∈ P(S) as the number of edges of P thatlie on CH(S). The quality of a path P is denoted byQua(P). A canonical path P is a path in P(S) withQua(P) = n − 1.

A k-flip is defined as the removal of k edges and theaddition of k edges. If P and Q are two paths in P(P )

we say that P can be transformed into Q by a k-flipif there are edges e0, e1, . . . , ek−1 and f0, f1, . . . , fk−1such that Q = P \ {e0, e1, . . . , ek−1} ∪ {f0, f1, . . . ,

fk−1}. We define the meta graph of P as the graph withvertex set P(P ). There is an edge (P,Q) in the meta

Author's Personal Copy

S.G. Akl et al. / Information Processing Letters 104 (2007) 59–64 61

graph if and only if P can be transformed into Q by a1-flip.

3. Transforming Hamiltonian paths on convexpoint sets

We begin with the observation that if any Hamil-tonian path on a convex set of points S has an edge thatdoes not lie on the CH(S), then that edge separates theother points of that path.

Lemma 3.1. Let P ∈ P(S) be the path p0,p1, . . . , pn−1.The edges (p0,p1) and (pn−2,pn−1) lie on CH(S).Moreover, if a path P has an edge (pi,pi+1) with0 < i < n − 2 that does not lie on CH(S), then thesets {p0,p1, . . . , pi−1} and {pi+2,pi+3, . . . , pn−1} lieon different sides of (pi,pi+1).

Proof. The result follows from the fact that since Pis planar and S is a convex set of points, no edgecan connect two points that lie on different side of(pi,pi+1). �

The next lemma shows that the quality of any non-canonical path can be increased by one using a 1-flip.

Lemma 3.2. A path P ∈ P(S) with Qua(P) < n−1 canbe transformed by a 1-flip into a path Q with Qua(Q) =Qua(P) + 1.

Proof. Let P be the path p0,p1, . . . , pn−1. Let i be thesmallest integer such that i > 1 and pi is a neighbor ofp0 on CH(S). If i = n − 1 then from Lemma 3.1 weknow that all edges of P lie on CH(S), i.e., Qua(P) =n − 1. So i < n − 1. Since i > 1 the edge (p0,pi)

is not in P . If the edge (pi−1,pi) lies on CH(S),then the path from p0 to pi contains an edge e noton CH(S). Vertices p0 and pi lie on the same sideof e, contradicting Lemma 3.1. Therefore (pi−1,pi)

does not lie on CH(S). Construct Q by removingedge (pi−1,pi) from and add edge (p0,pi) to P . SoQ = pi−1,pi−2, . . . , p1,p0,pi,pi+1, . . . , pn−1. Since(p0,pi) lies on CH(S) and (pi−1,pi) does not, we haveQua(Q) = Qua(P) + 1. �

We can use the above lemma to show that the metagraph of S is connected and has diameter � 2n − 5.

Lemma 3.3. A path P ∈ P(S) can be transformed intoa path Q ∈P(S) using at most 2n − 5 1-flips.

Proof. From Lemma 3.1 we see that Qua(P) � 2 andQua(Q) � 2. So Lemma 3.2 shows that we can trans-form both P and Q into canonical paths in at most n−3steps each. Since any canonical path can be transformedinto another canonical path by a single flip, the resultfollows. �3.1. Experimental results: Transforming Hamiltonianpaths on points in general position

In this section, we present experimental results thatwill show that two planar paths on any set of n (n �8) points in general position (with no three pointscollinear) can be transformed into each other using1-flips.

We base our analysis on the enumeration of allcombinatorially inequivalent sets of points as describedin [1]. The order type of a set {p0,p1, . . . , pn−1} of n

points in general position is a mapping that assigns toeach ordered triple i, j, k in {0,1, . . . , n − 1} the ori-entation (either clockwise or counterclockwise) of thetriple pi , pj , pk . Two point sets P0 and P1 with n

points each are said to be combinatorially equivalent ifthe points in P0 as well as the points in P1 can be la-beled with the same set of n labels so that they have thesame order types. The discussion of order types and thedatabase of all combinatorially inequivalent point setsfor n � 11 can be found in [1] and [15], respectively.The following lemma states that if P0 and P1 have thesame order type then they have the same meta graph.This because the intersection properties are direct con-sequences of the theory of order types.

Lemma 3.4. Two point sets P0 and P1 with the sameorder types have the same meta graphs.

For each combinatorially distinct set of n points withn � 8 given in [15] we use brute-force to generate allpaths (planar and non-planar). In this experiment wegenerate all Hamiltonian paths consisting of n pointsand then filter out all non-planar paths and compute theset of permutations that correspond to the planar paths.These paths forms the vertex set of the meta graph.We find the edge set of the meta graph by determin-ing which two planar paths can be transformed into eachother by a 1-flip. Finally we determine whether the metagraph is connected. For an illustration, see Fig. 1 whichshows the meta graph of paths of a set of 4 points.

Based on these experiments we can now prove thefollowing lemma.

Author's Personal Copy

62 S.G. Akl et al. / Information Processing Letters 104 (2007) 59–64

Fig. 1. The meta graph of a set of 4 points.

Lemma 3.5. The meta graph for n � 8 points in generalposition is connected.

Proof. We consider all the combinatorially inequiva-lent sets of n points in general position points in theplane with n � 8. Applying our brute-force algorithmfor each of the combinatorially inequivalent point setswe find that all the meta graphs for these point sets areconnected. �

We also create the meta graphs for larger sets ofpoints and in all cases found connected meta graphs.We dare to conjecture that the meta graph for any set ofpoints, even those not in general position, is connected.

4. Counting Hamiltonian paths on convex point sets

In this section we show that the size of P(S) isn2n−3. We start with counting the number of paths

Pi (S,p). Let p0 be a point of S. Let ci be the numberof paths in Pi (S,p0). Clearly the value of ci is indepen-dent of p0. The extremal points in a subset of neighbor-ing points in S are called the first and last points of thesubset. The names refer to the order in which we en-counter these points if we traverse S counter clockwise.

Lemma 4.1. We have of ci = 2i for 0 � i < n − 1 andcn−1 = 2n−2.

Proof. We prove this lemma by induction. Clearly thelemma holds for i = 0. Assume the lemma holds for 0 �i < k with 0 < k � n − 2. We now show that the lemmaholds for i = k. Consider a path P = p0,p1, . . . , pi ∈Pi (S,p0). Recall that P is a subgraph of a planarHamiltonian path with p0 as one of its end points. FromLemma 3.1 we derive that {p0,p1, . . . , pi} are neigh-bors on CH(S). Moreover, the point pi has to be thefirst or the last point of {p0,p1, . . . , pi}.

For the same reason, pi−1 is the first or the last pointof {p0,p1, . . . , pi−1}. So for each path in Pi−1(S,p0)

we can have two paths in Pi (S,p0): one in which pi−1and pi are neighbors on CH(S) and one in which theyare not. This implies that ci = 2 ∗ ci−1. Since c0 = 1we have ci = 2i for 0 < i < n − 1. The final part of thelemma holds since cn−1 = cn−2 = 2n−2. �

For example, Fig. 2 shows all the four paths oflength 2 and starting from p0.

Now we can prove the main theorem:

Theorem 4.2. The number of undirected Hamiltonianpaths on a set of points in convex position is n2n−3.

Proof. From Lemma 4.1 we know that the number ofplanar Hamiltonian paths of S with an end point p0 isequal to 2n−2. Since there n different end points andeach path has two end points, the proof follows. �

Fig. 2. All paths (P2(S,p0)) of length 2 starting at p0 are shown.

Author's Personal Copy

S.G. Akl et al. / Information Processing Letters 104 (2007) 59–64 63

5. Directed path construction algorithm

Let D(S) be the set of all directed planar Hamil-tonian paths on S. We present an algorithm for thegeneration of D(S). A directed path A ∈ D(S) can beassociated with an undirected path A′ ∈ P(S). Let usdefine a k-flip in directed paths. If A,B ∈ D(S) andA′,B ′ ∈ P(S) we say that A is transformed into B by ak-flip if there is a k-flip that transforms A′ into B ′.

Consider a path D = (p0,p1, . . . , pn−1) ∈ D(S).We define an encoding [p0, b1, b2, . . . , bn−2] of D

as follows: The first element is the first point of thepath. The value of bi for 1 � i < n − 1 is 0 or 1 ifpi is the first or last point respectively of the points{pi,pi+1, . . . , pn−1}. For example, the path shown inFig. 3 has encoding [p0,1,1,0,0,1,0].

Since an encoding of a path in D(S) contains onepoint and n − 2 bits, we have |D(S)| = n2n−2, whichalso follows from Theorem 4.2 which deals with undi-rected paths.

Now we will show that beginning from a canoni-cal path with encoding [p0,0,0,0, . . .] we can gener-

Fig. 3. The directed Hamiltonian path with encoding [p0,1,1,

0,0,1,0].

ate all paths that start at p0 using 1-flips and 2-flips.The last path generated has encoding [p0,1,1,1, . . .].After that we can then generate a path with encoding[pi,0,0,0, . . .], where pi is any point different from p0.

Let [p0, b1, b2, . . . , bn−2] denote the most recentlygenerated path. The following three cases define thenext path in the generation:

Case 1: bn−2 = 0. The next path is [p0, b1, b2, . . . ,

bn−3, b′n−2] with b′

n−2 = 1.

Case 2: bk = 0 and bt = 1 for k + 1 � t < n− 1. Thenext path is [p0, b1, b2, . . . , bk−1, b

′k, b

′k+1, . . . , b

′n−2]

with b′t = 1 − bt for k � t < n − 1.

Case 3: bt = 1 for 1 � t < n − 1. The next path is[pi,0,0,0, . . .], where pi is any point in S.

Lemma 5.1. The paths generated in case one, two andthree can be achieved with a 1-flip, a 2-flip and a 1-flip,respectively.

Proof. Let P = (p0,p1, . . . , pn−1) denote a path start-ing at p0. Let Q denote the path that is generated af-ter P . Assume P has encoding [p0, b1, b2, . . . , bn−2].In case one we have bn−2 = 0, so pn−2 is the firstpoint of {pn−2,pn−1}. The path Q with encoding[p0, b1, b2, . . . , bn−3, b

′n−2] is equal to P−(pn−3,pn−2)

+ (pn−3,pn−1). So case 1 requires a 1-flip. In case twowe know that pk is the first point of {pk,pk+1,pk+2, . . . ,

pn−1} and that pt is the last point of {pt ,pt+1,pt+2, . . . ,

pn−1} for k + 1 � t < n − 1. So Q is equal to P −(pk−1,pk)−(pk+1,pk+2)+(pk−1,pk+1)+(pk,pn−1).So case 2 requires a 2-flip. In case three, P traverses thepoints of S in clockwise order around the boundary. Toget Q we add the edge (p0,pn−1) and then remove theedge (pi,pi+1) which is a 1-flip. For an illustration ofall three cases, see Fig. 4. �

Fig. 4. (a) An example of case one with encoding [p0, b1, b2, . . . ,0], (b) case two with encoding [p0, b1, b2, . . . , bk−1, bk, bk+1, . . . , bn−2] withbk = 0 and bt = 1, for k + 1 � t < n − 1, and (c) and case three with encoding [p0,1,1, . . . ,1].

Author's Personal Copy

64 S.G. Akl et al. / Information Processing Letters 104 (2007) 59–64

5.1. Generation method

Let S = {p0,p1, . . . , pn−1}. We start generating thesequence of planar Hamiltonian directed paths with thepath [p0,0,0,0, . . .]. As shown above we can generateall 2n−2 directed paths which begin at p0. After that wecan generate the path with encoding [p1,0,0,0, . . .].This process is continued until we have reached path[pn−1,1,1,1, . . .]. Since given a path we can generatethe next path, it is clear that the algorithm requires O(n)

space. Also the time between the generation of succes-sive paths is O(n).

6. Conclusion and open problem

The problem of transforming planar Hamiltonianpaths for points in general position and points in con-vex position is considered. In the case where the pointsare in convex position it is proved that at most (2n − 5)

edge changes are sufficient for any two planar paths tobe transformed from one to another. The main implica-tion of this result is that the meta graph of P(S) is con-nected and the diameter of the meta graph is boundedby 2n − 5. In addition, experimental results for the caseof a small number of points in general position indicatethat, for all sets with at most 8 points, the correspond-ing meta graphs are connected. A recursive technique isused to show that the number of directed Hamiltonianplanar paths when the points are in convex positionequals n2n−2. An algorithm is also presented that al-lows us to generate uniquely the set of all directed pathsof a set of points in convex position employing flips ofsize one and flips of size two. Finally we conjecture thatthe meta graph is always connected for a set of pointsin general position. Settling this conjecture remains aninteresting and challenging open problem.

References

[1] O. Aichholzer, F. Aurenhammer, H. Krasser, Enumerating or-der types for small point sets with applications, in: Proc. 17thAnnual ACM Symp. Computational Geometry, Medford, MA,USA, 2001, pp. 11–18.

[2] D. Avis, Generating rooted triangulations without repetitions,Algorithmica 16 (1996) 618–632.

[3] D. Avis, K. Fukuda, A pivoting algorithm for convex hulls andvertex enumeration arrangements and polyhedra, Discrete andComputational Geometry 8 (3) (1992) 295–313.

[4] D. Avis, K. Fukuda, Reverse search for enumeration, DiscreteApplied Mathematics 65 (1996) 21–46.

[5] P. Bose, F. Hurtado, Flips in planar graphs, 2006.[6] P. Flajolet, M. Noy, Analytic combinatorics of non-crossing con-

figurations, Discrete Mathematics 204 (1–3) (1999) 203–229.[7] K. Fukuda, V. Rosta, Combinatorial face enumeration in convex

polytopes, Computational Geometry: Theory and Applications 4(1994) 191–198.

[8] C. Hernando, M.E. Houle, F. Hurtado, On local transformationof polygons with visibility properties, Theoretical Computer Sci-ence 289 (2) (2002) 919–937.

[9] C. Hernando, F. Hurtado, A. Marquez, M. Mora, M. Noy, Geo-metric tree graphs on points in convex position, Discrete AppliedMathematics 93 (1999) 51–66.

[10] C. Hernando, F. Hurtado, M. Noy, Graphs of non-crossingmatchings, in: Proceeding of 15th European Conference onComputational Geometry 1999, pp. 97–100.

[11] B. Joe, Construction of three dimensional Delaunay triangula-tions using local transformation, Computer Aided Geometric De-sign 16 (1991) 419–453.

[12] C.L. Lawson, Transforming triangulations, Discrete Mathemat-ics 3 (1972) 365–372.

[13] M. Noy, Enumeration of noncrossing trees on a circle, DiscreteMathematics 180 (1–3) (1998) 301–313.

[14] M. Pocchiola, G. Vegter, Topologically sweeping visibility com-plexes via pseudotriangulations, Discrete and ComputationalGeometry 16 (1996) 419–453.

[15] http://www.igi.TUGraz.at/oaich/triangulations/ordertypes.html.[16] E. Rivera-Campo, V. Urrutia-Galicia, Hamilton cycles in the path

graph of a set of points in convex position, Computational Geom-etry 18 (2) (2001) 65–72.

[17] C. Zhu, G. Sundaram, J. Snoeyink, J.S.B. Mitchell, Generatingrandom polygons with given vertices, Computational Geometry:Theory and Applications 6 (1996) 277–290.