Hamiltonian Cycles in Triangle Graphs
Total Page:16
File Type:pdf, Size:1020Kb
Hamiltonian Cycles in Triangle Graphs U Dogrusoz and M S Krishnamo orthy Tom Sawyer Software Hearst Avenue Berkeley CA ugurtomsawyercom Department of Computer Science Rensselaer Polytechnic Institute Troy NY mo orthycsrpiedu Abstract Weprove that the Hamiltonian cycle problem is NPcomplete for a class of planar graphs named triangle graphs that are closely related to innertriangul ated graphs We present a linear time heuristic algorithm that nds a solution at most onethird longer than the optimum solution and use it to obtain a fast rendering algorithm on triangular meshes in computer graphics Keywords Planar graph innertriangulatedgraph triangle graph NPcomplete heuristic algorithm rendering triangular meshes Intro duction The Hamiltonian cycle problem HC is that of determining whether or not a given graph contains a cycle that passes through every vertex exactly once and has numerous applications in dierent areas HC is NPcomplete for various classes of graphs including cubic connected planar graphs and maximal planar graphs and therefore for innertriangulations but a p olynomial time algorithm was presented for connected planar graphs by Chiba and Nishizeki The problem of nding a Hamiltonian cycle in an innertriangulation has applications in computer vision in determining the shap e of an ob ject represented by a cluster of p oints Cimikowski identied a Hamil tonian sub class of innertriangulations namely simply nested innertriangulations and presented a lineartime algorithm for nding a Hamiltonian cycle in suc h graphs A threecolorable class of graphs called trian gle graphs closely related to innertriangulated graphs was dened and their application to the parallel nite element solution of elliptic partial dierential equations on triangulated domains was discussed in The eciency of highp erformance rendering machines suchasOpenGL andIGL on triangular meshes in computer graphics is prop ortional to the rate at which triangulation data is sent to it Ordering the triangles so that consecutive triangles share a face reduces the data rate by a factor of three since now only one vertex p er triangle need b e sp ecied Such an ordering exists if and only if the dual of the given triangulation is Hamiltonian ie contains a Hamiltonian path Also note that in order to completely sp ecify the top ology of the triangulation the insertion order of the new vertices must b e sp ecied see Figure a OpenGL asks the user to issue a swaptmesh call whenever the insertion order deviates from alternating leftrightturns IGL on the other hand exp ects triangulations as vertexstrips and a vertex must b e senttwice to get two consecutive leftorright turns Hamiltonian triangulations can b e considered as triangulations satisfying a certain Grayco de prop erty consecutive triangles share a face In this pap er we prove that nding a Hamiltonian cycle of a triangle graph is in the class of NPcomplete problems and give a heuristic algorithm to nd a solution that is at most onethird longer than the optimum This heuristic is shown to result in a fast rendering algorithm on triangular meshes in computer graphics Preliminary Denitions An innertriangulation or an innertriangulated graph is a maximal planar graph which has an em b edding where eachinterior face or region of the graph is a triangle We will call suchanemb edding a triangular grid Merging twovertices u and v consists of collapsing them to form a new vertex at the same p osition as u which is adjacen t to all vertices w that were adjacent to either u or v v (a) (b) Fig a Next vertex v might sp ecify one of the two triangles shown dep ending on the turn wetake b An innertriangul atio n whose vertices are represented with empty circles and the corresp onding triangle graph whose vertices are represented with lled circles uv, u v 1 1 2, 2 uv, (a) (b) (c) Fig An element of a triangle graph a and the construction of other triangle graphs by merging one b and two c degreetwo no des Denitions through dene a class of emb edded graphs named triangle graphsWe refer the reader to for more information on triangle graphs Denition An element is a complete graph of three vertices with an embedding seeFigurea Denition A component is either a single element or a chain of elements where two and only two elements cal led end elements have two degreetwo vertices The remaining elements have two degreefour and one degree two vertices see Figure a The smal lest component is a single element Denition A triangle graph is an embedded planar graph G constructedaccording to the fol lowing rules i A component basic building block is a triangle graph es of G and H respectively ii If G is a triangle graph and H is a component and u and v aredegreetwo vertic then the graph obtainedbymerging vertices u and v is a triangle graph if and only if the resulting graph is planar see Figure b iii If G is a triangle graph and H is a component and u and u are two neighboring cf Denition degree two vertices of G and v and v are two neighboring degreetwo vertices of H thenthegraph obtainedby merging vertices u and v and vertices u and v is a triangle graph if and only if the resulting graph is planar no vertex of an interior faceisofdegree two and every interior facecontains at least threeedges see Figure c n1 n2 n3 (a) (b) Fig a An example of a comp onent of a triangle graph b Neighb oring no des n and n and nonneighb oring no des n and n of a triangle graph Denition Since triangle graphs are embedded in a plane the exterior faceconsists of al l nodes in the exterior region Two degreetwo nodes n and n of a triangle graph are neighbors if and only if thereisa path along the exterior facefrom n to n that does not contain any other degreetwo nodes For example in the graph of Figure b nodes n and n are neighbors while n and n are not Let G V E b e a planar graph The dual of G V E is a graph G V E where every region d d d in G is represented bya vertex in V and twovertices in G are adjacent if and only if the two corresp onding d d regions share an edge in G The edge adjacency graph of a graph G V E is a graph G V E whereevery edge in E is mapp ed onto a vertex in V and twovertices in V are adjacent if and only if their corresp onding edges in E are adjacent Lemma Edge adjacency graph of a triangular grid is a triangle graph In addition al l vertices except possibly those on the outerfaceareofdegree four Pro of We use induction on the numb er of triangular elements of the grid A single triangular element maps to a single element of its triangle graph representation Assuming edge adjacency graph of a triangular grid of n elements corresp onds to a triangle graph of n elements consider an arbitrary grid of n elements Removing a b oundary element a triangular region results in a grid of n elements whose edge adjacency graph is a triangle graph by the induction hyp othesis Returning this elementback results in one of the following two situations where the triangular elementaddstwo edges to the grid to extend the corresp onding triangle graph according to rule ii of Denition or the new element adds one edge to close the corresp onding triangular grid with a single triangle element using rule iii of Denition Notice that in b oth cases the vertices of the triangle graph corresp onding to the edges which are reused to extend or close the triangular grid will b e of degree four Only the vertices corresp onding to the edges on the outerface of the grid will b e of degree two ut Figure b illustrates the relationship b etween triangular grids and triangle graphs with an example A graph is said to b e triplyconnected or triconnected if and only if removal of no pair of vertices leaves the graph disconnected A graph G is called a cubic connected planar graph if it is planar its every vertex is of degree three and it is triplyconnected Let PHC denote the problem of determining whether or not a cubic connected planar graph contains a Hamiltonian cycle Also let THC represent the Hamiltonian cycle problem for triangle graphs THC is NPcomplete Theorem THC is NPcomplete Pro of THC is NPcomplete b ecause THC is in NPAverication algorithm for THC in nondeterministic p olynomial time is straightforward and omitted THC is NPhard We will next show this by transforming an NPcomplete problem namely PHC to THC in p olynomial time K (a) (c) (b) Fig a Basic building blo ck K used for the transformation b Possible lo cal states of K c Triangular grid corresp onding to K The transformation is p erformed by replacing eachvertex along with its incident edges of the graph G given for PHC with a graph K as shown in Figure a to obtain G K mighthaveve p ossible states in G for each dierentway the corresp onding vertex in G is visited see Figure b From the ab ove transformation it is obvious that G will have a Hamiltonian cycle if and only if the original graph G has a Hamiltoniancycle What remains to b e shown is that G is a triangle graph Let G be the d emb edded dual of G It is easy to see that G is an innertriangulation Furthermore let G b e the emb edded d d graph obtained when each face of G is partitioned into three triangle faces as shown in Figure c Notice d corresp onds to G Therefore by is also an innertriangulation and the edge adjacency graph of G that G d d Lemma G is a triangle graph ut Approximation Algorithm Christodes has develop ed a p olynomial time approximation algorithm with a worstcase b ound of for the traveling salesman problem in which the distance b etween vertices