• Nenhum resultado encontrado

Colored triangulations of maps = Triangulações coloridas de mapas

N/A
N/A
Protected

Academic year: 2021

Share "Colored triangulations of maps = Triangulações coloridas de mapas"

Copied!
69
0
0

Texto

(1)

INSTITUTO DE COMPUTAÇÃO

Lucas Moutinho Bueno

Colored Triangulations of Maps

Triangulações Coloridas de Mapas

CAMPINAS

2016

(2)

Lucas Moutinho Bueno

Colored Triangulations of Maps

Triangulações Coloridas de Mapas

Tese apresentada ao Instituto de Computação da Universidade Estadual de Campinas como parte dos requisitos para a obtenção do título de Doutor em Ciência da Computação.

Dissertation presented to the Institute of Computing of the University of Campinas in partial fulfillment of the requirements for the degree of Doctor in Computer Science.

Supervisor/Orientador: Prof. Dr. Jorge Stolfi

Este exemplar corresponde à versão final da Tese defendida por Lucas Moutinho Bueno e orientada pelo Prof. Dr. Jorge Stolfi.

CAMPINAS

2016

(3)

Ficha catalográfica

Universidade Estadual de Campinas

Biblioteca do Instituto de Matemática, Estatística e Computação Científica Ana Regina Machado - CRB 8/5467

Bueno, Lucas Moutinho,

B862c BueColored triangulations of maps / Lucas Moutinho Bueno. – Campinas, SP : [s.n.], 2016.

BueOrientador: Jorge Stolfi.

BueTese (doutorado) – Universidade Estadual de Campinas, Instituto de Computação.

Bue1. Topologia. 2. Triangulação. 3. Teoria dos grafos. I. Stolfi, Jorge,1950-. II. Universidade Estadual de Campinas. Instituto de Computação. III. Título.

Informações para Biblioteca Digital

Título em outro idioma: Triangulação colorida de mapas Palavras-chave em inglês:

Topology Triangulation Graph theory

Área de concentração: Ciência da Computação Titulação: Doutor em Ciência da Computação Banca examinadora:

Jorge Stolfi [Orientador] José Coelho de Pina Junior Daniel Morgato Martin Christiane Neme Campos Orlando Lee

Data de defesa: 16-09-2016

Programa de Pós-Graduação: Ciência da Computação

(4)

Universidade Estadual de Campinas Instituto de Computação

INSTITUTO DE COMPUTAÇÃO

Lucas Moutinho Bueno

Colored Triangulations of Maps

Triangulações Coloridas de Mapas

Banca Examinadora: • Prof. Dr. Jorge Stolfi

IC-UNICAMP

• Prof. Dr. Orlando Lee IC-UNICAMP

• Prof. Dra. Christiane Neme Campos IC-UNICAMP

• Prof. Dr. Daniel Morgato Martin CMCC - UFABC

• Prof. Dr. José Coelho de Pina IME- USP

A ata da defesa com as respectivas assinaturas dos membros da banca encontra-se no processo de vida acadêmica do aluno.

(5)

I would like to thank:

• FAPESP and CNPq for financial support.

• Prof. Jorge Stolfi and Prof. Raimund Seidel for academic support. • My family and friends for personal support.

(6)

Resumo

Essa tese propõe algoritmos para subdividir mapas topológicos de duas e três dimen-sões em triangulações coloridas nos vértices, usando 3 e 4 cores, respectivamente. Os algoritmos tentam criar o menor número possível de triângulos (ou tetraedros) na saída em tempo compatível com o método convencional da subdivisão baricêntrica. Prova-mos, tanto teoricamente como empiricamente, que os algoritmos propostos geram menos triângulos (ou tetraedros) que a subdivisão baricêntrica.

Triangulações coloridas são importantes para o uso da estrutura de dados gema para representar a topologia de triangulações de qualquer dimensão d ≥ 2.

(7)

This thesis proposes algorithms to subdivide topological maps of two and three dimensions into triangulations colored on the vertices, using 3 and 4 colors, respectively. The algo-rithms attempt to create as few triangles (or tetrahedra) as possible in time compatible to the conventional method of the barycentric subdivision. We prove, both theoretically and empirically, that the proposed algorithms generate fewer triangles (or tetrahedra) than the barycentric subdivision.

Colored triangulations are important for the use of the GEM data structure to repre-sent the topology of triangulations of any dimension d ≥ 2.

(8)

List of Figures

1.1 (a) Example of a two-dimensional planar map M , (b) a subdivision of M into a triangulation T , (c) and a 3-coloring for T . . . 13 1.2 (a) Triangulation T that is not 3-colorable, (b) the barycentric subdivision

of T and (c) a more efficient subdivision of T . . . 15 2.1 A map with a border vertex u, an internal vertex v, a border edge e and

an internal edge f . . . 17 2.2 A partition of a topological space that is not a map. It has a vertex w that

is a local cutset, two faces (A and B) whose frontiers are not homeomorphic to a 1-sphere (cycle), and a face C incident to only one edge whose closure is not homeomorphic to a closed 1-ball (a line segment). . . 17 2.3 (a) A 3-colored 2-triangulation, (b) its respective GEM graph and (c) its

respective GEM data structure. . . 20 3.1 Processing of a sample map M , showing the situation (a) just before, (b)

during, and (c) just after the main loop of the 3-coloring algorithm, and (d) the final result T . The faces of T0 are in dark gray and those of M0 in light gray. The white square is a hole in SM. . . 23

3.2 The extended dual graph corresponding to the situation of Figure 3.1(b). . 24 3.3 Examples of the Colorize procedure. The thick lines represent edges in the

front. . . 26 3.4 Examples of the FaceSplit procedure, when the condition of the step 1 is

satisfied (a), when the condition of the step 2 is satisfied at least once (b), and when only step 3 is executed (c). . . 27 3.5 Effect of the processing order on the efficiency of the algorithm. The faces

selected to be processed are numbered in increasing order in the input map at left. The output triangulation is at right. . . 36 3.6 Histogram of the inefficiency index η(M ) for random regular maps with

D = 3 and |FM| = 2048 (η = 0.413). Random regular maps are detailed

in Section 3.6.3. . . 37 4.1 A 3-map consisting of a single cubic cell (a) and three different 4-colored

3-triangulations for it: a subdivision with 6 tetrahedra (ABDH, ADCH, ACGH, ABFH, AEFH and AEGH) (b), a subdivision with 5 tetrahedra (BADF, EAFG, CADG, HDFG and ADFG) (c), and the barycentric sub-division with 48 tetrahedra (d). . . 43

(9)

without changing the colors of the vertices. (C) An alternative triangula-tion obtained by flipping edges and changing some vertex colors. . . 67

(10)

List of Tables

3.1 Experimental results for Delaunay triangulations as input maps. . . 38

3.2 Experimental results for Voronoi diagrams as input maps, without the face selection heuristic. . . 38

3.3 Experimental results for Voronoi diagrams as input maps, using the face selection heuristic. . . 39

3.4 Experimental results for random regular maps with D = 3. . . 40

3.5 Experimental results for random regular maps with D = 4. . . 40

3.6 Experimental results for random regular maps with D = 6. . . 40

3.7 Experimental results for random irregular maps with 3 ≤ d(m) ≤ 9. . . . 41

4.1 Experimental results for random maps of cubes. . . 62

4.2 Experimental results for random maps of tetrahedra. . . 62

(11)

1 Introduction 13

1.1 Thesis goal . . . 13

1.2 Motivation . . . 14

1.3 Previous work . . . 14

1.4 Thesis structure . . . 15

2 Definitions and notations 16 2.1 Maps . . . 16 2.1.1 Basic concepts . . . 16 2.1.2 d-map . . . 16 2.1.3 Sub-map . . . 18 2.1.4 d-triangulation . . . 18 2.1.5 Subdivision . . . 18 2.1.6 Graph colorings . . . 18 2.1.7 Map coloring . . . 19

2.1.8 The barycentric subdivision . . . 19

2.1.9 Map duality . . . 19

2.2 GEM . . . 20

2.2.1 GEM graph for triangulations . . . 20

2.2.2 GEM data structure for triangulations . . . 20

2.2.3 GEM data structure for general maps . . . 21

3 3-Colored Triangulations of 2-Maps 22 3.1 Introduction . . . 22

3.2 The algorithm for 3-Colored triangulation . . . 23

3.2.1 Overview . . . 23

3.2.2 The extended dual graph . . . 24

3.2.3 Detailed algorithm . . . 24

3.2.4 The Colorize procedure . . . 25

3.2.5 The FaceSplit procedure . . . 26

3.2.6 Selecting the next face . . . 27

3.3 Correctness . . . 28

3.3.1 General remarks . . . 28

3.3.2 Connectivity of M0∗ . . . 29

3.3.3 Conclusion of proof . . . 31

3.4 Efficiency . . . 31

3.4.1 Output upper bounds . . . 31

(12)

3.4.3 Time complexity . . . 34

3.5 Efficient face selection heuristic . . . 35

3.5.1 Effectiveness for triangulations . . . 36

3.6 Experimental results . . . 36

3.6.1 Delaunay triangulations . . . 37

3.6.2 Voronoi diagrams . . . 38

3.6.3 Random regular maps . . . 39

3.6.4 Random irregular maps . . . 40

3.7 Conclusions . . . 40

3.8 Apendix: earlier solutions . . . 41

3.8.1 Reducer chains . . . 41

3.8.2 3-Colored subdivision of triangulations . . . 41

4 4-Colored Triangulations of 3-Maps 42 4.1 Introduction . . . 42

4.2 The algorithm for 4-Colored triangulation . . . 42

4.2.1 Overview . . . 42

4.2.2 Detailed algorithm . . . 43

4.2.3 The 1DSplit procedure . . . 45

4.2.4 The 2DSplit procedure . . . 45

4.2.5 The 3DSplit procedure . . . 46

4.3 Correctness . . . 46

4.4 Efficiency . . . 48

4.4.1 General considerations . . . 48

4.4.2 Rules for coloring vertices . . . 49

4.4.3 Output efficiency . . . 50

4.4.4 Convexity . . . 51

4.4.5 Time complexity . . . 52

4.5 Special case: shellable triangulations . . . 52

4.5.1 Cell patterns . . . 53

4.5.2 Rules description . . . 53

4.5.3 Output upper bound for shellable triangulations . . . 54

4.5.4 Lower bound . . . 60

4.5.5 Convexity and Time complexity . . . 60

4.6 Experimental results . . . 61

4.6.1 Random maps of cubes . . . 61

4.6.2 Random triangulations . . . 62

4.6.3 Random shellable triangulations . . . 62

4.7 Acknowledgment . . . 63

5 Final remarks 64 5.1 Conclusions . . . 64

5.2 Future work . . . 65

5.2.1 Colored triangulations of d-Maps . . . 65

5.2.2 Colored mesh generation . . . 66

5.2.3 Edge flipping of colored 2-triangulations . . . 66

5.2.4 Adaptive refinement of GEMs . . . 67

(13)

Introduction

1.1

Thesis goal

The goal of this thesis is to propose efficient algorithms to subdivide d-dimensional maps into triangulations that are (d + 1)-colorable on the vertices. See Figure 1.1.

Precise definitions of maps, triangulations and related topics are given in Chapter 2. For this introduction, it suffices to say that:

• A d-dimensional map is a partition of a d-dimensional topological space into a collection of disjoint sets, its k-parts, with 0 ≤ k ≤ d. Each k-part is homeomorphic to a unit open ball of Rk. In particular, a 0-part is a vertex, a 1-part is an edge, a

2-part is a face and a 3-part is a cell.

• A d-dimensional triangulation is a map where all k-parts are k-dimensional sim-plexes. A 0-simplex is a vertex, a 1-simplex is an edge, a 2-simplex is a triangle and a 3-simplex is a tetrahedron.

• A (vertex) k-coloring of a map M is an assignment of the k “colors” (labels) {0, 1, 2, . . . , k− 1} to the vertices of M in such a way that the two endpoints of every edge have distinct colors.

(a) (b) (c)

Figure 1.1: (a) Example of a two-dimensional planar map M , (b) a subdivision of M into a triangulation T , (c) and a 3-coloring for T .

(14)

CHAPTER 1. INTRODUCTION 14

1.2

Motivation

Triangulations of any dimension d that are (d + 1)-colorable can be efficiently represented and manipulated by the GEM (Graph-Encoded Manifolds) data structure of Montagner and Stolfi [15, 14], based on the graph class of the same name created by Sóstenes Lins and Arnaldo Mandel [13].

The two-dimensional GEM data structure represents each triangle t by a record with pointer fields t.p[i], i ∈ {0, 1, 2}, corresponding to the 3 colors. The field t.p[i] points to the record of the triangle t0 that is adjacent to t across the edge e opposite to the vertex of color i.

Unlike other triangulation data structures, there is no need to identify which side of t0 is the edge e, or to perform runtime checks to obtain that information (e.g: from vertex pointers): in the GEM structure t0.p[i] points back to t. The GEM data structure can also be generalized to higher dimensions (see Chapter 2).

Perhaps the major obstacle to widespread use of the GEM structure in applied areas is the fact that many d-dimensional triangulations that occur in practice, such as the Delaunay triangulation of sites on the plane, are not (d + 1)-colorable, hence cannot be represented directly as a GEM. However, in many applications, the given triangulation T is not important, and it could be replaced by some subdivision of T – provided that the latter is not much larger than the original. An example was described in Montagner’s thesis [14]: the adaptive refinement of a GEM triangulation to provide an accurate representation of a bivariate function.

The algorithms proposed in this thesis aim to reduce that obstacle, making the GEM structure more attractive in practical applications.

1.3

Previous work

There is currently little explicit use of the GEM data structure in applied areas. Its use has been mostly confined to computational topology, specifically the theoretical study of 3-manifolds. However, there is substantial implicit use of the GEM structure in compu-tational geometry. The straightforward implementation of the barycentric subdivision [2] (BCS) of a general d-dimensional map, and of map data structures that are based on it (such as Brisson’s [4] and Lienhardt’s [12]), is a special case of the GEM data structure. For maps in two dimensions, the quad-edge data structure of Guibas and Stolfi [10] is an optimization of the two-dimensional BCS GEM structure, that combines certain 4-cycles into single data records. The facet-edge data structure of Dobkin and Laszlo [9] is a similar optimization for three-dimensional BCS GEMs.

The BCS is easily implemented, but it usually outputs a map with an excessive amount of simplexes (See Figure 1.2). In particular, the BCS of a d-dimensional triangulation M with n d-dimensional simplexes creates a (d + 1)-colored d-triangulation with n(d + 1)! d-dimensional simplexes. For a two-dimensional map M of a sphere, the BSC creates 4 triangles for each edge of M .

(15)

0 1 2 ? 0 0 0 0 1 1 1 1 1 1 2 2 2 0 1 0 1 2 (a) (b) (c)

Figure 1.2: (a) Triangulation T that is not 3-colorable, (b) the barycentric subdivision of T and (c) a more efficient subdivision of T .

1.4

Thesis structure

Chapter 2 formalizes some concepts needed for the remaining of the thesis.

In Chapter 3 we describe the algorithm 2DT riangulate, that subdivides any two-dimensional map into a 3-colored triangulation. This algorithm is proved to be more output-efficient than the BCS, both theoretically and empirically. The content of Chap-ter 3 was also published in a peer-reviewed journal [7].

In Chapter 4 we describe the algorithm 3DT riangulate, that generalises 2DT riangulate for three-dimensional maps.

Chapter 5 summarises the contributions of this thesis and suggests some problems for future research.

(16)

Chapter 2

Definitions and notations

In this Chapter we formally define d-dimensional-maps, GEMs and other related concepts. These definitions are used by the algorithms described in Chapters 3 and 4.

We assume known basic knowledge of topology and graph theory. Introdutory infor-mation about these subjects are found in [1] and [3].

In particular, we assume known the following concepts of topology: topological space, open sets and closed sets, closure, homeomorphism, connectivity and compact space.

2.1

Maps

2.1.1

Basic concepts

Let S be a topological space. An open (resp. closed ) k-ball of S is a subset of S home-omorphic to the k-dimensional unit open (resp. closed) ball of Rk. A k-sphere of S is a subset of S homeomorphic to the unit sphere Sk of Rk+1.

The frontier of a subset of S is its closure excluding itself.

A subset of S is said to be incident to another subset of S if one is contained in the frontier of the other.

A local cutset is a subset X of S such that there is a connected open set of S that contains X but is disconnected if X is removed.

2.1.2

d-map

We define a d-dimensional-map M with d ≥ 2, or simply a d-map, as a partition of a connected compact topological space, denoted by SM, into a finite collection of disjoint

open k-balls, for 0 ≤ k ≤ d, that satisfies the properties 1-6 below. Each k-ball is called a k-part of M . In particular, a 0-part is a vertex, a 1-part is an edge, a 2-part is a face and a 3-part is a cell.

1. the frontier in SM of each k-part is a (k − 1)-sphere;

2. the closure in SM of each k-part is a closed k-ball;

3. the frontier of every k-part with 1 ≤ k ≤ d is the union of l-parts with 0 ≤ l < k; 16

(17)

4. every k-part with 0 ≤ k ≤ d − 1 is contained in the frontier of some (k + 1)-part; 5. every d − 1-part is incident to at most two d-parts;

6. no l-part with 0 ≤ l ≤ d − 2 of M is a local cutset of SM.

The collection of all k-parts for some 0 ≤ k ≤ d is denoted by Pk

M. We also call VM,

EM, FM, and CM the collections PM0 (of vertices), PM1 (of edges), PM2 (of faces) and PM3

(of cells), respectively.

If a d − 1-part p is incident to exactly one d-part, all parts in the closure of p are border parts. Every part that is not a border part is an internal part. We denote by VMB, EMB and FB

M the set of border vertices, edges and faces of M .

See Figure 2.1 for an example of a 2-map.

Figure 2.1: A map with a border vertex u, an internal vertex v, a border edge e and an internal edge f .

Figure 2.2 shows a partition of a topological space that is not a 2-map.

Figure 2.2: A partition of a topological space that is not a map. It has a vertex w that is a local cutset, two faces (A and B) whose frontiers are not homeomorphic to a 1-sphere (cycle), and a face C incident to only one edge whose closure is not homeomorphic to a closed 1-ball (a line segment).

We say that the degree of a k-part p, denoted by deg(p), is either the number of k − 1-parts incident to p, if k ≥ 2, or the number of k + 1-1-parts incident to p, if p is an edge or a vertex. The degree of a vertex v with respect to a d-part m, denoted by degm(v), is the number of edges incident to both v and m.

(18)

CHAPTER 2. DEFINITIONS AND NOTATIONS 18

The Euler characteristic of a d-map M is the number χ =Pd

k=0(−1)d−k|PMk |. It is a

topological property of SM [1]. In particular, χ = |FM| − |EM| + |VM| if d = 2, being (for

example) 2 for a 2-sphere or 0 for a torus. In the case of d = 3, χ = |CM| − |FM| + |EM| −

|VM|, being (for example) 0 for a 3-sphere or −1 for a 3-ball.

A d-map M is said to be convex if SM is a subset of some Cartesian space Rn, for

some n ≥ d, and the frontier of of every part p of M is the frontier of the convex hull of the vertices incident to p.

An isomorphism from a d-map M to a d-map N is an homeomorphism φ from SM to

SN such that the image of every part of M is a part of N .

2.1.3

Sub-map

A sub-map of a d-map M is a subset X of the d-parts of M , together with all (and only) the parts that are incident to those d-parts; it will be denoted by M [X]. A sub-map has all the defining properties of a d-map, except that its underlying space SM [X] may be

disconnected and may have some l-parts, with 0 ≤ l ≤ d − 2, that are local cutsets of SM [X]. The border d − 1-parts of M [X] are the d − 1-parts of M that are incident to only

one d-part of X. The border l-parts, with 0 ≤ l ≤ d − 2, of M [X] are the ones incident to those d − 1-parts.

If M0 = M [X] and Y ⊆ X, we say that M [Y ] is a sub-map of M0, also denoted by M0[Y ].

2.1.4

d-triangulation

A k-part p of a d-map M is said to be a k-simplex if it has k+1l+1 incident l-parts, for every 0 ≤ l < k. Furthermore, for k = d, there must be an isomorphism from M [p] to a convex d-map. In particular, a 2-simplex a triangle and a 3-simplex is a tetrahedron.

A d-triangulation T is a d-map where every k-part is a k-simplex. A d-sub-triangulation T [X] of a d-triangulation T is a d-sub-map of T .

2.1.5

Subdivision

A d-map N is said to be a subdivision of another d-map M if SN = SM and every k-part

p of M is the union of some subset Q of k-parts of N and some subset R of l-parts of N with 0 ≤ l < k. We say that p is subdivided or split into Q, by R.

2.1.6

Graph colorings

A vertex k-coloring λ for a graph G consists on an assignment of the k “colors” (labels) {0, 1, 2, . . . , k − 1} to the vertices of G in such a way that the endpoints of every edge have distinct colors. The color of a vertex v is represented by λ(v).

A edge k-coloring ζ for a graph G consists on an assignment of the k colors {0, 1, 2, . . . , k− 1} to the edges of G in such a way that, for every vertex v of G, the edges incident to v have distinct colors. The color of an edge e is represented by ζ(e).

(19)

2.1.7

Map coloring

The 1-skeleton graph of a map M is a graph G = {VG, EG}, where VG = VM, EG = EM,

and the incidence among vertices and edges of M is the same of G.

A k-coloring of a map M is a (vertex) k-coloring of its 1-skeleton graph. We also say that k-coloring a map turns a k-colorable map into a k-colored map.

A non-colorable map can be colored after it is properly subdivided into a k-colorable map.

2.1.8

The barycentric subdivision

The barycentric subdivision [2] of a d-map M is a standard map subdivision N of M that is a (d + 1)-colored d-triangulation. This subdivision is obtained by splitting k-parts of M into k-simplexes of N in ascending order of k (from 1 to d). Original vertices of M are colored with 0, and any new vertex of N inside a k-part of M is colored with k. Formally, the baricentric subdivision is the output of the following algorithm:

1. N ← VM.

2. For every vertex v of N , set λ(v) ← 0. 3. For every k from 1 to d do:

(a) For every k-part p of M do:

i. Let φ be the homeomorphism from the closure of p into the closed unit k-ball centered on 0.

ii. Let w be {φ−1(0)}. Add the vertex w to N . Set λ(w) ← k. iii. For every part q of N on the frontier of p do:

A. Let q0 be φ(q). Let q00 be the cone of q0, consisting of the points {αx : x ∈ q0∧ α ∈ (0, 1)}.

B. Let q000 be φ−1(q00). Add the set q000 to N .

Note that, just before a k-part p of M is split, its frontier in N is a k-colored (k − 1)-triangulation of a (k − 1)-sphere. Therefore, q and q0 are l-simplexes of N , with 0 ≤ l < k; q00 and q000 are (l + 1)-simplexes of N .

See again Figure 1.2b of Chapter 1 for an exemple of barycentric subdivision.

2.1.9

Map duality

Two borderless d-maps M, N on the same space are dual iff they have a common barycen-tric subdivision, except that the colors are complemented (a color k of the barycenbarycen-tric subdivision of M is changed to the color d − k of the barycentric subdivision of N , for every 0 ≤ k ≤ d).

(20)

CHAPTER 2. DEFINITIONS AND NOTATIONS 20

2.2

GEM

Vertex-colorable triangulations can be efficiently represented and manipulated by the GEM (Graph-Encoded Manifolds) data structure of Montagner and Stolfi [15, 14], based on the graph class of the same name created by Sóstenes Lins and Arnaldo Mandel [13].

2.2.1

GEM graph for triangulations

The (abstract) GEM of a (d + 1)-colored d-triangulation T is a graph G and an edge (d + 1)-coloring of G with the following properties:

1. Every vertex of G represents a d-simplex of T , and vice-versa.

2. Every edge e of G represents a (d − 1)-simplex t of T , and vice-versa.

(a) If t has two incident d-simplexes (t is an internal (d−1)-simplex), the endpoints of e represent those d-simplexes.

(b) If t has one incident d-simplex m (t is a border (d − 1)-simplex), e is a loop incident to the vertex represented by m.

(c) ζ(e) is the single color that does not appear among the d vertices incident to t. In particular, the GEM graph G for a borderless d-triangulation T is essentially the 1-skeleton graph of the dual map of T .

2.2.2

GEM data structure for triangulations

The GEM data structure is a computer representation of a GEM graph (and therefore a representation of a (d + 1)-colored d-triangulation).

The GEM data structure represents each vertex v of an edge (d + 1)-colored GEM graph G by a record r with (d + 1) pointer fields r.p[i], with 0 ≤ i ≤ d, corresponding to the (d + 1) colors. The field r.p[i] points to the record r0 that represents the vertex of G that is adjacent to v across the edge of color i (if that edge is a loop, then r.p[i] points to r). Consequently, r0.p[i] points to r.

See Figure 2.3 for an exemple of a simple 3-colored 2-triangulation and its GEM graph and data structure representation.

2 0 1 2 0 1 r0 r1 r2 r3 r0 r1 r2 r3 1 2 0 p[0] p[1] p[2] r0 r0 r1 r0 r1 r3 r0 r2 r2 r2 r2 r1 r3 r1 r3 r3 (a) (b) (c)

Figure 2.3: (a) A 3-colored 2-triangulation, (b) its respective GEM graph and (c) its respective GEM data structure.

(21)

2.2.3

GEM data structure for general maps

The GEM data structure can also be used to represent general d-maps if they are prop-erly subdivided into a (d + 1)-colored d-triangulation. The baricentric subdivision is the standard way to represent general maps by GEMs. However, more efficient subdivisions will be proposed in Chapters 3 and 4.

(22)

Chapter 3

3-Colored Triangulations of 2-Maps

3.1

Introduction

Consider the definitions of d-map on Chapter 2 applied for d = 2. For this Chapter, we will use map and triangulation to mean 2-map and 2-triangulation, respectively.

We describe a new algorithm to subdivide a map M into a triangulation T that is 3-colored. Colorable triangulations can be efficiently represented and manipulated by the GEM [2] data structure.

Recall that the barycentric subdivision [2] subdivides each edge of M into two new edges by a new vertex, and each face m of M into 2 deg(m) triangles, by 2 deg(m) new edges, and a new vertex. The barycentric subdivision is easily implemented, but always produces a triangulation T with 4|EM| − 2|EMB| triangles.

The new algorithm described in this Chapter generalizes our previous algorithm [6] (see later apendix in Section 3.8.2) that requires M to be a triangulation. This new algorithm is equivalent to the former one if the input is a triangulation. In particular, if M is already a 3-colorable triangulation, then T = M .

If M is a convex map, then T will also be a convex map. If the input faces are plane polygons, any non-convex faces may be split into convex polygons, e.g. by algorithm of Chazelle and Dobkin [8], before applying our algorithm, to ensure that T is still a convex map.

Our new algorithm is considerably more efficient than the barycentric subdivision: it yields a triangulation with at most 2|EM| − |EMB| + 2(2 − χ) triangles. If all faces of M

have the same degree D, the resulting triangulation has at most 2|EM| − |EMB| + 2(2 − χ) −

|FM| + (2(2 − χ) − |EMB|)/(D − 2) (= (D − 1)|FM| + 2(2 − χ) + (2(2 − χ) − |EMB|)/(D − 2))

triangles. These are only upper bounds. Experiments with certain classes of random maps (described in Section 3.6) show that the average size of the output is lower than the upper bound, especially for maps with faces with larger average degree.

A naive algorithm for the problem considered here would be (1) randomly subdivide the faces of M and (2) apply our previous algorithm [6] to the resulting triangulation. The triangulation resulting from step (1) would have L0(M ) = 2|EM| − 2|FM| − |EMB| +

k triangles, where k is the number of faces of M with degree 2. Therefore the final triangulation would have at least L0(M ) and at most U0(M ) = 4|EM| − 4|FM| − 3|EMB| +

2k + 4(2 − χ) triangles, which is better than the barycentric subdivision but worse than 22

(23)

the output of the new algorithm described in this Chapter.

3.2

The algorithm for 3-Colored triangulation

3.2.1

Overview

Our algorithm receives a map M as input, and outputs a triangulation T , that is a subdivision of M , and a 3-coloring for T .

The algorithm operates on one face of M at a time, splitting it into triangles, in such a way that the part of the triangulation that has already been processed is 3-colored.

In the description of the algorithm, we will denote by T0 the sub-triangulation of T that has already been built, and by M0 the remainder of M , that still remains to be processed. Consequently, SM0 ∪ ST0 = SM. Each vertex v of T0 has an assigned color

λ(v) ∈ {0, 1, 2}. See Figure 3.1 for an example where M is an uncolored triangulation.

(a) (b)

(c) (d)

Figure 3.1: Processing of a sample map M , showing the situation (a) just before, (b) during, and (c) just after the main loop of the 3-coloring algorithm, and (d) the final result T . The faces of T0 are in dark gray and those of M0 in light gray. The white square is a hole in SM.

While T0 is a valid sub-triangulation of T (as defined in Chapter 2), M0 is a sub-map of M , except that each edge of M in the border of SM0 may be subdivided into two edges

(24)

CHAPTER 3. 3-COLORED TRIANGULATIONS OF 2-MAPS 24

by one vertex.

We define the front as the set of vertices and edges shared by both M0 and T0. Every edge in the front lies between a face of M0 and a face of T0. The border edges of T0 or M0 are either contained in the border of SM, or are part of the front.

The map T0 is always connected once T0 has been initialized. This follows from the fact that the algorithm only processes a face m of M0 if m is incident to some edge in the front (that is already incident to a triangle of T0).

3.2.2

The extended dual graph

During the algorithm, the map M0 may become disconnected, but only if M has a border. The precise circumstances are important for the proofs of correctness and output efficiency (in particular Lemma 4). To specify them, we define the extended dual graph M0∗ = {VM0∗, EM0∗} that represents the connectivity of M0. The vertices of M0∗ are all the faces

of M0, plus a null vertex m∅ if M0 has any border edges of M . The edges of M0∗ are all

the internal edges of M0, plus the border edges of M0 that are also border edges of M . Each internal edge e of M0 connects in M0∗ the two vertices that are the incident faces of e in M0. Each border edge e0 of M0 that is a border edge of M connects in M0∗ the vertex m∅ to the vertex that is the face incident to e0 in M0. See Figure 3.2.

Figure 3.2: The extended dual graph corresponding to the situation of Figure 3.1(b). Throughout the algorithm, the graph M0∗ remains connected. Note that the vertex m∅

may provide a path between two connected components of M0, as long as each still has at least one border edge of M .

For implementation purposes, the M0∗ graph does not need to be explicetely stored, since it is essentially the dual of the unprocessed part M0 of the map, and most data structures used to represent maps, also represent their dual. The extra node m∅ can be

supplied “on the fly” by the procedures that use M0∗.

3.2.3

Detailed algorithm

(25)

1. Let M0 ← M and T0 ← {}. Choose any face m of M and P rocess(m).

2. While |VM0∗| ≥ 2:

(a) find a face m of M0 that is incident to at least one edge in the front, and whose removal will not disconnect the graph M0∗.

(b) do P rocess(m).

3. Let m be the last vertex of M0∗. If m 6= m∅, do P rocess(m).

T ← T0. Return T .

Each call of P rocess(m) removes the cell m from M0 and adds a colored triangulation of m and its frontier to T0, in such a way that T0 remains 3-colored. The parts on the frontier of m that are aleady in T0 (on the front) are not altered.

Formally, P rocess(m) consists of four steps: 1. Colorize(m)

2. S ← F aceSplit(m) 3. T0 ← T0∪ M0[S]

4. M0 ← M0[F

M0\ S]

During each call of P rocess(m) the following properties are verified:

1. After Colorize(m) is executed, all vertices of M0 incident to the face m will be colored. Any edge e of M that is incident to m will have been split into two edges of M0 by a new vertex if, and only if, the endpoints of e have the same color. No edge of M will be subdivided into more than two edges of M0.

2. After F aceSplit(m) is executed, m will have been subdivided into a set S of one or more triangles by new edges and at most one new vertex. A new vertex will be created inside m if, and only if, its incident vertices had only two colors on the entry of F aceSplit(m).

3.2.4

The Colorize procedure

The input of the Colorize procedure is a face m of M0. Its effect is to assign colors to every uncolored vertices incident to m so that λ is still a valid 3-coloring.

Through the procedure, we denote by c(0), c(1) and c(2) the number of vertices inci-dent to m with colors 0, 1 and 2, respectively.

1. For every edge e incident to m that is not in the front, if both of its incident vertices, u and v, are in the front and λ(u) = λ(v), split e into two edges by a new vertex w.

(26)

CHAPTER 3. 3-COLORED TRIANGULATIONS OF 2-MAPS 26

2. While there is some uncolored vertex u incident to m and some color i such that c(i) = 0, set λ(u) ← i.

3. Finally, for every uncolored vertex v incident to m, set λ(v) to any color such that λ is a 3-coloring for m. See Figure 3.3. Input Output

a

0 0 0 1 0 1 2 1 0 1

b

0 0 1 2 1 0 0 1 2 1 0 2 1 2

c

0 0 1 0 1 0 0 1 0 1 0 1 0 0 1 2

d

0 0 1 0 0 2 0 0 1 0 0 2 0 1 2

Figure 3.3: Examples of the Colorize procedure. The thick lines represent edges in the front.

Note that any vertex colored by the Colorize procedure is not in the front and therefore it is not a neighbor, in T0, of an other vertex of T0. Thus, in step 3, as long as λ is a 3-coloring for M0[m], it will also be a 3-coloring for M0[m] ∪ T0.

If there are multiple ways for assigning colors to vertices in step 3, the chosen way may affect the number of triangles in the final triangulation, but it does not affect the uppper bounds for |FT| derived in Section 3.4.1.

3.2.5

The FaceSplit procedure

The FaceSplit procedure is called after the Colorize procedure. Its input is a face m such that every two consecutive vertices along the frontier of m are colored with different colors.

During this procedure, the face m will progressively shrink and eventually disappear. Meanwhile, the procedure will build a set of triangles S that, together with new edges and vertices, will cover the original face m. The result of FaceSplit is the set S and a 3-coloring for M0[S].

As in Colorize, through the procedure, we denote by c(0), c(1) and c(2) the number of vertices in m with colors 0, 1 and 2, respectively.

1. If c(i) = 0 for any 0 ≤ i ≤ 2, split m into the set S of deg(f ) triangles, by a new vertex u inside m and a new edge between u and every vertex incident to m. Set λ(u) ← i. Return S.

(27)

2. Otherwise, while c(0) ≥ 2 and c(1) ≥ 2 and c(2) ≥ 2 do:

There must be a vertex v, incident to m, with neighbors u, w such that λ(v), λ(u) and λ(w) have three different colors. Split m into a face m0 and a triangle t, by a new edge between u and w. Add t into S and set m ← m0.

3. There must be a color i and a vertex u of m such that λ(u) = i and c(i) = 1. Split f into deg(f ) − 2 triangles by a new edge between u and every vertex incident to f not adjacent to u. Add the resulting triangles into S. Return S.

Figure 3.4 shows three examples for the FaceSplit procedure. M0[m] M0[S]

a

0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 2

b

0 1 2 1 2 0 1 2 0 1 2 1 2 0 1 2

c

0 1 0 1 2 1 0 1 0 1 0 1 2 1 0 1

Figure 3.4: Examples of the FaceSplit procedure, when the condition of the step 1 is satisfied (a), when the condition of the step 2 is satisfied at least once (b), and when only step 3 is executed (c).

3.2.6

Selecting the next face

Let Xm be, for every face m of M0, the set of edges and vertices incident to m that are

not in the front. For efficient implementation of step 2a of 2DTriangulate we maintain for each m a counter Nm. If m is incident to the front, then Nm is the number of

connected components of Xm. Otherwise, Nm = 0. Every time a vertex v is colored, Nm

is incremented for every face m ∈ M0 incident to v. Every time an edge e is added to the front, Nm is decremented for the face m ∈ M0 incident to e.

We also maintain a priority queue with all the faces m of M0 incident to at least one edge in the front. The queue has only two priorities: “high” and “low”. If Nm = 1, m

has high priority, otherwise m has low priority. In step 2a, the algorithm will only select a face with low priority if no face with high priority remains in the queue. The removal of any face with high priority from M0 does not disconnect M0∗, as we will see in the next section. If there are only low priority faces left, all faces m whose removal from M0 does not disconnect M0∗ are found by the depth-first search algorithm of Hopcroft and Tarjan [11]. As we will see in the next section, at least one of them is incident to the front and will be selected.

(28)

CHAPTER 3. 3-COLORED TRIANGULATIONS OF 2-MAPS 28

3.3

Correctness

3.3.1

General remarks

Throughout the execution of the algorithm, every time a face m is processed, the union of the parts that are removed from M0, including m itself and some of its incident vertices and edges, will be added to T0 if they are not there yet. The edges and vertices incident to m that are not removed from M0 will also be added to T0, updating the front.

The result S of the FaceSplit procedure, together with its incident edges and vertices, is always a triangulation and M0[S] ∪ T0 is a sub-triangulation of T . Except for step 1 of 2DTriangulate, m is incident to a border edge of T0 and therefore M0[S] ∪ T0 will be connected just after FaceSplit is executed. This connectivity is also true for step 1 since M0[S] ∪ T0 = M0[S]. Therefore, after the execution of step 3 of Process(m), T0 will be a connected sub-triangulation of T .

Any new vertex either splits an edge of M0 at step 1 of the Colorize procedure or is created inside m at step 1 of the FaceSplit procedure. Anyway, the result of these procedures are subdivisions of the original face.

Finally, the colors assigned to vertices incident to m, in steps 2 and 3 of the Colorize procedure or step 1 of the FaceSplit procedure, extend λ to a valid 3-coloring of T0.

Thus, after each face is processed, the properties described in the algorithm overview can be verified:

• the union of the parts of T0

and M0 is SM;

• the intersection of ST0 and SM0 (the front) consists only of edges and vertices of T0

and M0;

• T0 is a valid connected sub-triangulation of T ;

• M0 is a valid sub-map of M , except that each edge of M in the border of S

M0 may

be subdivided into two edges by a vertex; • T0 is a valid subdivision of a sub-map of M ;

• λ is a valid 3-coloring of T0.

Moreover, after the execution of step 3 of 2DTriangulate, M0 will have no faces and T0 will be a valid subdivision of M . Therefore, T will be a valid subdivision of M and λ will be a valid 3-coloring of T . Note that the algorithm terminates, because at each iteration the map M0 loses one face.

To prove the correctness of the algorithm it remains to be shown that there is always a face m that satisfies the conditions of step 2a of 2DTriangulate. This assertion is proved in Section 3.3.2.

(29)

3.3.2

Connectivity of M

0∗

Lemmas 1 and 2 and Corollary 1 below guarantee that, on every execution of step 2a of 2DTriangulate, there is a face m whose removal does not disconnect M0∗.

Given the implementation of step 2a detailed in Section 3.2.6 we must also prove that, for any face m of M incident to at least one edge in the front, if Nm = 1 then the removal

of m from M0 does not disconnect M0∗. Lemma 3 guarantees this.

Lemma 1. Before every execution of step 2a of 2DTriangulate the front has at least one edge.

Proof. Just before processing face m, at least one edge e incident to it is not in the border of T0. In step 1 of 2DTriangulate e can be any edge; in step 2b, the existence of such an edge follows from the condition |VM0∗| ≥ 2. Moreover, e will be in the border of T0 after

the execution of these steps, by construction of the FaceSplit procedure. Therefore, every execution of the steps 1 and 2b creates at least one new edge in the border of T0. Thus, before each iteration of step 2a the border of T0 is not empty.

Note that FM0 is not empty, because the main loop of the algorithm processes one

face of M0 at a time and stops if M0∗ is only {m∅} or if FM0 has only one face (in the case

that m∅ doesn’t exist). Since SM is connected, the two closed subsets ST0 and SM0 of SM

must have a non-empty intersection. Since FT0 and FM0 are disjoint and SM has no local

cutset points, the intersection must include at least one whole edge of M0, which is also an edge of T0. By definition, this edge must be part of the front.

For the next lemma we define VB

M0∗ as the set of vertices of M0∗ whose dual faces are

incident to at least one edge in the front.

Lemma 2. Let u∗ be a vertex of M0∗ and G be a connected component of M0∗ − u∗.

If G has at least one vertex in VB

M0∗ and doesn’t have the vertex m, then there must

be a vertex in both G and VB

M0∗ whose removal does not disconnect the induced subgraph

H = M0∗[VG∪ u∗].

Proof. The graph H must have at least two vertices (u∗ and a vertex in both G and VMB0∗).

H must also be connected. If H has exactly two vertices, u∗ and v∗ ∈ VB

M0∗ there is an

edge connecting them. The removal of v∗ doesn’t disconnect H and the lemma is true. Suppose by induction that the lemma is true for any k such that 2 ≤ |VH| < k. We

want to prove the lemma for |VH| = k.

Chose a vertex v∗ in both G and VMB0∗. If the removal of v∗ from G does not

dis-connect H, we are done. Otherwise H is the sum of two or more dis-connected subgraphs H1, H2, . . . , Hn, n ≥ 2 such that |VHi| ≥ 2 for any 1 ≤ i ≤ n, Hi ∩ Hj = v

for any 1 ≤ i < j ≤ n, u∗ ∈ VHn, and Sn i Hi = H. Note that u ∗ ∈ V/ H1. Let G1 be H1− v ∗.

We will show now that VG1 ∩ V

B M0∗ 6= ∅.

The graph G1 must have a vertex w∗ that is adjacent to v∗ in H1. Let w and v be the

dual faces of w∗ and v∗ in M0. The set of edges Ewvincident to both w and v must then be

part of the border B of the sub-map represented by G1 in M0. Also, B does not contain

(30)

CHAPTER 3. 3-COLORED TRIANGULATIONS OF 2-MAPS 30

from G or m∅ is u∗ itself. In either case, no vertices of G1 are incident m∅. Moreover, B

does not contain any internal edges of M0 except those of Ewv, since every vertex of M0∗

that is adjacent to a vertex of G1, except v∗, is also in G1. Therefore, every edge of B is

either incident to the face v or is an edge in the front. On the other hand, v is incident to a cycle of distinct vertices and distinct edges. That cycle contains at least one edge in the front. Thus, the edges and vertices incident to v that are not in the front do not form any cycle and therefore they cannot comprise all vertices and edges of B. It follows that B must contain at least one edge in the front incident to a face f different from v.

Note that |VG1| < |VG|, m∅ is not part of G1, G1 has at least one vertex f

in VB M0∗

and G1 is a connected component of M0∗− v∗. By induction hypothesis, there is a vertex

from VB

M0∗ whose removal does not disconnect H1. Consequently, its removal does not

disconnect H.

Corollary 1. Just before every execution of step 2a of 2DTriangulate, there is a face m of M0 that has an edge e in the front, whose removal from M0 does not disconnect the M0∗ graph.

Proof. VB

M0∗ cannot be empty due to Lemma 1. If m exists, let u∗ be m. Otherwise, if

there is a vertex of M0∗ that is not in VB

M0∗, let u∗ be that vertex. Otherwise, let u∗ be

any vertex of VB

M0∗. Since |VM0∗| ≥ 2, in all cases, there is a graph G that is a connected

component of M0∗− u∗ and that contains a vertex from VB

M0∗. G does not contain m∅. By

Lemma 2, there is a vertex in both VMB0∗ and G whose removal does not disconnect the

induced subgraph H = M0∗[VG∪ u∗].

If M0∗ − u∗ has only one connected component, H = M0∗ and the corollary is true.

Otherwise, M0∗ is the sum of two or more connected subgraphs with u∗, and only u∗, in common. One of these subgraphs is H. There is a path from any vertex of M0∗ outside H to a vertex in H passing through u∗. Therefore, M0∗ is not disconnected by removing a vertex that does not disconnect H and the corollary is true.

Lemma 3. The removal of any face m with Nm = 1 from M0 will never disconnect the

M0∗ graph.

Proof. Since Nm = 1, there is an alternating path {e0, v1, e1, v2, e2, . . . , vn, en} in M0 that

comprises all edges and vertices incident to m that are not in the front. For each vertex vi,

1 ≤ i ≤ n, there is an alternating cycle in M0∗Ci = {m∗, e∗i1, vi1∗, e∗i2, v∗i2, . . . , v∗i(ki−1), e

∗ iki, m

}

of vertices and edges whose primal in M0 are the faces and edges incident to vi. The

ver-tex m∗ is the dual of m, the vertex vi1∗ is the dual of the face incident to ei−1 and the

vertex vi(k

i−1) is the dual of the face incident to ei. The path Ci is a cycle because all

faces incident to vi are faces of M0 (note that m∅ is part of Ci if and only if vi is a border

vertex).

For every 1 ≤ i ≤ n − 1 note that vi(k

i−1) = v

(i+1)1. Therefore, inductively one can

see that there is a path P from v11 to vn(kn−1) that comprises all vertices and edges of all

(31)

Since all vertices adjacent to m∗ are vertices of P , the removal of m∗ does not disconnect M0∗ either.

3.3.3

Conclusion of proof

From the general remarks of Section 3.3.1 and the lemmas of Section 3.3.2, we conclude the following:

Theorem 1. For any map M , 2DTriangulate(M) returns a 3-colored triangulation T that is a subdivision of M .

3.4

Efficiency

3.4.1

Output upper bounds

We will prove two upper bounds U1(M ) and U2(M ) for the size |FT| of the output T of

2DTriangulate (M). Bound U1(M ) is defined for any map M as:

U1(M ) = 2(2 − χ) +

X

m∈FM

deg(m)

If the average degree of the faces is 4 or more, then U1(M ) is less than the upper bound

U0(M ) for the naive algorithm described in Section 3.1. Note that

P

m∈FMdeg(m) =

2|EM| − |EMB|.

Bound U2(M ) is defined only if all faces of M have the same degree D:

U2(M ) = (D − 1)|FM| + 2(2 − χ) +

2(2 − χ) − |EMB| D − 2 If all faces of M have the same degree D, then P

m∈FMdeg(m) = D|FM| and therefore

U2(M ) = U1(M ) − |FM| + (2(2 − χ) − |EMB|)/(D − 2). Usually U2(M ) ≤ U1(M ) (that is

always true for planar maps). Moreover, if D ≥ 4, then U2(M ) < U0. If D = 3, then

U0(M ) = U2(M ) = 2|FM| + 4(2 − χ) − |EMB|, which is the same upper bound given in [6].

For the following lemmas we define K as the number of faces of M0 that will have all its incident vertices already colored when the Colorize procedure is called.

Lemma 4 and Theorem 2 guarantee that U1(M ) is an upper bound for |FT|.

Lemma 4. For any map M , 2DTriangulate(M) returns a 3-colored triangulation T of M with at most |VM| + K + 2 − χ vertices.

Proof. Let’s consider the implementation of step 2a of 2DTriangulate described in Sec-tion 3.2.6. Also, we consider m = m0 and m = m00 for steps 1 and 3, respectively.

Note that all vertices of M are also vertices of T , so |VT| will be |VM| plus any new

vertices created.

Note also that step 1 of 2DTriangulate never creates a new vertex and step 3 creates at most one. Finally note that when Colorize(m00) is called, all vertices incident to m00 are already colored.

(32)

CHAPTER 3. 3-COLORED TRIANGULATIONS OF 2-MAPS 32

By inspection of the Colorize procedure, one can see that for any m selected by step 2a of 2DTriangulate, at most Nm new vertices are created. Moreover, if m has

at least one uncolored vertex when the Colorize procedure is called, at most Nm − 1

vertices are created. By inspection of both Colorize and FaceSplit procedures, one can see that for any m as input, if any vertex (either of M or a new one) is colored in Colorize procedure, no vertex will be crated in FaceSplit procedure. Therefore |VT| ≤

|VM| + K +

P

m∈{FM−m00−m0}(Nm− 1).

For each iteration of step 2a, since M0∗is connected, Xm 6= ∅, and since m has at least

one edge in the front, Xm does not comprise the whole frontier of m. Each component

of Xm has, then, n ≥ 1 edges and n − 1 vertices and therefore, |EXm| - |VXm| = Nm. For

step 1, Xm0 comprises the whole frontier of m0 and |EX

m0| - |VXm0| = 0. For step 3, if m

00

exists, Xm00 6= ∅ and |EX

m00| - |VXm00| = 0.

Let χT0 be the Euler characteristic of T0. Note that by removing m from M0 and adding

it in T0, without triangulating m, we have the same effect on the value of χT0 as removing

m from M0 and adding the triangulation S in T0, as noted by Process. Therefore, just after m is processed, χT0 will be increased or decreased, according to the Euler’s polyhedron

formula, by |Fm| + |VX| − |EX|, which is equal to 1 for steps 1 and 3 (if m00 exists) or

1 − Nm for step 2a. At the start of the execution of the algorithm χT0 = 0 and at the

end, χT0 = χ. We conclude that χ ≤ 2 +P

m∈{FM−m00−m0}(1 − Nm). But we also know

that |VT| ≤ |VM| + K +

P

m∈{FM−m00−m0}(Nm− 1).

With both equations we prove that |VT| ≤ |VM| + K + 2 − χ.

Theorem 2. For any map M , 2DTriangulate(M) returns a 3-colored triangulation T of M with at most U1 faces.

Proof. By Euler’s formula |VT| + |FT| − |ET| = |VM| + |FM| − |EM|. Since each edge

contributes twice for the degree of incident faces or incident holes along the border of the map, |VT| + |FT| − (3|FT| + |ETB|) 2 = |VM| + |FM| − (P m∈FM deg(m) + |E B M|) 2 We have that |EB

T| ≥ |EMB| and, by Lemma 4, |VT| ≤ |VM| + K + 2 − χ. Thus:

|FT| ≤ 2K + 2(2 − χ) +

X

m∈FM

deg(m) − 2|FM|

K cannot be more than |FM| itself and the lemma is proved.

Lemma 5 and Theorem 3 guarantee that U2(M ) is an upper bound for |FT| if all faces of

M have the same degree.

Lemma 5. If all faces of the input map M have the same degree D, 2K ≤ |FM| + (2(2 − χ) − |EMB|)/(D − 2).

(33)

Proof. The first face of M0 processed by the algorithm will require the coloring of all its incident vertices, which are also vertices of M . During the algorithm, K faces of M0 will not require any coloring. By the conditions of step 2a of 2DTriangulate, every processed face will require the coloring of at most D − 2 vertices of M . Therefore, by counting the number of vertices of M that will be colored, face by face, we have:

|VM| ≤ D + (|FM| − K − 1)(D − 2)

Each edge contributes twice for the degree of incident faces or incident holes along the border of the map. Also, |VM| = |EM| − |FM| + χ. Furthermore, |EM| = (D|FM| + |EMB|)/2

Thus:

D|FM| + |EMB|

2 − |FM| + χ ≤ (D − 2)(|FM| − K) + 2 After some algebraic manipulation:

2K ≤ |FM| +

2(2 − χ) − |EB M|

D − 2 and the lemma is proved.

Theorem 3. If all faces of the input map M have the same degree D, 2DTriangulate(M) returns a 3-colored triangulation T of M with at most U2 faces.

Proof. By Theorem 2:

|FT| ≤ 2K + 2(2 − χ) +

X

m∈FM

deg(m) − 2|FM|

Replacing 2K according to Lemma 5 and replacingP

m∈FMdeg(m) by D|FM|, the theorem

is proved.

The upper bounds U1 and U2 are not always achieved. The average |FT| can be much

less than these bounds, especially for maps with large average face degree. See Section 3.6 for more details.

3.4.2

Output lower bound for triangulations as input

Note that a triangulation is 3-colorable only if all internal vertices have even degree. This condition is in fact sufficient for planar triangulations [16]. Therefore, if all faces of M are triangles then, for each odd internal vertex, at least one edge incident to that vertex must be created during the execution of the algorithm. It follows that at least one additional triangle must be present in T (compared to M ) for each odd internal vertex. Thus, a lower bound for |FT| is L1(M ) = |FM| + |VMo |, where VMo is the set of odd internal vertices

(34)

CHAPTER 3. 3-COLORED TRIANGULATIONS OF 2-MAPS 34

3.4.3

Time complexity

The algorithm can be executed in O((3 − χ)|EM|) time. Therefore, for maps with the

same value of χ the algorithm runs in linear time with respect to |EM|.

Lemma 6 gives a bound for the execution of all steps of 2DTriangulate, except for step 2a.

Lemma 6. The execution of all iterations of step 2b in addition to the execution of steps 1 and 3 of 2DTriangulate can be done in O(|EM|) time.

Proof. Steps 1, 3 and every iteration of step 2b of 2DTriangulate process exactly one face m of M . At step 1, m can be any face of M and, at step 3, if m exists, it is the only face of M0. Therefore, the selection of m takes O(1) in these cases. At step 2b, m is the face previously selected by step 2a.

To process the face m the procedures Colorize and FaceSplit are called once each. If we prove that every edge incident to m is accessed a constant amount of time by both Colorize and FaceSplit procedures, since every edge of M is incident to one or two faces, the time complexity to process all faces of M is O(|EM|).

One can see that each step of the Colorize procedure can be computed by verifying every edge (and its incident vertices) incident to m once.

Each of the steps 1 and 3 of the FaceSplit procedure accesses every edge incident to m once.

The first iteration of step 2 of the FaceSplit procedure can identify all possible sets of three consecutive vertices with three different colors by verifying every edge (and its incident vertices) incident to m twice. Every time a triangle is created in step 2 of the FaceSplit procedure, a constant number of these sets are updated (those sets that contain some of the vertices incident to the triangle just created), each one in constant time.

Therefore both Colorize and FaceSplit procedures take O(|EM|) time to process all

faces and the lemma is true.

Now, we must show that the time complexity for all iterations of step 2a of 2DTrian-gulate is O((3 − χ)|EM|).

To achieve this goal consider the implementation defined in Section 3.2.6. Note that each face m will update Nm twice for each incident edge. Therefore the update of Nm for

all m ∈ M can be done in O(|EM|). The priority queue is updated in constant time.

Any face m ∈ M with Nm = 1 that is incident to at least one edge in the front is

found in O(1) and its removal does not disconnect the M0∗ graph. Therefore all these faces together are found in O(EM).

Since every iteration of 2DTriangulate after step 1 Nm ≥ 1, it remains to prove

Lemma 7 to complete the proof of time complexity.

Lemma 7. At most 2 − χ iterations of 2DTriangulate will process a face m with Nm > 1

that will not disconnect the M0∗ graph. All these faces together can be found in O((2 − χ)|EM|) time.

(35)

Proof. Let χT0 be the Euler Characteristic of T0 and let m0 and m00 be the faces processed

by steps 1 and 3 of 2DTriangulate. Processing m0 increases χT0 by one. If m00 exists,

processing it also increases χT0 by one. On the other hand, one can see that every

iteration of step 2b will decrease χT0 by 1 − Nm. Since every face processed is incident

to the front, Nm ≥ 1 and χT0 will never increase on any iteration of step 2b. At the

start of the execution of algorithm, χT0 = 0 and at the end χT0 = χ. Therefore, χ ≤

2 −P

m∈{FM\m00\m0}(Nm− 1). The number of processed faces with Nm > 1 will be no

more than the value of the later sum and thus at most 2 − χ.

If every face m incident to the front has Nm > 1, then all faces whose removal from

M0 does not disconnect M0∗ are found by the depth-first search algorithm of Hopcroft and Tarjan [11] in O(|EM0∗|) time. By Lemma 2, at least one of these faces is incident to

at least one edge in the front. Since |EM0∗| = |EM0|, each face of m with Nm > 1 that does

not disconnect M0∗ can be found in O(|EM0|). Therefore 2 − χ of these faces can be found

in O((2 − χ)|EM|) time.

Adding the execution of all steps of 2DTriangulate we prove Theorem 4. Theorem 4. The algorithm can be executed in O((3 − χ)|EM|) time.

3.5

Efficient face selection heuristic

Section 3.4 defines K as the number of faces of M0 that will have all its incident vertices already colored when the Colorize procedure is called. Lemma 4 proves that at most K + 2 − χ new vertices are created by the algorithm. The value of K is not a property of the map and can vary significantly depending on the order that the faces are processed. Figure 3.5 shows two orders of processing for the same input map. In the first example (top) K is almost equal to FM; and moreover, a new vertex is created for each face

that counts for K. Consequently, the size of the output is close to the upper bound. In the second example (bottom) K is zero and the algorithm creates no new vertices, so the number of triangles of the output will be the same as in a minimal uncolored triangulation of the map.

In this section we describe an heuristic for selecting the next face to be processed by the algorithm that tries to minimize K in the hope of minimizing the number of triangles of the output.

As described in Section 3.2.6, the algorithm maintains a priority queue with all the faces m of M0 incident to at least one edge in the front. To implement the heuristic we modify the queue so it has D priority levels instead of two, where D is the degree of the face of M with the largest degree. We also maintain, for each face m in the queue, a counter Um = |VXm| (the number of vertices of m not in the front). If a face m has

Nm = 1, its priority is D − Um, otherwise its priority is 1. For instance, if Nm = 1 and

all vertices of m are colored (Um = 0), m has the highest priority (D).

In step 2a of 2DTriangulate, the modified algorithm still selects one of the faces in the queue with the highest priority. If that priority is 1, then Nm > 1 and the algorithm

(36)

CHAPTER 3. 3-COLORED TRIANGULATIONS OF 2-MAPS 36

Figure 3.5: Effect of the processing order on the efficiency of the algorithm. The faces selected to be processed are numbered in increasing order in the input map at left. The output triangulation is at right.

must search for a face in the queue that does not disconnect M0∗, as usual. Otherwise the algorithm selects any face m with that priority (which has Nm = 1 and therefore does

not disconnect M0∗).

Insertion or deletion of a face in the queue still takes constant time. Finding a face m with highest priority in the queue takes O(deg(m)), and therefore finding all faces with highest priority throughout the execution of the algorithm takes O(|EM|) time. As before,

the update of Nm for all m ∈ M can be done in O(|EM|). Also, Um is decremented every

time Nm is incremented, except when a new vertex is created (and colored) during the

Colorize procedure. Therefore the updating of Um does not increase the time complexity

of the the algorithm, that still executes in O((3 − χ)|EM|) time.

3.5.1

Effectiveness for triangulations

In the particular case when M is a triangulation, then every face m in the queue will have at most one uncolored vertex. Of the |FM| − 1 faces that are removed from the

queue in steps 2b and 3 of 2DTriangulate, |FM| − 1 − K of them will result in one

additional vertex of M being colored. Since three vertices of M are colored in step 1, then |VM| − 3 = |FM| − 1 − K, which means that K = |FM| − |VM| + 2 and it doesn’t

depend on the choice of m in step 2b. Therefore the heuristic turns out to be ineffective in this particular case. This observation holds even if M has only faces of degree 2 or 3.

3.6

Experimental results

This section shows the result of some computer experiments. The goal of the experiments is to compare the actual average output size of the algorithm with the theoretical upper

(37)

and lower bounds, for some specific families of maps.

In all these experiments the average size of the output |FT| was found to be

substan-tially lower than the upper bound given in Section 3.4, especially for maps with faces with larger average degree.

In each experiment a number of random instances were generated from a specific family of maps. The size of each map was determined by a parameter n set to be approximately equal to |FM|. The values of n used by all experiments were 256, 512, 1024 and 2048.

For each value of n, we generated 100 maps and subdivided them by the algorithm. We also computed the average values |FM| and |FT| of the input and output sizes, as well

the average valuesL and U of some lower bound L(M ) and some upper bound U (M ) for |FT|.

We define the inefficiency index of the algorithm for one input map M by the formula: η(M ) = (|FT| − L)/(U − L). The value of η(M ) ranges from 0 to 1; the closer η(M ) is

to zero, the better. In particular, if η(M ) = 0, then |FT| is equal to the lower bound

L(M ) and therefore optimal. If η(M ) = 1, then |FT| is equal to the upper bound U (M ).

Note that the bounds are not tight, and therefore an optimum algorithm could have η(M ) > 0, and it may be impossible for η(M ) to be exactly 1 for any family of maps. We computed the average valueη and the standard deviation ˆη of η(M ). In our experiments, the standard deviation of the lower and upper bounds are negligible. Also, η(M ) has an approximately normal distribution (see Figure 3.6). Therefore, ˆη reflects mainly the variability of the algorithm’s output size.

Figure 3.6: Histogram of the inefficiency index η(M ) for random regular maps with D = 3 and |FM| = 2048 (η = 0.413). Random regular maps are detailed in Section 3.6.3.

3.6.1

Delaunay triangulations

In the first experiment, each input map was the Delaunay triangulation of a set of (n+2)/2 random sites with a two-dimensional normal distribution. The outer face was excluded, so the edges of the convex hull of the sites were border edges and χ was 1. In this experiment the parameter n turns out to be |FM| + |EMB|. We used for U (M ) the upper bound U2(M )

of Section 3.4.1, that for this experiment turns out to be 2|FM| − |EMB| + 4. For the

(38)

CHAPTER 3. 3-COLORED TRIANGULATIONS OF 2-MAPS 38

The face selection heuristic described in Section 3.5 was not used, since, as observed in Section 3.5.1, it is effective only for maps with at least some faces of degree higher than 3.

See the results in Table 3.1. Note that the average output size |FT| was approximately

1.5 ×|FM|, 1.2 × L, and about 1/3 of the way from the lower bound to the upper bound,

for all input sizes. The deviation ˆη of the inefficiency index is about 1/10 of the average η, which means that |FT| is usually close to |FT|.

Table 3.1: Experimental results for Delaunay triangulations as input maps. n |FM| |FT| |FT|/|FM| |FT|/L L U η ηˆ 256 246.4 368.5 1.49 1.20 306.6 487.3 0.343 0.059 512 501.8 750.6 1.50 1.20 624.9 997.5 0.337 0.042 1024 1012.9 1520.9 1.50 1.20 1263.4 2018.6 0.341 0.031 2048 2035.7 3064.3 1.50 1.21 2541.2 4063.0 0.344 0.020

3.6.2

Voronoi diagrams

In the second experiment, each input map was the Voronoi diagram of a set of n random sites with a two-dimensional normal distribution. The unbounded faces of the Voronoi diagrams were excluded, so that some edges were on the border and χ was 1. In this experiment, the parameter n turns out to be |FM| plus the number of unbounded faces.

We used for U (M ) the upper bound U1(M ) of Section 3.4.1, that for this experiment turns

out to be 2|EM| − |EMB| + 2. We chose the lower bound L(M ) as the number of triangles

of the minimal uncolored triangulation for M , that is L0(M ) = 2|EM| − 2|FM| − |EMB|.

We executed the algorithm with and without the heuristic described in Section 3.5 to show its importance. See the results in Tables 3.2 and 3.3. Note that, even without the heuristic, the average output size|FT| was about 3% higher than the average size of

the minimal uncolored triangulation L for all input sizes. However, the results with the heuristic were even better: |FT| was between 0.01% and 0.04% higher than L. With the

heuristic, the deviation ˆη of the inefficiency index is greater than the average η because η(M ) = 0 for most inputs.

Table 3.2: Experimental results for Voronoi diagrams as input maps, without the face selection heuristic. n |FM| |FT| |FT|/L L U η ηˆ 256 245.8 1235.9 1.03 1199.3 1651.8 0.081 0.016 512 501.1 2543.5 1.03 2466.1 3423.9 0.081 0.010 1024 1012.0 5162.4 1.03 5004.7 6978.8 0.080 0.009 2048 2035.1 10404.0 1.03 10091.6 14105.0 0.077 0.006

(39)

Table 3.3: Experimental results for Voronoi diagrams as input maps, using the face selec-tion heuristic. n |FM| |FT| |FT|/L L U η ηˆ 256 245.6 1204.3 1.0001 1204.1 1655.8 0.0003 0.0014 512 500.2 2473.1 1.0001 2472.8 3426.6 0.0003 0.0076 1024 1012.2 5031.0 1.0002 5030.1 7004.7 0.0005 0.0008 2048 2035.6 10146.7 1.0004 10142.6 14158.1 0.0010 0.0008

3.6.3

Random regular maps

In the third experiment, the goal was to test the algorithm for highly non-planar maps. Each input map was generated at random by the following procedure, whose input is the parameter n = |FM| and the degree D of the faces of M .

1. Let M be a set of n totally disconnected faces of degree D and their incident vertices and edges. (At this point, every edge of M is a border edge and |EB

M| = |EM|).

Assume that each edge is oriented so that each vertex has exactly one edge entering and one edge leaving.

2. Let X ← EMB. While |X| ≥ 2 do:

(a) Select two distinct random edges, e and f , from X. (b) Execute Join(M , e, f ) if allowed.

(c) Remove e and f from X.

During this procedure, X is a subset of the border edges of M . The procedure Join(M , e, f ) joins the face l incident to e to the face m incident to f . That is done by merging the border edges e and f with opposite orientation into one internal edge g incident to both l and m. The join is not allowed if it would create a loop or a bridge in the final map. In that case e and f will remain border edges in the final map M .

In contrast to the previous experiments, the final map M will not be necessarily planar, and its Euler characteristic χ might be less than 2. In fact, χ is expected to decrease linearly with |FM|. In our tests, none of the maps generated was planar.

We executed the algorithm for D = 3, D = 4, and D = 6. All executions included the heuristic described in Section 3.5. Although every face of the input map M has the same degree D, we still used for U (M ) the upper bound U1(M ) of Section 3.4.1, because the

value of χ decreases linearly with |FM| and therefore U1(M ) turns out to be a bit tighter

than U2(M ).

The maps generated by this procedure have large negative average value of χ and few vertices, most of them being border vertices. For D = 3, the number of odd internal vertices in M is frequently zero. Therefore, we used for L(M ) the lower bound L0(M ),

even for D = 3, since L0(M ) would be almost equal to L1(M ).

See the results in Tables 3.4, 3.5 and 3.6. Note that the average inefficiency η was about 0.40, 0.36 and 0.32 for n = 2048 respectively. The coloring of random maps usually requires more colors than the coloring of planar maps, so L(M ) is expected to

(40)

CHAPTER 3. 3-COLORED TRIANGULATIONS OF 2-MAPS 40

be much lower than the actual lower bound (size of the smallest 3-colored triangulation that is a subdivision of M ). Therefore the inefficiency index for this experiment might be overestimated.

Table 3.4: Experimental results for random regular maps with D = 3.

|FM| |FT| χ |FT|/L L U η ηˆ

256 515.9 -106.5 2.01 256 985.0 0.356 0.030 512 1081.1 -225.7 2.11 512 1991.4 0.385 0.018 1024 2208.1 -469.4 2.16 1024 4014.8 0.396 0.013 2048 4538.6 -965.1 2.22 2048 8078.9 0.413 0.009

Table 3.5: Experimental results for random regular maps with D = 4.

|FM| |FT| χ |FT|/L L U η ηˆ

256 841.2 -230.9 1.64 512 1489.6 0.337 0.020 512 1726.4 -477.5 1.69 1024 3007.1 0.354 0.013 1024 3482.3 -975.4 1.70 2048 6050.9 0.358 0.010 2048 7050.7 -1979.4 1.72 4096 12154.7 0.367 0.007

Table 3.6: Experimental results for random regular maps with D = 6.

|FM| |FT| χ |FT|/L L U η ηˆ

256 1465.0 -480.3 1.43 1024 2500.7 0.299 0.018 512 2975.4 -981.5 1.45 2048 5039.0 0.310 0.013 1024 6013.4 -1988.3 1.47 4096 10124.6 0.318 0.008 2048 12142.3 -4013.8 1.48 8192 20319.7 0.326 0.006

3.6.4

Random irregular maps

In the fourth experiment, each input map was generated at random like in the previous experiment, except that each face of M had a random degree, that varied from 3 to 9 with uniform probability (so the average degree was 6). We used for U (M ) the upper bound U1(M ) of Section 3.4.1, and for L(M ) the lower bound L0(M ).

See the results in Table 3.7.

3.7

Conclusions

We described a linear time algorithm to subdivide a 2-map into a 3-colored triangula-tion, that can be represented by the GEM data structure. The output efficiency of such algorithm can be quantified by the number of faces in the output triangulation. We proved some upper bounds for the efficiency of our algorithm that are tighter than that of the barycentric subdivision. Experimental results showed even better results than the theoretical upper bounds.

Referências

Documentos relacionados

FEDORA is a network that gathers European philanthropists of opera and ballet, while federating opera houses and festivals, foundations, their friends associations and

Na hepatite B, as enzimas hepáticas têm valores menores tanto para quem toma quanto para os que não tomam café comparados ao vírus C, porém os dados foram estatisticamente

Com ela procurámos chegar a um sistema de informação pedagógica orientado para a comunicação, formal e informal, simples de usar e criar aproveitando muitos dos conceitos que todos

Os dados encontrados em nosso estudo de- monstram que os músculos bíceps femoral, semi- tendinoso e semimembranoso participaram duran- te o movimento de fl exão do joelho realizado em

From the unique identifiers of workers and establishments, we construct a large longitudinal data base that allows us to include various types of fixed effects to examine

The probability of attending school four our group of interest in this region increased by 6.5 percentage points after the expansion of the Bolsa Família program in 2007 and

Este relatório relata as vivências experimentadas durante o estágio curricular, realizado na Farmácia S.Miguel, bem como todas as atividades/formações realizadas

NÓS E OS OUTROS EM/COM QUEM HABITAMOS Na atual sociedade do conhecimento, pautada por encontros inesperados com as mudanças da era digital e cimentada por múltiplas incertezas,