Bounds On Some Geometric Transforms - School of Computing

78
Bounds On Some Geometric Transforms by Md. Kamrul Islam A thesis submitted to the School of Computing in conformity with the requirements for the degree of Master of Science Queen’s University Kingston, Ontario, Canada May 2005 Copyright c Md. Kamrul Islam, 2005

Transcript of Bounds On Some Geometric Transforms - School of Computing

by
School of Computing
Queen’s University
Kingston, Ontario, Canada
Abstract
A flip or edge-replacement can be considered as a transformation by which one
edge e of a geometric figure is removed and an edge f (f 6= e) is inserted such
that the resulting figure belongs to the same class as the original figure. This thesis
is concerned with transformation of two kinds of geometric objects, namely, planar
trees and planar paths, through the application of flips. A technique is presented
for transforming a given planar tree into another one for a set of n points in general
position in the plane. It is proved that the number of flips required for such a
transformation is at most 2n − k − s − 2 (k, s ≥ 1). In the case of planar path
transformation we show that any planar path can be transformed into another by
at most 2n − 5 flips for a set of n points in convex position in the plane. Besides,
experimental results are presented that show transformability of any planar path into
another considering n (n ≤ 13) points in general position. Later, we investigate the
possibility of using flips, as an enumeration technique to generate the set P(S) of all
planar paths of a set S of n points in convex position in the plane. First, it is shown
that |P(S)| = n2n−3. Then two algorithms are proposed that describe the ways flips
can be used to generate all the planar paths uniquely. The first algorithm is based on
a recursion technique and uses flips of size one. The second algorithm is non-recursive
and uses flips of size one and flips of size two (two edges are removed and two are
inserted simultaneously) to enumerate all such paths uniquely.
i
Acknowledgements
First of all, I glorify the greatness and bounty of Allah who has bestowed on me
the strength and ability without which it would not have been possible to carry out
the thesis.
I am grateful to my supervisors Dr. Selim G. Akl and Dr. Henk Meijer who
introduced me to the tremendously exciting field of research and guided me to the way
of innovation and novelty. Their invaluable ideas and profound research experience
kept me enthusiastic and optimistic all the way to the completion of this thesis. I
thank them for their many hours of patience for listening to my problems. Their
assistance, comments, constructive criticism and positive attitude helped me proceed
towards completing each step of the thesis.
I would like to acknowledge the support and facilities I received from the staff of
School of Computing and Queen’s University.
I am indebted to my father Late Md. Anowarul Islam for introducing me the
things I did not know and the utmost care I received from him. I pay my sincere
gratitude and profound love to my mother, Mst. Fazilatun Nessa, who put up with
hardships and kept patient to raise us (My brother, me and my sister).
Lastly, I thank my wife Mithila whose understanding, inspiration and constant
support provided me with optimism in different situations.
ii
Contents
1.1.1 Geometric Transformation . . . . . . . . . . . . . . . . . . . . 3
1.1.3 Triangulation Example . . . . . . . . . . . . . . . . . . . . . . 5
1.2.1 The Meta Graph and its Connectedness . . . . . . . . . . . . 7
1.3 Enumeration of Objects . . . . . . . . . . . . . . . . . . . . . . . . . 9
1.4 Contribution of the Thesis . . . . . . . . . . . . . . . . . . . . . . . . 11
1.5 Outline of the Thesis . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2 Literature Review 14
2.3 Edge Slide and Improving Edge Move . . . . . . . . . . . . . . . . . . 16
2.4 Enumeration Techniques . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.1 Graph Essentials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
4 Transformation Results 25
4.1 Tree Transformation . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
4.2 Path Transformation . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
4.2.2 Path Tranformation Strategy . . . . . . . . . . . . . . . . . . 35
4.2.3 Experimental Results for Path Transformation . . . . . . . . . 37
5 Counting and Enumeration 41
5.1 Counting Paths . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
5.2.1 Recursive Generation of All Paths . . . . . . . . . . . . . . . . 50
5.2.2 Space and time complexity . . . . . . . . . . . . . . . . . . . . 52
iv
5.3.3 Mapping Between CP0,1 and CPm,m+1 (CPm+1,m) . . . . . . . 56
5.3.4 Space and time complexity . . . . . . . . . . . . . . . . . . . . 59
5.3.5 Implementation of the algorithm . . . . . . . . . . . . . . . . 60
6 Conclusion 61
1.2 Triangulation X is transformed into Y through flips. . . . . . . . . . 6
1.3 (a) A flip on P can transform it into any of the six paths P1, P2, P3,
P4, P5, P6. (b) The path P ′ produced from P by the flip is not valid
as it is not planar. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3.1 (a) The canonical tree (b) Not a canonical tree . . . . . . . . . . . . . 21
3.2 In (a) v1 can see vertices v3, v4, v5, · · · , v0 and in (b) v2 can see only
v4, v5, v6 and v1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
3.3 (a) Canonical path CP1,2 and (b) not a canonical path. . . . . . . . . 24
4.1 (a) A tree T ′ = (V,E ′) (b) A tree T ′′ = (V,E ′′) (c) Transformations
(shown with thick edges) applied on T ′ to construct T ′′. . . . . . . . . 26
4.2 A tree T of case 1. Only the solid line segments represent the edges of
the tree. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
4.3 A tree T depicting case 3. Only the solid line segments represent the
edges of the tree. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
vi
4.4 Showing the transformation of tree T into canonical tree T ∗ v0
. Thick
edges represent the edges that are flipped. . . . . . . . . . . . . . . . 31
4.5 Showing the transformation of tree T ′ and T ′′ to be transformed into
canonical tree T ∗ v0
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
4.6 (a) Shows a canonical path, CP0,1 with Qua(CPi,i+1) = 7 and (b) shows
an arbitrary path P with Qua(P) = 4. . . . . . . . . . . . . . . . . . 35
4.7 (a) Shows the edge for flip (b) Shows the resultant path after flipping
the edge {vt, vt′}. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
4.8 (a) The meta graph of paths with vertices showing all possible paths
of 4 points defined in the plane. . . . . . . . . . . . . . . . . . . . . . 39
5.1 Showing v` can only be connected to either vj−1 or vj+k+1 to construct
P ′′ from P ′. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
5.2 All paths of length 2 starting at vi are shown in (a) (vivi+1vi+2) (b)
(vivi+1vi−1) (c) (vivi−1vi−2) and (d) (vivi−1vi+1) . . . . . . . . . . . . 43
5.3 Recursive enumeration of all paths from a canonical path CP0,n−1.
Recursion terminates as vertex vn/2 of the leftmost leaf of the tree can
see only one vertex and thus is incapable of producing any path. . . . 49
5.4 Recursive enumeration of all paths from the canonical path CP1,2
(v1v2v3v4v5v0) of 6 vertices. Bold edges represent marks of the cor-
responding paths. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
vii
viii
List of Notations
P set of n points in general position in the plane
S set of n points in convex position in the plane
(vi, vj) an edge connecting vertices vi and vj
CPi,i+1 canonical path begins with edge (i, i + 1)
T (P ) set of all planar trees of P
TG(P ) graph with T (P ) as vertex set
V i k set of k + 1 consecutive vertices {vi, vi+1, vi+2, · · · , vi+k}
N(vj) the set of vertices which are adjacent to vertex vj
P i k a set of paths of length k beginning at vi and using V j
k
pi k number of directed paths of length k starting at vi and using V j
k
P(S) set of all planar trees of S
Pj(vi) any path where j is the number of vertices visible to vertex vi
Nj(vi) the number of child paths produced by Pj(vi)
Qua(P i n−1) quality of a path P i
n−1
Introduction
Geometric elements such as points, line segments and polygons are the basis of a
broad variety of different applications and give rise to an interesting set of well-
defined problems and algorithms. One such geometric problem asks whether any
geometric object or figure consisting of those geometric elements (such as straight line
segments and fixed point-set in the plane) can be transformed into another object
of the same type by applying small changes (e.g. removing an edge and replacing
with another) in the object. If this question gives a positive answer then we would
like to determine the minimum (maximum) number of such small changes. The
constraint associated with such problem is that if there is a finite number of changes
needed, then all the intermediate objects will be in the same class as the original one.
Another interesting issue regarding transformation may be posed, namely, whether
it is possible to generate the set of all objects uniquely with small changes in the
objects. The process of generating the objects is called enumeration. In this thesis,
1
we study the transformation of certain geometric objects and determine the bounds
on those transformations.
There are a number of examples that illustrate this particular computational prob-
lem of transformation and enumeration. For instance, problems related to transforma-
tion and enumeration of geometric objects such as triangulations, tetrahedrons, span-
ning trees, crossing free paths, linked-edge lists, pseudo-triangulations and meshes
are studied in the literature of computational geometry. Some of these algorithms,
techniques and their lower and upper bounds to achieve those transformations and
enumerations can be found in [3] [5] [29] [35] [36]. A majority of research activity in
computational geometry is devoted to the design and analysis of algorithms and data
structures, in an effort to find the fastest possible solutions to those problems.
1.1 Defining the Problem
As mentioned earlier, this thesis deals with the geometric problems that involve trans-
formation of a given object defined on a set of points in the plane. The aim of the
thesis is to describe techniques and bounds on the complexity of transforming geo-
metric objects consisting of points and straight line segments. The problem can be
generally defined as follows: Let X be a given geometric figure of a class with some
property M, and let Y be another object of the same class satisfying M. We consider
objects or figures that can be described in terms of vertices and straight line segments
in the plane. It is intended to construct the figure Y by applying a sequence of small
2
changes or transformations to X.
The main criterion is that when changes are applied on the figure X, each resulting
object towards achieving Y from X, must posses the same property, M. The first
question is: Is it at all possible to achieve Y from X? Once the problem is solved as
far as transformation is concerned then we figure out how many steps are required
to do so and if not then what the lower and upper bounds on the number of such
transformations are. One of the aims of this thesis is to answer these questions
on particular geometric objects, namely planar trees and planar paths. We assume
throughout that all problems are defined in the two-dimensional plane.
In the remainder of this section follows in this section, we shed light on what we
mean by a local transformation in general. Subsequently we define and illustrate the
flip operation as a local transformation which is one of the basic operations applied on
geometric objects to produce other objects. Finally we present a particular example
that will help one understand the transformation of geometric figures.
1.1.1 Geometric Transformation
In general, a geometric transformation can be defined as an operation in which new
objects of the class are generated only from previously-examined objects by means
of small changes. This transformation is performed on the vertices and the edges of
a graph. As a new object is produced due to a single transformation of an object,
the new object constitutes the neighbourhood of the original object. This simple
transformation is performed successively on every newly produced object without
3
any duplication of any objects. Thus we form a class of valid objects having similar
characteristics.
We are concerned with the connectedness of all the objects of that class with
respect to the transformation in question, that is, whether every valid object must
be reachable from some initial valid object by means of a finite sequence of transfor-
mations. Local search (that searches only within the neighbourhood of the current
object) and optimization methods such as reverse search enumeration, and random
walks all make use of transformation to visit new objects of the class.
1.1.2 Flip as Geometric Transformation
The standard edge flip in a planar graph G, also called the Lawson flip [7], takes
two triangles 4abc and 4abd, whose union is a convex quadrilateral. By a flip we
exchange the diagonals e and f of this quadrilateral and obtain a new graph G′ as
shown in Fig. 1.1.
4
We say that G′ has been obtained from G by a diagonal transformation or a
diagonal flip. Observe that one can flip only {a,b} if adbc is a convex quadrilateral.
In this case it can be stated that the edge {a,b} is flippable.
Armed with the knowledge of the transformation flip, we can now look forward
to considering the following example involving transformation of a geometric figure
called a triangulation.
1.1.3 Triangulation Example
A triangulation is a an embedded planar graph all of whose faces (except the outer
face) are triangles [30]. A set of points in the plane can be triangulated by connect-
ing pairs of points with straight line-segments until no edges can be added without
making an intersection with existing edges. Similarly the interior of a polygon can
be triangulated by connecting its vertices with diagonals such that each diagonal lies
entirely inside the polygon until no diagonal can be added without intersecting the
existing diagonals.
Let X and Y be two triangulations with the same set of n vertices for n = 7
in the plane. It is required to obtain Y from X by applying a sequence of local
transformations such that every resulting object still is a triangulation. Here we
use flip as the local transformation of triangulations, which is defined earlier as the
removal of one edge and the insertion of a new edge such that all the intermediate
figures belong to the same class of the original figure. Fig 1.2 gives an example.
The questions associated with such transformations deal with whether it is always
5
YX
Fig. 1.2: Triangulation X is transformed into Y through flips.
possible to transform one object to another and if so then what is the number of such
transformations. Both questions are settled with an affirmative answer and a lower
bound is found to be (n2) [36] where n is the number of points in the plane.
1.2 Flips in Trees and Paths
In this thesis, we restrict ourselves only to the transformations of planar (sometimes
referred as non-crossing or crossing-free) trees and planar paths. A planar tree is an
embedded connected acyclic (containing no cycle) graph where the edges (straight
line-segments) do not pairwise cross. Similarly a crossing-free or planar path is an
embedded connected graph such that no two edges cross and every vertex has degree
6
at most two.
The standard definition of a flip has been extended (flipping of edges is not re-
stricted to only the diagonals of a quadrilateral) to general graphs such as planar trees
and planar paths where a flip means the operation of removing an edge e ∈ G and
replacing it with another new edge f such that a new planar graph G′ = G\{e}∪{f}
is formed. Here G and G′ represent either planar trees or planar paths. See Fig 1.3(a)
where a flip on the path P can transform it into any of the six paths P1, P2, P3, P4,
P5, P6 as shown. But in Fig 1.3(b) the path P ′ produced from P by the flip is not
valid as it is not planar.
A sequence of flips replaces a given set of edges with another set of the same
cardinality. This operation (flip) can be used for the purposes of enumeration, random
generation of geometric objects such as trees and paths (as we will see later) and for
proving fundamental combinatorial properties of some objects of a certain class.
1.2.1 The Meta Graph and its Connectedness
One can then define a mathematical model in terms of transformations for all the
objects of a class of whether any two geometric objects of a certain class (satisfying
some property) are reachable from one to another via a finite sequence of flips. Here
we define a graph, called the meta graph (also called super graph), that serves as the
mathematical model to describe the relationships among the objects of that graph.
The meta graph can be defined as the graph having the set of objects in the class as
its vertex set, and a pair of vertices is connected by an edge if the objects represented
7
(a)
(b)
P
P
P4
P ′
P5
Fig. 1.3: (a) A flip on P can transform it into any of the six paths P1, P2, P3, P4, P5, P6. (b) The path P ′
produced from P by the flip is not valid as it is not planar.
by the vertices differ by a small change. In this way, one can develop adjacencies
among nodes of the meta graph.
For a set of points in the plane in general position, the order of the meta graph
is quite large. For example, the number of crossing-free trees is (10.42n) [25], the
number of labelled non-crossing paths of n points in convex position in the plane is
n2n−3 (as will be shown later), and so on.
In most of the cases, generating, examining and establishing relationships among
all the objects is not feasible due to the amount of time needed to construct a graph
8
containing such a huge number of vertices. There is a way that makes it possible to
establish polynomial-size descriptions among the objects even though the size of the
graph is exponential in most of the cases. The procedure of incorporating local mod-
ifications on some initial object to visit new objects allows us to study the essential
characteristics such as connectedness, reachability, diameter of the graph and so on.
The existence of a path between two vertices in the graph means transformability
of the corresponding trees or paths represented by the vertices into one another by
means of repeated application of the local transformations. The length of the shortest
path between two vertices corresponds to the distance between the two trees or paths
in terms of the number of operations. Furthermore, analysis of such graph helps us
develop suitable expressions to represent the relationship among the objects that arise
from the issue of carrying out transformations.
In this thesis, we show that small changes in geometric figures of some class can
be one of the means to enumerate all such figures (having same property) of the class.
Besides, we aim to determine the bounds on the number of such transforms of planar
trees and paths.
1.3 Enumeration of Objects
Enumeration entails the use of algorithms for generating all the combinatorial or
geometric objects of a certain set without duplicates. The problem of efficiently
generating the set of objects has theoretical interest and also is a fundamental problem
9
in combinatorics, computational geometry and operations research. For example,
generation of all graphs for a class may arise in constructing test data for certain
programs. As this thesis is concerned with object transformations, we intend to
extend this capacity to deal with enumeration of all geometric objects of a certain
class. The techniques of generating or enumerating all planar paths are provided.
In order to find out efficient solutions regarding combinatorial objects for the pur-
pose of classification and enumeration, numerous techniques have been investigated
by mathematicians and geometers. One of the earliest object classes to be studied by
the ancients is likely the Platonic solids [16], for example, a polyhedron all of whose
faces are congruent regular polygons. Along with theoretical solutions and proof of
enumeration techniques, computers have also been employed to obtain experimental
results that investigate the structures of objects far more complex than those consid-
ered by the ancients and help provide certain proofs. For example, in graph theory,
the only proofs yet known of the famous Four Colour Theorem have been obtained
by means of computer enumeration of cases [1][2].
Since the size of the meta graph (as described above) is quite large, it takes a
lot of time to enumerate all objects represented by the vertices of the meta graph.
Nonetheless, for the sake of determining connectedness of the meta graph whose ver-
tices represent planar paths, when the vertices are in general position (no three points
are collinear), we apply a brute-force enumeration algorithm and take advantage of
the computer to enumerate all such paths of n vertices for n ≤ 13 when the vertices
are in general position in the plane. Later, two theoretical proofs are given for the
10
enumeration of all planar paths of n vertices assuming that the vertices are in convex
position.
1.4 Contribution of the Thesis
As we deal with transformation of geometric objects, we determine the minimum and
maximum number of flips required for such transformation which are called the lower
and upper bounds of transformation. The problem of finding bounds of transformation
of crossing-free spanning trees and planar paths is addressed and some algorithms
are suggested. Besides, some results are given by studying the combinatorial and
enumerative property namely, the counting of the total number of objects of a certain
class, generating them all, finding relationship between any two successively generated
objects, and so on. Following are the contributions of this thesis:
1. It is shown that at most 2n− 5 flips are required to transform any crossing-free
path into another when the point set is in convex position.
2. The number of crossing-free paths in convex position is shown to be n2n−3. Two
enumeration algorithms (one recursive and another non-recursive) are designed
for generating all such paths.
3. The non-recursive enumeration algorithm for generating paths in convex posi-
tion is implemented. Although the time complexity is exponential, the space
complexity is linear.
11
4. An algorithm is presented for the problem of planar tree transformation and it
is shown that a linear number of flips suffice to transform any planar tree into
another planar tree considering points in general position in the plane. More
specifically, we improve the upper bound on the number of transformations from
2n− 4 [3] to 2n− k − s− 2 where both k and s are larger than or equal to 1.
5. Experimental results concerning transformation of crossing-free paths are pre-
sented for at most n = 13 points in general position in plane. It is shown that
any two paths are reachable from one another which implies that the corre-
sponding meta graph is connected.
1.5 Outline of the Thesis
The rest of the thesis is organized as follows. Chapter 2 provides a brief literature
survey on flips that act as the basis of transforming triangulations and general graphs
and sheds light on some of its applications. In chapter 3 some basic definitions and
terminologies necessary for understanding the thesis are provided. In chapter 4, a
number of lemmas and proofs are provided regarding planar trees and crossing-free
paths transformation. Experimental results demonstrating the connectedness of the
meta graph containing vertices representing non-crossing planar paths are presented
in this chapter. In chapter 5, a simple recursive technique for counting the total
number of planar paths is given. Two algorithms are discussed for enumeration of
all convex planar paths uniquely. The first one is recursive, where it is shown that
12
flipping can be used to generate all planar paths without duplicates. We then present
a non-recursive algorithm that takes only O(n) space to enumerate all such paths.
Chapter 6 provides a summary of the results and concludes with an open problem.
13
2.1 Flips and Triangulations
The idea of flipping in planar tree and path transformations stems from the edge-
flipping operations used in triangulations, a structure which has great importance
in computational geometry. Flipping can be used in generating different types of
triangulations in two and three dimensions [36][35], enumerating rooted plane trian-
gulation [12] and also in building visibility graphs of a set of objects in the plane [34].
Flipping of edges as a simple tool of changing certain geometric objects, has received
some attention during recent years. Flipping has found its applications in many im-
portant areas such as finite element analysis, solid modeling, shape representation,
terrain modeling, volume rendering and computer vision [17][18][19].
Flips have been used in various fields starting with a simple greedy algorithm
that constructs the Delaunay triangulation of a point set by successive flips from an
14
arbitrary initial triangulation of the point set [8]. The results of [12] provide some
efficient ways of enumeration and a number of algorithms for the generation of all
tri-connected rooted plane triangulation defined with n vertices. The latter are of
particular importance as they are based on the reverse search method that does not
store all the lists of graphs while they are generated successively.
2.2 Flips in Trees
Apart from the literature regarding flips and their influence on triangulations, a con-
siderable amount of similar study has been also conducted for general graphs. The
meta graph of trees (as discussed in chapter 1) was introduced in [24], in connection
with the study of electrical networks. An characteristic of the meta graph, specifi-
cally that the graph of trees is Hamiltonian is proved in [24]. A simpler proof of the
same fact was found later [21] and generalized to the base graph of a matroid. A
base graph of a matroid is the graph whose points are the bases of the matroid. Two
bases are adjacent if they differ by exactly one element. Graph-theoretical versions of
the problem of geometric object transformations have been largely studied in [22] for
tree graphs and was shown that tree graphs have maximum connectivity (a directed
graph is said to be maximally connected if it is k-connected and k is the minimum in
or out degree of all vertices). Another excellent discussion of combinatorial version
for graphs more general than trees is studied in [23]. They exclusively treat the case
where the allowed operation is called edge-move, which relates two trees in the meta
15
graph of trees if they have all but one edge in common.
Motivated by the question of enumerating the set of all non-crossing spanning trees
for a point set in general position, Avis and Fukuda [3] showed that the corresponding
tree graph is connected and has a diameter bounded by 2n − 4. To the best of our
knowledge this is the only known result for a general point set. In this thesis, we
present an improved bound of 2n − k − s − 2 (where k, s ≥ 1) which in some cases
produces a better result.
The special case when the point set is in convex position has been treated by
Hernando et al. [26]. They showed that the tree graph has maximum connectivity
and is Hamiltonian in this case. A lower bound of b3n/2c − 5 on its diameter is
established there and it is shown that the number of crossing-free spanning trees is
minimum for the convex case. A different flavour on crossing-free geometric spanning
trees and related results can be found in [27].
2.3 Edge Slide and Improving Edge Move
Recently, two operations slightly different from but related to flips have gained at-
tention in connection with transformations; they are called edge-slide and improving
edge-move [28]. A planar edge-slide is like a constant-size local edge move that keeps
one endpoint of the moved edge fixed and moves the other one along an adjacent
tree edge without generating any edge crossings. An improving edge-move is same as
the edge move or flip, the only difference being that it (move) reduces the total tree
16
length. The length of a tree is the sum of lengths of all the edges of the tree.
As found in [28], the number of length-improving and planar edge-moves needed to
transform a tree T ∈ Ts into MST (S), (Minimum Spanning Tree) of S where Ts is the
set of all crossing-free spanning trees of S, is O(n log n). Edge slide operations could
also prove useful in enumerating all simple polygons on a point set S via constant-size
local transformations but this is still unsettled as reported in [26].
2.4 Enumeration Techniques
There are techniques available for enumeration of typical objects such as generation
of all rooted trees [12], triangulations of a set of points in the plane [37], non-crossing
paths in a connected graph in a two-dimensional Euclidean plane, all connected in-
duced subgraphs of a graph, all topological orderings of an acyclic graph, vertices and
faces of a polyhedron etc [3]. As described in [11], one of the particular applications
of enumerating all graphs having some property includes unbiased statistical analysis.
Davis and Fukuda [14] provide a nice treatment regarding algorithms developed for
counting and generating these objects. As enumeration techniques are in place, the
necessity of searching a particular object also demands attention. Among the number
of searching techniques backtracking is known to be useful for various enumeration
problems associated with graphs [20]. For enumeration problems in computational
geometry the incremental search technique is used [13]. On the other hand two most
typical search techniques in graphs namely, depth first search and breadth first search
17
can be applied to the case where the objects to be listed or counted are the vertices
of some connected graph.
The experimental results presented in this thesis for finding transformability of
planar paths use flips to sequentially traverse all the planar paths of a point set in
general position. That is, we first generate all the planar paths of the point set.
Then to answer the question as to whether any two planar paths P1 and P2 can
be reached from one another by means of flips, the algorithm begins from P1 and
uses a flip to reach its neighbour which in turn reaches to its neighbour and so on
until P2 is reached. This can be called local search as the search is limited only
to the neighbours of a path represented by a vertex of the meta graph. There are
local search techniques discussed in the literature [8][9] of enumeration and searching
algorithms. For example, edge-exchange algorithms for finding a particular object
with some property in some weighted graph and flip algorithm for finding a Delaunay
triangulation in the plane are studied in [8][9][10][13].
18
Preliminaries and Definitions
A number of definitions are provided in this section. These definitions and notations
will be used throughout the rest of the thesis. In order to follow our discussion, the
following are some basic definitions and concepts given without proof. Some of them
are adopted from [31][32][33].
3.1 Graph Essentials
Graph: A graph G = (V, E) consists of V , a nonempty set of vertices, and E, a set
of edges between the vertices, E = {(vi, vj)|vi, vj ∈ V }. If G is drawn in the plane,
an edge (vi, vj) is represented by a straight line-segment joining two vertices vi and
vj. The cardinalities of V and E are denoted by |V | and |E| respectively. A path
from vi to vj is a sequence of edges where the terminal vertex of an edge is the same
as the initial vertex in the next edge in the path. A cycle in G is a path of length
19
(n ≥ 3) that begins and ends at the same vertex. A graph is called acyclic if it
contains no cycles. A graph is called connected if for every pair vi, vj of distinct
vertices there is a path from vi to vj. A graph G is called planar if it can be drawn
in the plane so that no two edges intersect, except at a common vertex. We also call
such a drawing an embedding of graph G. Throughout the rest of the thesis a graph
G drawn in the plane is assumed to be a planar embedding unless otherwise stated.
If (vi, vj) ∈ E, then vi and vj are adjacent or neighbours, and the edge (vi, vj) is
said to be incident to vi and vj. We define N(vj) to denote the set of vertices which
are adjacent to vertex vj. The degree of a vertex vi is the total number of edges
incident to it. It is denoted by deg(vi). A flip in G is the operation of removing an
edge from G and adding an edge to G. If k (k ≥ 1) edges are removed from, and k
are added to, G then we call this operation a flip of size k.
3.2 Terminologies used for Trees
In the following definitions, assume P = {v0, v1, v2, · · · , vn−1} is a set of n points in
general position (recall that general position means no three points are collinear) in
the two-dimensional Euclidean plane. We assume that trees are drawn in the plane.
Vertices (V ) and edges (E) of a tree are represented by points of P and straight
line-segments.
Planar tree: A planar tree T = (V, E) is a connected acyclic planar graph.
Rooted tree: A rooted tree is a planar tree in which one vertex is designated
20
as the root of the tree.
In this thesis, it is considered that the root of a tree T = (V, E) is the vertex with
minimal x−coordinate. The vertex with smallest y−coordinate will be designated as
the root if there are two or more candidates for the root. The root of any tree, T will
be represented by v0.
is a rooted tree where all vertices are
adjacent to v0, that is, in T ∗ v0
, vi ∈ N(v0), ∀i, i 6= 0. Fig. 3.1 shows the canonical tree
and a tree which is not canonical.
(a) (b)
v0
v0
Fig. 3.1: (a) The canonical tree (b) Not a canonical tree
Visibility of vertices: Two vertices vi and vj, vi 6= vj in an embedding of G are
visible to each other if the straight line segment (vi, vj) ∈ E between them does not
intersect any of the edges in G.
It is assumed that vi is not visible to vj if vi ∈ N(vj). If vi and vj are not visible
then they are blocked by some edge in G. This is illustrated in Fig. 3.2.
Let T (P ) denote the set of all trees of P and the geometric tree graph TG(P )
21
denote the graph having T (P ) as vertex set. Two trees T1, T2 ∈ T (P ) are adjacent if
T2 = T1\{e} ∪ {f} for some edges e and f .
(a) (b)
v4
v7
v6
v5
v0
v3
v4
v1
v2
v7
v6
v5
v0
v3
v2
v1
Fig. 3.2: In (a) v1 can see vertices v3, v4, v5, · · · , v0 and in (b) v2 can see only v4, v5, v6 and v1
In the rest of the thesis, it is assumed that a tree is planar unless otherwise
mentioned.
Flip in a tree: A flip in a tree T1 is the operation of removal an edge e and
addition of a edge f so that T2 = T1\{e} ∪ {f} is a tree.
3.3 Terminologies used for Paths
In the following definitions, assume a point set S = {v0, v1, v2, · · · , vn−1} is a set of
n points in convex position in the two-dimensional Euclidean plane. Assume that
no two points of S have the same y − coordinates otherwise we rotate the points
accordingly.
Denote the vertex with the lowest y − coordinate in S as v0 and label the rest
of the vertices v1, v2, · · · , vn−2, vn−1 counter clock-wise from v0. Arithmetic on the
22
indices of vertices of paths will be defined modulo n. In the rest of the thesis, it
is assumed that all paths are drawn in the plane whose vertices (V ) and edges (E)
are represented by points of S (unless a different point-set is specified) and straight
line-segments.
Consecutive group of vertices: A set of k+1 vertices, vi, vi+1, vi+2, · · · , vi+k−1, vi+k
is called a consecutive group of vertices and denoted by V i k .
Let P(S) denote the set of all planar paths on S. Henceforth, whenever we mention
a path we mean it is a planar path.
Let P i k denote any path of k edges beginning at vi and using all vertices of V j
k
for some j such that vi ∈ V j k . Note that a path P i
k is a Hamiltonian planar path if
k = n− 1.
Also, let pi k define the number of directed paths of length k starting at vi and
connecting vertices of V j k for some j such that vi ∈ V j
k .
End-edge of a path: The edge (vi, vj) of a path P ∈ P(S) is called an end-edge
of P if vi or vj has degree one.
Canonical path: A directed path (vivi+1vi+2 · · · vi−2vi−1) (resp. (vivi−1vi−2 · · · vi+2vi+1))
in P i n−1 is called a canonical path and denoted by CPi,i+1 (resp. CPi,i−1).
The two end-edges of CPi,i+1 are (vi, vi+1) and (vi−2, vi−1). The path CPi,i+1 can
also be represented as CPi−1,i−2.
Fig. 3.3 shows an example of a canonical path and a path that is not canonical.
Furthest (Nearest) Visible Vertices: A vertex vj is called furthest (nearest)
visible vertex from vi with respect to a path P ∈ P(S) if vj is visible to vi and the
23
v2
Fig. 3.3: (a) Canonical path CP1,2 and (b) not a canonical path.
number of edges walking along the path from vi to vj is maximum (minimum).
It is clear from the context that Furthest (Nearest) visible vertices will always be
considered with respect to a path P whether mentioned or not.
Flip in a path: A flip in a path P1 is the operation of removal of an edge e and
addition of a edge f so that P2 = P1\{e} ∪ {f} is a path.
Path generation: A path Qj k is called generated from P i
k if a flip transforms
P i k into Qj
k.
We say that path Qj k is generated from P i
k by a single flip.
Quality of a path: The quality of a path P i n−1 is defined to be the number of
edges on the boundary of the convex hull of S and is denoted by Qua(P i n−1).
It can be verified that Qua(P i n−1) ≥ 2.
24
Chapter 4
Transformation Results
In this chapter, we discuss flipping operations for transformation of spanning trees
and paths . The focus is mainly centered on finding the bounds on the number of flips
required to transform trees and paths. In sections 4.1 and 4.2 we provide the technique
and find the bound in terms of the number of flips used in such transformation.
In section 4.3, our path transformation strategy is explained along with the bound
needed to achieve the transformation.
4.1 Tree Transformation
Let T ′ = (V,E ′) and T ′′ = (V, E ′′) be any two trees belonging to T (P ) (recall that
T (P ) denote the set of all trees of point set P ). It is required to construct T ′′ by
applying a sequence of flips one by one to T ′. The number of flips required for such
construction is known to be at most 2n − 4 [3]. In general we say that T ′′ can be
25
transformed from T ′ by p flips if there is a set of trees T0, T1, · · · , Tp where T ′ = T0
and T ′′ = Tp such that Tt+1 can be obtained from Tt by a single flip. This implies
that for any t, Tt and Tt+1 are adjacent in TG(P ).
Consider the Fig. 4.1 where the tree T ′′ is obtained from T ′ by a sequence of
transformation.
(c)
T ′
T ′′
Fig. 4.1: (a) A tree T ′ = (V, E′) (b) A tree T ′′ = (V, E′′) (c) Transformations (shown with thick edges) applied
on T ′ to construct T ′′.
In this thesis, we try to improve the upper bound (2n−4). In the following section
it is proved that two trees T ′, T ′′ ∈ T (P ) can be transformed to each other with at
most 2n− k− s− 2 flips, where k > 0 and s > 0 are the number of neighbours of the
roots of T ′ and T ′′ respectively.
Instead of proving directly that a tree can be transformed into another tree the
26
strategy is to show that it is always possible to transform the given tree into a unique
canonical tree. One can then perform the reverse operations that transform the target
tree into the same canonical tree.
4.1.1 Transformation via Canonical Tree
The following lemma provides a useful direction towards proving the main result:
Lemma 4.1.1 At least one vertex of T ∈ T (P ) and T 6= T ∗ v0
is visible to the root, v0
of T .
Proof Since the tree T = (V,E) is not in its canonical form, ∃i such that vi 6∈ N(v0).
Let N1 and N2 be the set of neighbours of v0 such that deg(vp) = 1 for vp ∈ N1 and
deg(vq) > 1 for vq ∈ N2 with 0 < p, q ≤ n− 1. According to the definition, v0 can see
neither the vertices of N1 nor those of N2.
Let `1 be a line segment connecting v0 to any of the vertices vr 6∈ N(v0). Denote
by 6 `1 the angle made by `1 with v0 along the vertical line that goes up through v0.
If `1 does not cross any edge of E, this means vr is visible to v0 and the proof is done.
So we may assume that `1 crosses some edges of T . Denote the set of intersected
edges Eint1 .
Select the edge e1 ∈ Eint1 whose intersection with `1 is nearest to v0.
Now at least one of the vertices of e1 = (v1, v2) must not be a neighbour of v0,
otherwise if both of them are neighbours of v0 then it is a loop. Assume v1,v2 6∈ N(v0).
In this case we can arbitrarily choose v1 or v2 to connect to v0. If one of them is a
27
neighbour then we select the other vertex which is not a neighbour of v0 and connect
it to v0. Let `2 denote a line segment joining v0 to one of the vertices v1 or v2 . Now
check whether the edge `2 crosses any edges of T . If there is no crossing then the other
vertex on `2 is visible to v0. If this is not the case, i.e., |Eint2| > 0, then choose the
closest intersected edge e2 from Eint2 from the root and follow the above procedure of
connecting v0 to the vertex of e2 which is not neighbour of v0. Repeatedly applying
the procedure described above gives rise to the following cases:
Case 1: Case 1 deals with the situation where 6 `1 < 6 `2 < 6 `3 · · · < 6 `a (here
a ≤ n − 2). Since there is a finite number of vertices in the graph, by following the
above procedure we can reach to a vertex vs where the edge `a (one end vertex is vs
and the other one is v0) will not cross any edges. This ensures us that in the worst
case (a = n− 2) the line segment `a makes the largest angle joining the vertex vs to
v0. Then vs is the vertex visible to v0. This is illustrated in Fig. 4.2.
Case 2: Case 2 is the reverse of case 1 ( 6 `1 > 6 `2 > 6 `3 · · · > 6 `a) and can be
similarly resolved.
Case 3: In Case 3 we consider the following:
There exists some i such that (i) 6 `i < 6 `i+1 > 6 `i+2 or (ii) 6 `i > 6 `i+1 < 6 `i+2
Without loss of generality consider (i) 6 `i < 6 `i+1 > 6 `i+2. Now the line segment
`i+2 must lie between `i+1 and `i and ei. Let vi and vi+1 be the end vertices of the
line segments `i and `i+1 respectively. Any `j (for j > i + 2) must lie in triangle
formed by the line segments `i,`i+1 and ei because at each step we are taking the
closest intersected edges to v0. Also this implies that at every iteration the number
28
with the vertical line This line makes the largest angle
(counterclockwise)
vs is visible to v0
Fig. 4.2: A tree T of case 1. Only the solid line segments represent the edges of the tree.
of vertices to be considered for visibility to v0 are reduced (only those vertices inside
the triangles) as the area of successive triangles are decreased gradually. Since the
number of vertices are finite and the number is becoming smaller and smaller at each
step, we must end up with a single vertex vs inside the smallest of such triangles (in
the worst case) that will be visible to v0. Fig. 4.3. shows such a scenario.
Lemma 4.1.2 Any tree T ∈ T (P ) and T 6= T ∗ v0
can be transformed into its canonical
form T ∗ v0
through flipping of edges at most (n− k − 1) steps, where k = |N(v0)|.
Proof Begin with any vertex visible to v0 (according to Lemma 4.1.1 at least one
vertex of T will be visible to the root). Assume v0 can see vj. Since adding a line
segment (v0, vj) makes a unique cycle v0 · · · vivjv0 in T , break the cycle by eliminating
the edge (vi, vj). This flip increases the degree of v0 by one. Then continue the same
29
axis
v0
li+1
li+2
vs ei
Fig. 4.3: A tree T depicting case 3. Only the solid line segments represent the edges of the tree.
process with another vertex visible to v0 until ∀vi ∈ N(v0) and vi 6= v0. An illustration
is Fig. 4.4 shows the transformation of T into canonical tree T ∗ v0
through successive
flips.
Since for any tree there can be n− 1− k edges possible which are not incident to
v0, the total number of flips required to produce T ∗ v0
is n− 1− k.
Example Given the tree in Fig. 4.4 with n = 10 and k = 1 note that the number of
flips to obtain T ∗ v0
from the initial tree T is n− k − 1 = 10− 1− 1 = 8.
We will prove one of the main results of this thesis, i.e., two trees T ′, T ′′ ∈ T (P )
can be transformed into one another with only a linear number of flips. Instead of
directly proving that a tree can be transformed into another tree our strategy is that
we transform T ′ into the unique canonical tree T ∗ v0
. And then we can reverse the
operations that transform T ′′ into T ∗ v0
. This is shown in the following lemma:
30
T ∗ v0
Fig. 4.4: Showing the transformation of tree T into canonical tree T ∗v0 . Thick edges represent the edges that
are flipped.
Lemma 4.1.3 Two trees T ′, T ′′ ∈ T (P ) can be transformed to each other with at
most 2n− k − s− 2 flips where k ≥ 1 and s ≥ 1 are the number of neighbours of the
roots of T ′ and T ′′ respectively.
Proof Given the tree T ′, one can transform it into canonical tree T ∗ v0
using Lemma
4.1.2 with at most n−k−1 steps where k is the number of neighbours of v0. Similarly,
the tree T ′′ can be transformed into canonical tree T ∗ v0
with at most n − s − 1 flips
where s is the number of neighbours of T ′′. Since the canonical trees for T ′ and T ′′
are same, it takes 2n − k − s − 2 flips to transform T ′ into T ′′. This completes the
proof.
31
The following corollary follows from the above lemma.
Corollary 4.1.4 The number of flips required to transform a tree T ′ into another
tree T ′′, where T ′, T ′′ ∈ T (P ) is 2n− p− 2 where p = maxv∈CH(V )(degree v in T ′ +
degree v in T ′′).
Suppose that T ′ and T ′′ are two trees with n = 7 as shown in Fig. 4.5. The
neighbours of the roots of T ′ and T ′′ are 3 and 2 (hence k = 3 and s = 2) respectively.
It takes 3 flips for T ′ to be modified to T ∗ v0
and 4 flips for T ′′ to be transformed to
T ∗ v0
. Hence we need 2n− k − s− 2 = 14− 3− 2− 2 = 7 flips to transform T ′ to T ′′.
The above result can be expressed in terms of the meta graph TG(P ) whose vertices
are the non-crossing set of trees, T (P ). Two vertices of the meta graph are adjacent
if the trees represented by them can be obtained from the other by a single edge
replacement. According to the proof of the above lemma, we can derive that TG(P )
is connected and the diameter of TG(P ) which is the shortest distance between any
two furthest vertices, can be at most 2n − k − s − 2. As mentioned earlier, Avis
and Fukuda [3] showed that the corresponding tree graph has a diameter bounded
by 2n− 4. We improve their result by 2n− k − s− 2 which produces a better result
when the values for k or s are greater than one. Even in the worst case when both
the parameters k and s have the value equal to one our result is as good as theirs.
32
T ∗ v0
Fig. 4.5: Showing the transformation of tree T ′ and T ′′ to be transformed into canonical tree T ∗v0 .
4.2 Path Transformation
In this section both theoretical and experimental results regarding path transforma-
tion are presented. We were not able to prove that a path can be transformed into
another when the point set is in general position in the plane. Instead of tackling the
problem of path transformation with points in general position (as we did for tree
33
transformation in the previous section) we conducted a number of experiments. We
generated n random points (n ≤ 13, and points are in general position and no three
points are collinear) in the plane and all the planar paths were constructed. Then
brute force search was employed to traverse all the paths of the point set and it was
found that the path graph (defined earlier) was connected in all of the simulation
runs. Section 4.2.3 provides the details of the experiment.
In section 4.2.2 we consider a special point set (points in convex position) and prove
the theoretical result that any two paths can be transformed from one to another. It
is shown that it takes a linear number of flips to transform a path into another path.
Assume we have the following information regarding the path graph. Define the
geometric path graph as the graph having P(S) as vertex set and two paths P i k,Qj
k ∈
P(S) are adjacent if Qj k = P i
k\{e} ∪ {f} for some edges e and f . In the following
section, it is proved that two arbitrary paths in P(S) can be transformed to each
other with at most 2n− 5 flips if n = |S|.
4.2.1 Quality of a Canonical path
Recall that a canonical path CPi,i+1 on S (recall that S is set of points in convex
position) is a path where the edges (vi, vi+1) are defined on the boundary of the convex
hull of S. This means that the quality of CPi,i+1 is, Qua(CPi,i+1) = n− 1 (as defined
earlier the quality of a path is the number of edges that are on the boundary of S),
see the Fig. 4.6.
The quality of any path is at least two because a path P which starts at vi must
34
v4
v1
v2
v7
v6
v5
v0
v3
v4
v1
v2
v7
v6
v5
v0
v3
Fig. 4.6: (a) Shows a canonical path, CP0,1 with Qua(CPi,i+1) = 7 and (b) shows an arbitrary path P with
Qua(P) = 4.
have the starting edge vivi+1 or vivi−1 which is on the boundary of the convex hull.
This is also true for the other end of P . So the quality of any path P is at least two.
4.2.2 Path Tranformation Strategy
Like the canonical transformation for trees, instead of directly transforming a path
Pa n−1 ∈ P(S) into another path Pb
n−1 ∈ P(S) where Pa n−1 6= Pb
n−1, we first show that
it is always possible to transform Pa n−1 into a canonical form CPi,i+1 and then do the
reverse of the operations that transform Pb n−1 into CPi,i+1. By the following lemma
we prove that to obtain CPi,i+1 from Pa n−1 takes n− 3 flips.
Lemma 4.2.1 Every path P i n−1 ∈ P(S) which is not canonical can be transformed
into a canonical form through flipping of edges in at most (n− 3) steps.
Proof Here vi is one of the end point of the path P i n−1. There is a j such that the first
j +2 vertices of the path are (vivi+1vi+2 · · · vi+jvi−1) or (vivi−1vi−2 · · · vi−jvi+1). With-
35
out loss of generality consider the former path consisting of vertices (vivi+1vi+2 · · · vi+jvi−1 · · · vk).
If j = n−2 then we are done because all the edges are on the boundary of the convex
hull and hence the path is a canonical path. If j < n−2 then we add the edge (vivi−1)
and delete (vi+jvi−1). The resulting set of vertices constitutes a path P i+j n−1 because
the addition of (vivi−1) makes a cycle (vivi+1vi+2 · · · vi+jvi−1vi) where the vertex vi−1
has degree three. The cycle is broken by removing the edge vi+jvi−1 connected to
vi−1 and reducing its degree to two. So the path P i+j n−1 has the set of j + 2 vertices
(vi+jvi+j−1 · · · vivi−1). Thus the quality of the path P i n−1 is increased by one.
This implies that if Pq n−1 represents any path at step i and Pr
n−1 is generated from
Pq n−1 at step i + 1 then Qua(Pr
n−1) = Qua(Pq n−1) + 1.
This edge will be flipped
(b)(a)
vt′ vt′
Fig. 4.7: (a) Shows the edge for flip (b) Shows the resultant path after flipping the edge {vt, vt′}.
Since there are at least two edges are on boundary for any given path, the number
of flips required is n− 3.
36
It is shown in the following, that to transform any two paths from one to another
the total number of flips is linear.
Theorem 4.2.2 For any paths P i n−1,Pj
n−1 ∈ P(S), it takes at most 2n − 5 flips to
transform one into another.
Proof From Lemma 5.1.2 it is clear that to obtain a canonical path from any given
path P i n−1 at most n − 3 flips are necessary. Also, from the definition of canonical
path we find that there are n possible canonical paths of n points in convex position
since i can take any value from 0 to n− 1. Moreover, with a single flip it is possible
to transform a canonical path into another one. This gives us a total of n − 2 flips.
Similarly, transforming P i n−1 into canonical form takes n − 3 flips. Therefore, the
total number of flips to transform P i n−1 into Pj
n−1 is at most 2n− 5.
4.2.3 Experimental Results for Path Transformation
In this section, we present experimental results of path transformation considering
the set P of n points. Recall that P is a set of n points in general position in the
plane.
Theoretically, the proof of connectedness of the path graph whose vertices are
non-crossing paths of P , and where two paths Pa n−1 and Pb
n−1 are adjacent if Pb n−1 =
Pa n−1\{e} ∪ {f}) is difficult. We implemented the problem for a small set of points
n (n ≤ 13) in general position in the plane. The experiment to solve the problem
employs a brute-force technique to generate all paths (intersected and intersection
37
free) on n vertices. The number of all such paths is n!/2. Any path connecting all
vertices of P can be represented by a permutation of n− digits. We filtered out all
intersected paths and compute Paccept, the set of permutations that correspond to the
planar paths of n− vertices.
Denote P ′ ∈ Paccept as the initial path consisting of all the vertices with increasing
order of their indices. We perform Depth First Search (DFS) technique starting from
the initial permutation P ′ to find out those permutations, each of which differs from
P ′ in such a way that their equivalent path representations differ by one edge. All
those permutations (including P ′) are marked indicating that they can be reached
from P ′ at most one flip. A similar step is followed with all the children of P ′ where
the children of P ′ are those permutations marked at previous step. This process of
marking permutations is continued following Depth First Search strategy until all the
permutations are covered (either marked or not marked).
Finally, it is checked whether all the permutations are marked or not. If all of
the permutations are marked then the meta graph is connected meaning any path
is reachable from any other path. If all the permutations are not marked, then this
means the meta graph is not connected. In the experiments we found that in every
run with a random set of points, or a specific input-set, the corresponding meta graph
is connected. We performed more than 100 simulation runs with point sets of size n
(n ≤ 13). Since the algorithm generates all the paths (planar and non-planar) of n
points and accepts only those which are planar, it takes exponential amount of time
to generate all such paths. Increasing the number of points (more than 13) costs
38
a lot of time to execute the algorithm. Therefore, we took at most 13 points for
our experiments. Each time of the simulation the points were randomly generated
in general position with no three points collinear. All the simulation runs produced
the same result of connectedness of the corresponding meta graph. We did not find
a counter example where the meta graph is not connected. The conclusion that we
draw from the results of our experiment lead us to believe that for any value of n the
corresponding meta graph is connected.
1234 1243 1423 1432
2134 2143 2314 3214
32
3
1
2
4
1
3
4
2
1
3
Fig. 4.8: (a) The meta graph of paths with vertices showing all possible paths of 4 points defined in the plane.
As an illustration, Fig. 4.8 shows the meta graph of paths of four vertices placed
on the corner of a square (points are shown inside each circle labeled as 1,2,3,4).
There are 8 acceptable permutations out of 4!/2 = 12 permutations as depicted. Two
incident vertices with each undirected edge in the graph indicate that the paths they
39
represent are reachable from one another by a single flip. Note that in this particular
example one can reach any one vertex from another with at most three flips.
40
Counting and Enumeration
5.1 Counting Paths
We show how to count all the directed and undirected paths on a point set in convex
position. A simple recurrence formula is used to count all such paths. Recall that P i k
denotes the set of paths length k starting at vi and connecting all vertices of V j k for
some j where vi ∈ V j k . The number of such paths (P i
k) is denoted by pi k. The basic
idea of counting relies on the definition of pi k. For any path P ′ ∈ P i
k (one end is vi),
let v` be the other end of this path.
Lemma 5.1.1 For any path P ′ ∈ P i k on V j
k (k ≤ n− 3) let v` be the other end of P ′.
We can construct a new path P ′′ of length k + 1, P ′′ ∈ P i k+1 from P ′ by connecting
v` of P ′ to vj−1 or vj+k+1. For k = n− 2 we can connect v` only to vj+k+1.
Proof Consider the end vertex v` of P ′. Assume v` is connected to any of the
41
vertices other than vj−1 or vj+k+1 to construct P ′′. Select vm ∈ V \V j k such that
vm 6= vj−1 and vm 6= vj+k+1. Consider the edge (vm, v`). Joining vm and v` divides
V \V j k into two disjoint sets of consecutive vertices X = {v`+1, v`+2, · · · , vm−1} and
Y = {vm+1, vm+2, · · · , vj−1} as shown in Fig. 5.1.
X
Y
P ′′
Fig. 5.1: Showing v` can only be connected to either vj−1 or vj+k+1 to construct P ′′ from P′.
Any vertex of either set (X or Y ) can see only the vertices of the same set (X
or Y ) because all the vertices of the other set are blocked by the edge (vm, v`). In
this circumstance it is obvious that any attempt to connect any vertex vr ∈ X to any
vertex vs ∈ Y will result in a crossing with edge (vm, v`). See the Fig. 5.1.
Therefore, the only way to get rid of crossings of edges and have a Hamiltonian
crossing-free path P ′′ of length k + 1 from P ′ is to join the vertex v` to either of the
vertices vj−1 or vj+k+1 of V \V j k . If k = n − 2 then there is only one vertex vj+k+1
that can be connected to the other end of P ′ to complete P ′′.
This completes the proof.
42
Lemma 5.1.2 The number of directed Hamiltonian paths of length n−1 and starting
at vertex vi is 2n−2.
Proof We can prove the above lemma through induction.
Recall that pi k denotes the number of paths of length k and starting at vi. For
k = 0, it is trivial that the number of paths of length 0 and starting at vi equals one as
there is only one path beginning at vi with no edge. For k = 1, pi 1 = 2 because there
can be only two paths of length one beginning from vi namely (vivi+1) and (vivi−1).
Similarly for k = 2, pi 2 = 4 = 2pi
1 since the total number of paths of length 2 starting
from vi is 4. These paths are (vivi+1vi+2), (vivi+1vi−1), (vivi−1vi−2) and (vivi−1vi+1).
Fig. 5.2 shows all the four paths of length 2 and starting from vi.
(a) (b)
(c) (d)
vi+1
vi+2
vi−1
vi−2
Fig. 5.2: All paths of length 2 starting at vi are shown in (a) (vivi+1vi+2) (b) (vivi+1vi−1) (c) (vivi−1vi−2)
and (d) (vivi−1vi+1)
43
For every value of k (k ∈ {0, 1, · · · , n − 3, n − 2}) there are twice as many paths
for pi k than pi
k−1. This is because for each of the path pi k−1 of length k − 1 we can
form two more paths of length k with the other end of each of the path pi k−1. So we
have pi k = 2pi
k−1 for 0 < k ≤ n− 2.
For the value k = n−1 we have pi n−1 = pi
n−2, because for each path of length n−2
we get exactly one corresponding path of length n− 1. Evaluating the recursion for
k = n− 1 the number of directed paths equals to pi n−1 = 2n−2.
Lemma 5.1.3 All the paths of P i k+1 derived from P i
k are distinct for 0 ≤ k ≤ n− 2.
Proof Take any path P ∈ P i k that starts at vi and uses all the vertices of V j
k =
{vj, vj+1, · · · , vj+k} where vi ∈ V j k . The path P can produce two paths of length k+1,
say P ′ and P ′′. Assume P ′ uses the vertex set, V1 = {vj, vj+1, · · · , vi, vi+1, · · · , vj+k, vj+k+1}
and P ′′ uses V2 = {vj−1, vj, · · · , vi, vi+1, · · · , vj+k, vj+k}. Since V1 6= V2, P ′ and P ′′ are
different.
From above we can conclude that although P ′ and P ′′ use different sets of vertices,
their starting edges, i.e., vivi+1 is common to them as they are generated from P in
which the starting edge vivi+1 is not changed to form P ′ and P ′′. Now consider
another path Q ∈ P i k which produces two paths Q′ and Q′′ of length k + 1. Since the
starting edge of Q is not equivalent to that of P , all the paths Q′ and Q′′ of Q are
different from P ′ and P ′′ of P .
Now we can prove the main theorem:
Theorem 5.1.4 The number of undirected Hamiltonian paths of length n−1 is n2n−3.
44
From Lemma 5.1.2 it has been found that the number of directed paths (of length
n− 1) of S starting at vertex vj is equal to 2n−2. Since there are n vertices, applying
the procedure described in the above lemma for each of the individual vertices the
total count of directed paths equals n2n−2. On the other hand for the case of counting
the number of undirected paths, observe that each of the paths is counted twice, one
starting with the higher labeled vertex and the same path with the lower labeled
vertex. So, the number of undirected paths is n2n−3.
5.2 Enumeration of Paths
In this section and the section following that we present two algorithms to generate
all the paths of n− points when the point set is convex position. Both algorithms
offer their relative advantages and limitations. The first algorithm (described in this
section) is recursive. In some sense, this algorithm is simple and straightforward, uses
only single flips to produce all the paths of n points. But the main limitation is that
it takes an exponential amount of space because of its recursive nature (uses stack to
store intermediate paths). In order to overcome the limitation of this algorithm we
present a non-recursive algorithm. This non-recursive algorithm uses less space. It
takes linear space to store the paths and produce new paths from them. The non-
recursive algorithm employs flips of size one and two. As defined earlier, a flip of size
two means removing two edges and putting two edges at a time in a path. Following
the presentations of the algorithms then space and time complexities are derived.
45
In the recursive algorithm, our strategy to generate all the paths of P(S) is to
begin with a canonical path, CPi,i+1 ∈ P(S) and generate all those paths possible from
CPi,i+1 with edge (vi, vi+1) fixed. The notion of vertex visibility plays the vital role to
carry out the process of path generation. As we go through a recursive procedure to
obtain new paths, consider building a tree where the root vertex of the tree represents
the path CPi,i+1 and all the children of CPi,i+1 are designated as the vertices of the
tree.
The spawning of a new path can only be initiated from its parent when a vertex
vi in the parent path can see at least one vertex vj such that j > i + 1.
Lemma 5.2.1 There is an algorithm that produces exactly 2n−3 distinct Hamiltonian
paths starting from a canonical path.
Proof Begin with a canonical path CPi,i+1 and consider it the root of the tree.
Consider the vertex vi−1 of CPi,i+1.
The vertices visible to vi−1 are vi, vi+1, vi+2, vi+3, · · · , vi−3 and the number of those
vertices is n−2 since vi−1 can not see itself and vi−2. Among the set of visible vertices
consider the second furthest visible vertex vi+1.
Start by generating the first path from CPi,i+1 by flipping the edge between the
second furthest visible vertex vi−2 and vi−3, i.e. removing edge (vi+1, vi+2) and in-
serting an edge (vi−1, vi+1). Represent this child path as Pn−3(vi+2) = CPi,i+1 ∪
(vi−1, vi+1)\(vi+1, vi+2) that differs from its parent by a single edge. Here Pj(vi) de-
notes a path where j is the number vertices visible to vi. Call the edge (vi−1, vi+1) as a
46
mark of Pn−3(vi+2). A mark is an edge that is not flipped, i.e., it remains unchanged
for a parent and all its successors.
Place this newly generated path as the leftmost child of the root. Continue gen-
erating the rest of the n− 3 paths and placing them from left to right:
...
P2(vi−3) = CPi,i+1 ∪ (vi−1, vi−4)\(vi−4, vi−3)
P1(vi−2) = CPi,i+1 ∪ (vi−1, vi−3)\(vi−3, vi−2).
Note that the marks of paths Pn−3(vi+2), Pn−4(vi+3), · · · ,P1(vi−2) are (vi−1, vi+1),
(vi−1, vi+2), · · · , (vi−1, vi−3), respectively. Since each of the marks is unique to each
path at this level (level-1, root is considered at level-0), all the paths generated are
unique, i.e. no path at this level has the same marks.
Starting from the leftmost child of the root we observe that the end vertex vi+2 of
the path Pn−3(vi+2) can see n− 3 vertices (which is one less than the number that its
parent can see). This is because vi is now blocked by edge vi−1vi+2. Like the previous
step, the leftmost child representing the path with end vertex vi−3 can produce n− 4
paths as its children in the next level where each of the paths (already having a mark
edge (vi−1, vi+1)) is generated with an additional mark edge (vi−1, vi+2). These two
47
marks uniquely identify a path which was not generated at a previous step and also
distinct in this level (level-2).
Similarly, the process is continued with each of the children of the root up to the
rightmost child which can see only vi−3 and can not generate any path.
Since at each level a new mark is added to each of the paths (which consists of a
set of unique marks from all previous levels) it can be concluded that all the paths in
the tree are uniquely generated. This recursive construction of paths continues until
the leftmost child of the tree can see only one vertex and thus can not produce any
offspring. The scenario is depicted in Fig. 5.3.
Let Nj(vi) be the number of child paths produced by Pj(vi).
The following gives us the values of Nj(vi)s:
N1(vi−2) = 0
N2(vi−3) = 1.
Continue going from the third rightmost vertex and so on and apply recursion in each
step:
= (1 + 1) + (1 + 0)
= (1 + 21 − 1) + (1 + 20 − 1)
The first 1 in each of the terms of the sum indicates the presence of the vertices
48
vn/2
vi
v1
v5
v0
vn−2
vn−3
vn−1
vn−2
vn−1vn−1
Fig. 5.3: Recursive enumeration of all paths from a canonical path CP0,n−1. Recursion terminates as vertex
vn/2 of the leftmost leaf of the tree can see only one vertex and thus is incapable of producing any path.
themselves and the rest of the integers denote the number of children they produce.
N4(vi−5) = N3(vi−4) + N2(vi−3) + N1(vi−2)
= (1 + 3) + (1 + 1) + (1 + 0)
= (1 + 22 − 1) + (1 + 21 − 1) + (1 + 20 − 1)
= (22) + (21) + (20)
49
Nn−2(vi) = Nn−3(vi+2) + Nn−4(vi+3) + Nn−5(vi=4) + · · ·+ N2(vi−3) + N1(vi−2)
= 2n−4 + 2n−5 + 2n−6 + · · ·+ 21 + 20
= 2n−3 − 1
This is the number of total vertices (excluding the root) of the tree. Counting the
root together with this number we get 2n−3 which is the total number of paths that
can be generated by CPi,i+1.
Consider the example of a set of n = 6 vertices given in Fig. 5.4. The root of the
tree is the path CP1,2 (v1v2v3v4v5v0). The generation of all paths from this canonical
path (26−3 = 8) starting with edge v1v2 is depicted.
5.2.1 Recursive Generation of All Paths
In the last section (specifically Lemma 5.2.1) we showed how we could generate paths
from a single canonical path. Here we describe the algorithm of generating all paths of
n vertices in convex position. We use all canonical paths CPi,i+1 and CPi+1,i (there are
2n such canonical paths) to enumerate all paths. As our algorithm uniquely generates
paths, we need to keep track, as the algorithm progresses whether a particular path is
generated twice. For this we form a A = n x n matrix that updates its entry ai,j = 1
where j = i+1 or j = i− 1 if all the paths beginning with edge (vi, vj) are generated
else ai,j = 0.
Start first with CP0,1 to generate all paths from it and then with CP1,0, CP1,2
50
v3
v4
v0
v5
v2
v1
v3
v4
v2
v1
Fig. 5.4: Recursive enumeration of all paths from the canonical path CP1,2 (v1v2v3v4v5v0) of 6 vertices. Bold
edges represent marks of the corresponding paths.
CP2,1, and continue up to CP0,n−1 and CPn−1,0. In general for each i (starting i at
0 and then incrementing it by one after each pair CPi,i+1 and CPi+1,i are done with
generation until i = n− 1) we generate paths from CPi,i+1 and CPi+1,i and continue
until paths are generated from CP0,n−1 and CPn−1,0.
Beginning with CP0,1 enumerate all the paths recursively as described in Lemma
5.2.1. And this generates 2n−3 paths each of which begins with edge (v0, v1). The entry
a0,1 in the matrix A is updated to 1 as all the paths from CP0,1 are generated. Then
begin and continue with CP1,0, CP1,2, · · · , CP0,n−1 and follow the same procedure.
Resolve the difficulty of avoiding previously generated paths in the following way.
51
Suppose we are generating paths from CPi,i+1. Let P ′ be a path generated from
CPi,i+1. Let (vp, vq) be its end-edge (q = p + 1 or q = p − 1). If the entry ap,q of A
is 0 then none of the paths with end-edge (vp, vq) have been generated then P ′ is not
duplicated and hence can be outputted. If on the other hand, the entry ap,q is 1, then
we do not ouput P ′.
5.2.2 Space and time complexity
As described earlier, we begin with a canonical path and start generating all the paths
from it in the next level. And then do the same of generating paths from each of
the paths (generated so far) in the next level and so on until we are finished with
the last one from which no paths can be generated. We need to keep track all the
paths generated from the root up to the left-most leaf to continue generating paths
which produce exponential number of paths (2n−3 paths). It follows that the space
complexity is also exponential which is O(2n).
In the case of time complexity we find the maximum time required to successively
generate any two paths Pi and Pi+1. If t(Pi) represents the time elapsed from the
beginning of the algorithm until Pi generated then maxi = t(Pi+1)− t(Pi) determines
the amount of time required to generate and output two successive paths Pi and Pi+1.
Since there can be an exponential number of paths that are generated (according to
the algorithm) but not outputted between Pi and Pi+1, the time maxi results in
exponential. This gives O(2n) time complexity.
52
5.3 Non-recursive Construction
Here we discuss an algorithm to non-recursively generating all paths P(S).
Each path consisting of n vertices is unique and it can be represented by a per-
mutation of n− digits where each of the vertices represents a digit.
Begin with the canonical path CP0,1 (v0v1v2v3 · · · vn−2vn−1). What we wish to do
is enumerate all 2n−3 paths from CP0,1 keeping the edge (v0, v1) fixed (not flipped)
and flipping edges (vi−1, vi) not involving (v0, v1). We will also do the same with
the rest of the canonical paths CPm,m+1 and CPm+1,m by not flipping the edges
(vm, vm+1) and (vm+1, vm) respectively. Assume the equivalent n−digit representation
of the permutation of CP0,1 (v0v1v2v3 · · · vn−2vn−1) is A0,1 = a0a1a2 · · · an−2an−1 where
an−1 > an−2 > an−3 · · · > a1 > a0. Call this the initial permutation where each
digit ai where 0 ≤ i ≤ n − 1 of the permutation corresponds to each vertex vi.
In the following the generation of successive permutations is shown. Each of the
permutations represents a unique path.
5.3.1 Generation Method
Keep the positions of a0 and a1 unchanged and change the positions of the remaining
digits ai, 1 < i ≤ n− 1, to generate successive permutations.
The basic idea is that, at any step, a digit ai of the permutation can only have
digit max{ai+1, ai+2, · · · , an−1} or min{ai+1, ai+2, · · · , an−1} as its right neighbour.
Having a minimum or a maximum digit to the right of a digit ensures planarity of the
53
path represented by the permutation (this can be verified from Lemma 5.1.1). For
example, 01 276345 is a permutation of this kind where the digit 7 has 6 as its right
neighbour which is the maxmimum of {6, 3, 4, 5} and 6 has 3 as its right neighbour
which is the minimum of {3, 4, 5} etc.
Find i from the rightmost position of the permutation such that ai−1 < ai. If
i = n−1, obtain the next permutation by exchanging the positions of ai−1 and ai which
is equivalent to a single flip (a flip of size one). Let the number of digits to the right
of ai be k. If i 6= n−1, then the next permutation is obtained by first exchanging the
positions of ai−1 and ai and then reversing the positions of ai+1, ai+2, ai+3, · · · , an−1.
The changing of positions of the digits is equivalent to a flip of size two. The edges
that are removed are (vai , vai+1
) and (vai−1 , vai−2
) and the newly inserted edges are
(vai−1 , va1) and (vai−2
, vai ) which is the reflection of the above permutation. The
process of generating a permutation Pm from a previous one Pm−1 beginning from
the rightmost digit of Pm−1 to find ai−1 < ai is continued until we obtain a2 > a3 >
a4 · · · > an−2 > an−1.
As an example, consider n = 8. All the possible permutations of 8−digits (from
Lemma 5.1, 28−3 = 32) according to this method are shown below (keeping the
positions of the two leftmost (01) digits unchanged):
01 234567 → 01 234576 → 01 234756 → 01 234765 → 01 237456 → 01 237465
01 237645 → 01 237654 → 01 273456 → 01 273465 → 01 273645 → 01 273654
54
01 276345 → 01 276354 → 01 276534 → 01 276543 → 01 723456 → 01 723465
01 723645 → 01 723654 → 01 726345 → 01 726354 → 01 726534 → 01 726543
01 762345 → 01 762354 → 01 762534 → 01 762543 → 01 765234 → 01 765243
01 765423 → 01 765432.
5.3.2 Correctness of the Algorithm
What we wish to show is that all the paths generated by this algorithm are unique
and the total number of such paths is 2n−3. We can imagine a binary tree where
each of the vertices will represent a digit ai of a permutation. Let us assume A =
{a1, a2, · · · , an−1} and let the root be denoted as the element a1 which is at level-0. At
the next level the left and right children of the root are determined by max{A−{a1}}
and min{A − {a1}}, respectively.
In general at level-i the left and right children of a vertex at level-(i − 1) will be
determined in the following way (see Fig. 5.5 where a0a1a2a3a4a5a6 = 0123456):
left child = max{A−{all ais along the path from the root to the current vertex at level i-1}}
and
right child = min{A−{all ais along the path from the root to the current vertex at level i-1}}
As there are n−1 elements in the permutation a1a2a3 · · · an−2an−1 and the parent
of each leaf contains exactly one leaf, the height of the tree is n−1−2 = n−3. Then
55
1
5
3
435
5
Fig. 5.5: Tree representation of permutations
the total number of leaves equals 2n−3. As all the elements of A are distinct and each
path from a leaf to the root is unique, all such paths of the tree are unique.
5.3.3 Mapping Between CP0,1 and CPm,m+1 (CPm+1,m)
After generating all the valid permutations (each represents a unique path) of A0,1
we can now proceed to generate other paths from each of the remaining canonical
paths. Without loss of generality we only show mapping between CP0,1 and CPm,m+1.
Mapping between CP0,1 and CPm+1,m is also meant subsequently after mapping of
CPm,m+1 is done, although not mentioned.
There is a one-to-one correspondence between CP0,1 and all other canonical paths
CPm,m+1 and CPm+1,m. Let the equivalent n− digit representation of the permutation
of CPm,m+1 be A′ m,m+1 = amam+1am+2 · · · am−2am−1.
In order to enumerate paths from CPm,m+1 we first map A′ m,m+1 (the equivalent
permutation of CPm,m+1) and A0,1 (the equivalent permutation of CP0,1) with the
56
function f : A′ m,m+1 → A0,1 such that the function yields:
f(aim) = ai0 , f(aim+1) = ai1 , · · · , f(aim−1) = ain−1 .
A mapping between A′ 4,3 and A0,1 is shown in Fig. 5.6.
0 1 2 6543
A0,1
Fig. 5.6: Mapping between A′4,3 and A0,1.
Start generating permutations with A0,1 as it is done before. But this time we
need to check whether paths represented by permutations are already generated or
not. In generating permutations, if we find any of them is already generated then
the permutation is discarded, else it is generated. To realize the fact whether any
paths are already generated we introduce the term what we call index to the two
leftmost (rightmost) digits of all the permutations. Index starts from the two left-
most digits of A0,1 with the value 1. That is, the index of the two leftmost digits
a0a1 of a permutation is 1. Next the index of the two digits a1a0 is 2, the index
of a1a2 is 3 and so on. So in general for each m (starting at m = 0 and then in-
crementing it by one after each pair of digits amam+1 and am+1am are indexed until
m = n − 1) the indices of two leftmost (rightmost) digits amam+1 and am+1am are
2m + 1 and 2m + 2 respectively. For example, if n = 6 the indices of two leftmost
(rightmost) digits a0a1, a1a0, a1a2, a2a1, a2a3, a3a2, a3a4, a4a3, a4a5, a5a4, a5a0, a0a5 are
57
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, respectively.
As a permutation is generated from A0,1, do the inverse of f on this permutation
and see whether the index of the two rightmost digits or their reverse is smaller than
the index of the two leftmost digits of this permutation. If this is smaller then this
means that the permutation is already generated and we can discard the permutation.
This is evident since we begin generating all the permutations in order where the two
leftmost digits of all the permutations are a0a1, a1a0, a1a2, a2a1, · · · , an−1an−2, a0an−1.
This ensures us that when we find the index of the two rightmost (or their reverse)
digits is smaller than the index of two the leftmost digits, this indicates that those
permutations with smaller index in the two leftmost digits are already generated.
Consider the example with n = 6 and assume that we are going to generate paths
from CP3,4 where A′ 3,4 = 34 5012 and A0,1 = 01 2345. First we do f : A′
3,4 → A0,1
and find f(3) = 0, f(4) = 1, f(5) = 2, f(0) = 3, f(1) = 4, f(2) = 5. So the
first permutation is 01 2345. As this is obtained we need to check whether it is
already generated. Applying the reverse function we get f−1(0) = 3, f−1(1) = 4,
f−1(2) = 5, f−1(3) = 0, f−1(4) = 1, f−1(5) = 2, i.e., the permutation is 34 5012
where the index of the two rightmost digits is smaller than the index of the two
leftmost digits (index of a1a2 is 3 and the index of a3a4 is 7). This means that we will
produce this permutation as output since it is generated with A′ 1,2. Let us assume
another permutation 01 5423. Now apply the reverse function and get the following
permutation 34 2150. Since (index of a5a0 is 11 and the index of a3a4 is 7) we are
sure that this permutation has not been generated before and we can generate this
58
permutation.
Note that we do not need to generate any permutations from A′ 0,n−1 since all
the permutations that can be generated from A′ 0,n−1 have their two rightmost digits
(or their reverse) equal to the two leftmost digits of all the permutations that have
already been generated. In fact, permutations from A′ n−2,n−1 and A′
n−1,n−2 do not
need to be generated for the same reasoning.
5.3.4 Space and time complexity
Space complexity has been improved a lot (from exponential to linear) in this non-
recursive procedure. We begin with a canonical path and start generating a path
from it. And then generate a new path from the currently generated one in sequence
and so on until