# The Geodesic Diameter of Polygonal Domains

- 332 Downloads
- 4 Citations

## Abstract

This paper studies the geodesic diameter of polygonal domains having \(h\) holes and \(n\) corners. For simple polygons (i.e., \(h=0\)), the geodesic diameter is determined by a pair of corners of a given polygon and can be computed in linear time, as shown by Hershberger and Suri. For general polygonal domains with \(h \ge 1\), however, no algorithm for computing the geodesic diameter was known prior to this paper. In this paper, we present the first algorithms that compute the geodesic diameter of a given polygonal domain in worst-case time \(O(n^{7.73})\) or \(O(n^7 (\log n + h))\). The main difficulty unlike the simple polygon case relies on the following observation revealed in this paper: two interior points can determine the geodesic diameter and in that case there exist at least five distinct shortest paths between the two.

## Keywords

Polygonal domain Shortest path Geodesic diameter Exact algorithm Convex function Lower envelope## 1 Introduction

A *polygonal domain* \(\mathcal{P }\) with \(h\) holes and \(n\) corners is a connected and closed subset of \(\mathbb R ^2\) having \(h\) holes whose boundary consists of \(h+1\) simple closed polygonal chains of \(n\) total line segments. Given a polygonal domain \(\mathcal{P }\), the geodesic distance \({\hbox {d}}(p,q)\) between two points \(p\) and \(q\) of \(\mathcal{P }\) is defined as the length of a shortest path that connects \(p\) and \(q\) and stays within \(\mathcal{P }\).

This paper addresses the geodesic diameter problem in polygonal domains having one or more holes. The geodesic diameter \({\hbox {diam}}(\mathcal{P })\) of domain \(\mathcal{P }\) is defined as the largest possible geodesic distance between any two points of \(\mathcal{P }\), that is, \({\hbox {diam}}(\mathcal{P }) = \max _{s,t \in \mathcal{P }} {\hbox {d}}(s,t)\).

For simple polygons (i.e., domains with no hole), the geodesic diameter has been extensively studied. Chazelle [7] provided the first \(O(n^2)\)-time algorithm computing the geodesic diameter of a simple polygon. Afterwards, Suri [20] presented an \(O(n\log n)\)-time algorithm that solves the all-geodesic-farthest neighbors problem, computing the farthest neighbor of every corner and thus finding the geodesic diameter. At last, Hershberger and Suri [12] showed that the diameter can be computed in linear time using fast matrix search techniques.

On the other hand, the geodesic diameter of a domain having one or more holes is less understood. Mitchell [16] has posed an open problem asking an algorithm for computing the geodesic diameter of a polygonal domain. However, even for the corner-to-corner diameter \(\max _{u,v\in V} {\hbox {d}}(u,v)\), where \(V\) denotes the set of corners of \(\mathcal{P }\), we know nothing better than a brute-force algorithm that takes \(O(n^2\log n)\) time, checking all the geodesic distances between every pair of corners.^{1} Prior to our results, there was no known algorithm for computing the geodesic diameter in domains with holes. We should also mention that Koivisto and Polishchuk [14] had claimed an improved algorithm after a preliminary report of our work [6], but it was shown to be a failed trial through conversations with the authors.^{2}

The status of the geodesic center problem is also similar. A point in \(\mathcal{P }\) is defined as a *geodesic center* if it minimizes the maximum geodesic distance from it to any other point of \(\mathcal{P }\). Asano and Toussaint [3] introduced the first \(O(n^4\log n)\)-time algorithm for computing the geodesic center of a simple polygon (i.e., when \(h=0\)), and Pollack et al. [19] improved it to \(O(n\log n)\) time. As with the diameter problem, there is no known algorithm for domains with holes. See O’Rourke and Suri [18] and Mitchell [16] for more references on the geodesic diameter/center problem.

Since the geodesic diameter/center of a simple polygon is determined by its corners, one can exploit the *geodesic farthest-site Voronoi diagram* of the set \(V\) of corners to compute the diameter/center, which can be built in \(O(n \log n)\) time [2]. Recently, Bae and Chwa [4] presented an \(O(nk \log ^3 (n+k))\)-time algorithm for computing the geodesic farthest-site Voronoi diagram of \(k\) sites in polygonal domains with holes. This result can be used to compute the geodesic diameter \(\max _{p,q\in S} {\hbox {d}}(p,q)\) of a *finite* set \(S\) of points in \(\mathcal{P }\). However, this approach cannot be directly used for computing \({\hbox {diam}}(\mathcal{P })\) without any characterization of the diameter. Moreover, when \(S=V\), this approach is no better than the brute-force \(O(n^2 \log n)\)-time algorithm for computing the corner-to-corner diameter \(\max _{u,v \in V}{\hbox {d}}(u,v)\).

In this paper, we present the first algorithms that compute the geodesic diameter of a given polygonal domain in \(O(n^{7.73})\) or \(O(n^7(\log n + h))\) time in the worst case. Our new geometric results underlying the algorithms show that the existence of any diametral pair consisting of non-corner points implies multiple shortest paths between the pair; among other results, we show that *if* \((s,t)\) *is a diametral pair and both* \(s\) *and* \(t\) *lie in the interior of* \(\mathcal{P }\), *then there are at least five shortest paths between* \(s\) *and* \(t\).

Some analogies between polygonal domains and convex polytopes in \(\mathbb R ^3\) can be seen. O’Rourke and Schevon [17] proved that if the geodesic diameter on a convex \(3\)-polytope is realized by two non-corner points, then at least five shortest paths exist between the two; see also Zalgaller [21] for simpler arguments. Based on this observation, they presented an \(O(n^{14} \log n)\)-time algorithm for computing the geodesic diameter on a convex \(3\)-polytope. Afterwards, the time bound was improved to \(O(n^8\log n)\) by Agarwal et al. [1] and recently to \(O(n^7 \log n)\) by Cook IV and Wenk [9].

The rest of the paper is organized as follows: after introducing preliminary definitions and concepts in Sect. 2, we investigate local maxima of the lower envelope of convex functions in Sect. 3, resulting in Theorem 1. Section 4 extensively exploits the intermediate result to show lower bounds on the number of shortest paths between a diametral pair for every possible case, and then Sect. 5 describes our algorithms for the geodesic diameter. We finally conclude the paper with a summary, some remarks, and open issues in Sect. 6. Also, we exhibit several examples that cover all possible combinatorial cases in Appendix 1.

## 2 Preliminaries

Throughout the paper, we frequently use several topological concepts such as open and closed subsets, neighborhoods, and the boundary \(\partial A\) and the interior \({\text {int}}\, A\) of a set \(A\); unless stated otherwise, all of them are supposed to be derived with respect to the standard topology on \(\mathbb R ^d\) with the Euclidean norm \(\Vert \cdot \Vert \) for fixed \(d\ge 1\). We also denote the straight line segment joining two points \(a, b\) by \(\overline{ab}\).

*polygonal domain*\(\mathcal{P }\) with \(h\) holes and \(n\) corners

^{3}is a connected and closed subset of \(\mathbb R ^2\) with \(h\) holes whose boundary \(\partial \mathcal{P }\) consists of \(h+1\) simple closed polygonal chains of \(n\) total line segments. The boundary \(\partial \mathcal{P }\) of a polygonal domain \(\mathcal{P }\) is regarded as a series of

*obstacles*so that any feasible path in \(\mathcal{P }\) is not allowed to cross \(\partial \mathcal{P }\). The

*geodesic distance*\({\hbox {d}}(p,q)\) between any two points \(p,q\) in a polygonal domain \(\mathcal{P }\) is defined as the length of a shortest feasible path between \(p\) and \(q\), where the

*length*of a path is the sum of the Euclidean lengths of its segments. It is well known from earlier work [15] that there always exists a shortest feasible path between any two points \(p, q \in \mathcal{P }\), and thus the geodesic distance function \({\hbox {d}}(\cdot , \cdot )\) is well defined. The geodesic diameter \({\hbox {diam}}(\mathcal{P })\) of a polygonal domain \(\mathcal{P }\) is defined as the largest geodesic distance between any two points of \(\mathcal{P }\), that is,

*diametral pair*.

*Shortest Path Map.* Let \(V\) be the set of all corners of \(\mathcal{P }\) and \(\pi (s,t)\) be a shortest path between \(s\in \mathcal{P }\) and \(t\in \mathcal{P }\). Such a path \(\pi (s,t)\) is represented as a sequence \(\pi (s,t) = (s, v_1, \ldots , v_k, t)\) for some \(v_1, \ldots , v_k\in V\); that is, a polygonal chain through a sequence of corners [15]. Note that we can have \(k=0\) when \({\hbox {d}}(s,t)=\Vert s-t\Vert \). If two paths (with possibly different endpoints) have the same sequence of corners \((v_1, \ldots , v_k)\), then they are said to have the same *combinatorial structure*.

The *shortest path map* \(\mathsf{SPM }(s)\) for a fixed \(s\in \mathcal{P }\) is a decomposition of \(\mathcal{P }\) into cells such that every point in a common cell can be reached from \(s\) by shortest paths of the same combinatorial structure. Each cell \(\sigma _s(v)\) of \(\mathsf{SPM }(s)\) is associated with a corner \(v\in V\) which is the last corner of \(\pi (s,t)\) for any \(t\) in the cell \(\sigma _s(v)\). We also define the cell \(\sigma _s(s)\) as the set of points \(t\in \mathcal{P }\) such that \(\pi (s,t)\) passes through no corner of \(\mathcal{P }\), so \(\pi (s,t) = \overline{st}\). Each edge of \(\mathsf{SPM }(s)\) either belongs to \(\partial \mathcal{P }\) or is an arc on the boundary of two incident cells \(\sigma _s(v_1)\) and \(\sigma _s(v_2)\) determined by two corners \(v_1,\, v_2 \in V\cup \{s\}\). Similarly, each vertex of \(\mathsf{SPM }(s)\) is a vertex of \(\mathcal{P }\) or is determined by at least three distinct corners \(v_1,\,v_2,\,v_3 \in V \cup \{s\}\).

Note that, for fixed \(s\in \mathcal{P }\), a point farthest from \(s\) lies at either (1) a vertex of \(\mathsf{SPM }(s)\), (2) an intersection between the boundary \(\partial \mathcal{P }\) and an edge of \(\mathsf{SPM }(s)\), or (3) a corner in \(V\). The shortest path map \(\mathsf{SPM }(s)\) has \(O(n)\) total number of cells, edges, and vertices and can be computed in \(O(n\log n)\) time using \(O(n\log n)\) working space [13]. For more details on shortest path maps, see [13, 15, 16].

*Path-Length Function.* If \(\pi (s,t) \ne \overline{st}\), then there are two corners \(u,v\in V\) such that \(u\) and \(v\) are the first and last corners along \(\pi (s,t)\) from \(s\) to \(t\), respectively. Here, the path \(\pi (s,t)\) is formed as the union of \(\overline{su},\,\overline{vt}\) and a shortest path \(\pi (u,v)\) from \(u\) to \(v\). Note that \(u\) and \(v\) are not necessarily distinct. In order to realize such a path, we assert that \(s\) is visible from \(u\) and \(t\) is visible from \(v\). That is, \(s\in \mathsf{VR }(u)\) and \(t\in \mathsf{VR }(v)\), where \(\mathsf{VR }(p)\) for any \(p\in \mathcal{P }\) is defined to be the set of all points \(q\in \mathcal{P }\) such that \(\overline{pq}\subset \mathcal{P }\), also called the *visibility region* of \(p\in \mathcal{P }\).

*path-length function*\({\text {len}}_{u,v}:\mathsf{VR }(u)\times \mathsf{VR }(v) \rightarrow \mathbb R \) for any fixed pair of corners \(u,v\in V\) to be

## 3 Local Maxima of the Lower Envelope of Convex Functions

In this section, we give a property of the lower envelope of a family of convex functions which will afterwards be used in our geodesic diameter environment. We start with a basic observation on the intersection of hemispheres on a unit hypersphere in the \(d\)-dimensional space \(\mathbb R ^d\). For any fixed positive integer \(d\), let \({S}^{d-1}:=\{x \in \mathbb R ^d \mid \Vert x\Vert = 1\}\) be the unit hypersphere in \(\mathbb R ^d\) centered at the origin. A *closed* (or *open*) *hemisphere* on \(S^{d-1}\) is defined to be the intersection of \(S^{d-1}\) and a closed (open, respectively) half-space of \(\mathbb R ^d\) bounded by a hyperplane that contains the origin.

We call a \(k\)-dimensional affine subspace of \(\mathbb R ^d\) a \(k\)-*flat*. Note that a hyperplane in \(\mathbb R ^d\) is a \((d-1)\)-flat and a line in \(\mathbb R ^d\) is a \(1\)-flat. Also, the intersection of \(S^{d-1}\) and a \(k\)-flat through the origin in \(\mathbb R ^d\) is called a *great* \((k-1)\)-*sphere* on \(S^{d-1}\). Note that a great 1-sphere is called a great circle and a great 0-sphere consists of two antipodal points.

### **Lemma 1**

For any two positive integers \(d\) and \(m\le d\), a set of any \(m\) closed hemispheres on \(S^{d-1}\) has a nonempty common intersection. Moreover, if the intersection has an empty interior relative to \(S^{d-1}\), then it includes a great \((d-m)\)-sphere on \(S^{d-1}\).

### *Proof*

We only give a proof for the second statement, which implies the first. The case of \(d=1\) is trivial, so we assume \(d>1\). Let \(H_1,\ldots , H_m\) be any \(m\) closed hemispheres on \(S^{d-1}\), and \(h_i\) be the hyperplane through the origin in \(\mathbb R ^d\) such that \(H_i\) lies in a closed half-space supported by \(h_i\). In this proof, we denote by \({\mathop {H}\limits ^{\frown }_i}\) the open hemisphere, defined to be \({\mathop {H}\limits ^{\frown }}_i\) \(= H_i \setminus h_i\). Also, let \(\mathcal{H }_j := \bigcap _{1\le i \le j} H_i\) and \({\mathop {\mathcal{H }}\limits ^{\frown }}\) \(_j := \bigcap _{1\le i \le j}\) \({\mathop {H}\limits ^{\frown }}_i\).

Suppose that \({\mathop {\mathcal{H }}\limits ^{\frown }}\) \(_m = \emptyset \). Let \(k\) be the smallest integer such that \({\mathop {\mathcal{H }}\limits ^{\frown }}\) \(_k = \emptyset \). By definition, \(k \ge 2\) and \({\mathop {\mathcal{H }}\limits ^{\frown }}\) \(_{k-1} \ne \emptyset \). Note that the intersection of any \(k-1\) non-parallel hyperplanes of \(\mathbb R ^d\) includes a \((d-k+1)\)-flat and each \(h_i\) contains the origin. Hence, \(\bigcap _{1\le i\le k-1} h_i\) includes a \((d-k+1)\)-flat through the origin and thus \(\mathcal H _{k-1}\) includes a great \((d-k)\)-sphere \(G\) on \(S^{d-1}\). Since \(x\in G\) implies \(-x \in G\) for any \(x\in S^{d-1}\), we must have \(G \subseteq h_k\), in order to have an empty intersection \({\mathop {\mathcal{H }}\limits ^{\frown }}\) \(_k\). This implies that \(\bigcap _{1\le i\le k} h_i\) also includes a \((d-k+1)\)-flat through the origin, and further that \(\bigcap _{1\le i\le m} h_i\) includes a \((d-m+1)\)-flat through the origin. We hence conclude that \(\mathcal H _m = \bigcap _{1\le i \le m} H_i\) includes a great \((d-m)\)-sphere on \(S^{d-1}\). \(\square \)

Using Lemma 1 we prove the following theorem.

### **Theorem 1**

For any fixed positive integer \(d\), let \(\mathcal F \) be a finite family of real-valued convex functions defined on a convex subset \(C\subseteq \mathbb R ^d\) and \(g(x):= \min _{f \in \mathcal F } f(x)\) be their pointwise minimum. Suppose that \(g\) attains a local maximum at \(x^* \in C\) and there are exactly \(m \le d\) functions \(f_1,\ldots ,f_m \in \mathcal F \) such that \(f_i(x^*)=g(x^*)\) for each \(i=1,\ldots ,m\). Then there exists a \((d+1-m)\)-flat \(\varphi \subset \mathbb R ^d\) through \(x^*\) such that \(g\) is constant on \(\varphi \cap U\) for some neighborhood \(U \subset \mathbb R ^d\) of \(x^*\) with \(U\subset C\).

### *Proof*

First, we give an overview of our proof for the theorem. All functions \(f \in \mathcal F \) other than \(f_1,\ldots , f_m\) must satisfy \(f(x)>g(x)\) in a small neighborhood of \(x^*\). In particular, the function \(g\) is the lower envelope of the \(m\) convex functions \(f_i\) in a small neighborhood of \(x^*\). By convexity, we will show that for each \(i\), there is a hemisphere \(H_i\) of directions in \(S^{d-1}\) in which \(f_i\) does not decrease. (Note that the sphere \(S^{d-1}\) represents the space of all directions in \(\mathbb R ^d\).) This result combined with Lemma 1 gives that the intersection of hemispheres will be a \((d+1-m)\)-flat in which neither of the \(m\) functions (nor \(g\)) can decrease. Since \(x^*\) is a local maximum of \(g\), the only possibility is that \(g\) remains constant near \(x^*\) along the flat.

A more detailed proof is given as follows. Let \(x^* \in C\) and \(f_1, \ldots , f_m \in \mathcal F \) be as in the statement. For each \(i\), consider the sublevel set \(L_i := \{ x \in C \mid f_i(x) \le f_i(x^*) \}\). Here, we consider two cases: (i) \(x^*\) lies in the interior of \(L_i\) or (ii) on its boundary \(\partial L_i\). Note that \(L_i \subseteq C\) is convex since \(f_i\) is a convex function. For the latter case (ii), there exists a supporting hyperplane \(h_i\) to \(L_i\) at \(x^*\) since \(L_i\) is convex and \(x^* \in \partial L_i\). Denote by \(h_i^\oplus \) the closed half-space that is bounded by \(h_i\) and does not contain \(L_i\). For the former case (i), we choose \(h_i\) to be any hyperplane of \(\mathbb R ^d\) through \(x^*\) and \(h_i^\oplus \) to be any closed half-space supported by \(h_i\). Then we have that \(f_i(x^*) \le f_i(x)\) for any \(x\in h_i^\oplus \cap C\), regardless of the cases; in particular for Case (i), observe that \(f_i(x) = f_i(x^*)\) for any \(x\in L_i\) by convexity so that we can choose any hyperplane as \(h_i\).

## 4 Properties of Geodesic-Maximal Pairs

We call a pair \((s^*,t^*) \in \mathcal{P }\times \mathcal{P }\) *maximal* if \((s^*,t^*)\) is a local maximum of the geodesic distance function \({\hbox {d}}\). That is, \((s^*,t^*)\) is maximal if and only if there are two neighborhoods \(U_s, U_t \subset \mathbb R ^2\) of \(s^*\) and of \(t^*\), respectively, such that for any \(s \in U_s\cap \mathcal{P }\) and any \(t\in U_t \cap \mathcal{P }\) we have \({\hbox {d}}(s^*, t^*) \ge {\hbox {d}}(s,t)\). Clearly, any diametral pair is maximal.

Let \(E\) be the set of all sides of \(\mathcal{P }\) without their endpoints and \(\mathcal B \) be their union. Note that \(\mathcal B = \partial \mathcal{P }\setminus V\) is the boundary of \(\mathcal{P }\) except the corners \(V\). The goal of this section is to prove the following theorem, which is the main combinatorial result of this paper.

### **Theorem 2**

Together with the bound \(|\Pi (s^*, t^*)| \ge |\mathcal{V }(s^*,t^*)|\), Theorem 2 immediately implies tight lower bounds on the number of shortest paths between any maximal pair.

### **Corollary 1**

To see the tightness of the bounds, we present examples with remarks in Fig. 1 and Appendix 1. In particular, one can easily see the tightness of the bounds on \(|V_{s^*}|\) and \(|V_{t^*}|\) from shortest path maps \(\mathsf{SPM }(s^*)\) and \(\mathsf{SPM }(t^*)\), when \(V \cup \{s^*,t^*\}\) is in general position.

We first give an overview of the proof. The general reasoning is roughly the same for all the different scenarios, and we thus focus on the case in which \((s^*,t^*)\) is a maximal pair and both \(s^*\) and \(t^*\) are interior points (Case (I-I)). Regard the geodesic distance function \({\hbox {d}}\) as a four-variate function in a small convex neighborhood of \((s^*,t^*)\). As mentioned in Sect. 2, the geodesic distance is the pointwise minimum of a finite number of path-length functions. Since the pair \((s^*,t^*)\) is maximal, we will apply Theorem 1 and obtain that the geodesic distance is constant in a flat of dimension \(d+1-m=5-m\), where \(m = |\mathcal{V }(s^*, t^*)|\). On the other hand, we will also show that the geodesic distance function can only remain constant in a zero-dimensional flat (i.e., at a point), hence \(m\ge 5\). In the other cases (boundary–interior, boundary–boundary, etc.) the boundary of \(\mathcal{P }\) introduces additional constraints that reduce the degrees of freedom of the geodesic distance function. Hence, fewer paths are enough to *pin* the solution.

The main technical difficulty of the proof is the fact that the path-length functions \({\text {len}}_{u,v}\) are not globally defined. Thus, we must properly extend them in a way that all conditions of Theorem 1 are satisfied.

### 4.1 Proof of Theorem 2

We start with several basic observations. The proof of Theorem 2 will be done separately for each case.

The following lemma proves the bounds on \(|V_{s^*}|\) and \(|V_{t^*}|\) of Theorem 2.

### **Lemma 2**

- 1.
If \(t^*\in \mathcal B \), then \(|V_{t^*}|\ge 2\). Moreover, if \(t^*\in e \in E\), then there exists \(v \in V_{t^*}\) such that \(v\) is off the line supporting \(e\).

- 2.
If \(t^*\in {\text {int}}\,\mathcal{P }\), then \(|V_{t^*}|\ge 3\) and \(t^*\) lies in the interior of the convex hull of \(V_{t^*}\).

### *Proof*

Since \((s^*,t^*)\) is a maximal pair, the function \(d_{s^*}(t):={\hbox {d}}(s^*,t)\) is maximized at \(t=t^*\) on a sufficiently small subset \(U \subset \mathcal{P }\) with \(t^*\in U\). As discussed in Sect. 2, if \(t^*\notin V\), then \(t^*\) must be either a vertex of \(\mathsf{SPM }(s^*)\) or an intersection point between an edge of \(\mathsf{SPM }(s^*)\) and \(\partial \mathcal{P }\). If \(t^*\in {\text {int}}\,\mathcal{P }\), then \(t^*\) should fall into the former case and hence we have at least three corners \(v_1,\,v_2,\,v_3 \in V\) determining the vertex \(t^*\) of \(\mathsf{SPM }(s^*)\). If \(t^* \in \mathcal B \), then \(t^*\) may also occur at the latter case. In that case, \(t^*\) lies on an edge of \(\mathsf{SPM }(s^*)\) and thus we have at least two corners \(v_1,\,v_2 \in V\) determining an edge of \(\mathsf{SPM }(s^*)\).

The other claims of the lemma can be shown as follows. If \(t^* \in {\text {int}}\,\mathcal{P }\) but \(t^*\) lies out of the interior of the convex hull of \(V_{t^*}\), then we can find another point \(t \in \mathcal{P }\) arbitrarily close to \(t^*\) such that \(\Vert t-v_i\Vert > \Vert t^*-v_i\Vert \) for every \(v_i\in V_{t^*}\). This implies that \({\hbox {d}}(s^*,t) > {\hbox {d}}(s^*,\, t^*)\), contradicting the maximality of \((s^*,\,t^*)\). If \(t^* \in e \in E\) but every \(v_i \in V_{t^*}\) lies on the supporting line \(\ell \) of \(e\), then we obtain a strictly larger distance than \({\hbox {d}}(s^*,t^*)\), as moving \(t^*\) in a perpendicular direction to \(\ell \). (Notice that a similar argument can be also found in [17, Lemma 2.2]). \(\square \)

Lemma 2 immediately implies the lower bound on \(|\mathcal{V }(s^*,t^*)|\) when \(s^* \in V\) or \(t^* \in V\) since \(|\mathcal{V }(s^*,t^*)| \ge \max \{ |V_{s^*}|,|V_{t^*}|\}\). This completes Cases (V-*). Note that the bounds for Case (V-V) are trivial.

From now on, we assume that neither \(s^*\) nor \(t^*\) is a corner of \(\mathcal{P }\). This assumption, together with Lemma 2, implies multiple shortest paths between \(s^*\) and \(t^*\), and thus \({\hbox {d}}(s^*,t^*) > \Vert s^*-t^*\Vert \). Hence, as discussed in Sect. 2, any maximal pair falling into one of Cases (B-B), (B-I), and (I-I) appears as a local maximum of the lower envelope of some path-length functions.

*Case* (I-I): *When both* \(s^*\) *and* \(t^*\) *lie in* \({\text {int}}\,\mathcal{P }\). We will apply Theorem 1 to prove Theorem 2 for Case (I-I). Recall the definition of \(\mathcal{V }(s^*, t^*) = \{(u_1, v_1), \ldots , (u_m, v_m)\}\) and \(m = |\mathcal{V }(s^*,t^*)|\). For each \((u_i, v_i) \in \mathcal{V }(s^*,t^*)\), we have the corresponding shortest path \(\pi _i\) between \(s^*\) and \(t^*\) and \({\text {len}}_{u_i,v_i}(s^*,t^*) ={\hbox {d}}(s^*,t^*)\). Thus, we have at least \(m\) functions \(f\) among\(\{{\text {len}}_{u,v} \mid u,v\in V\}\) such that \(f(s^*, t^*) = {\hbox {d}}(s^*,t^*)\). If the number of such path-length functions are exactly \(m\), we can apply Theorem 1 directly.

Unfortunately, this is not always the case. A single shortest path \(\pi _i \in \Pi (s^*,t^*)\) may give additional pairs \((u,v)\) of corners with \(u, v\in \pi _i\) such that \((u,v) \ne (u_i, v_i)\) and \({\text {len}}_{u,v}(s^*,t^*) = {\hbox {d}}(s^*,t^*)\). This situation can occur even when the corners of \(\mathcal{P }\) are in general position. Observe that this happens only when \(u, u_i, s^*\) or \(v, v_i, t^*\) are collinear. In order to resolve this problem, we define the *merged* path-length functions that satisfy all the requirements of Theorem 1 even in degenerate cases.

### **Lemma 3**

- (i)
\(f_i(s^*,t^*) = {\hbox {d}}(s^*,t^*)\) for any \(i\in \{1,\ldots ,m\}\).

- (ii)
There exists a convex neighborhood \(C \subset \mathbb R ^4\) of \((s^*,t^*)\) with \(C \subseteq \bigcap _{i=1}^{m} D_i\) such that \({\hbox {d}}(s,t)= \min _{i\in \{1,\ldots ,m\}} f_i(s,t)\) for any \((s,t)\in C\).

- (iii)
Each of the functions \(f_i\) for \(i \in \{1,\ldots , m\}\) is convex on \(C\).

- (iv)
For any \(i\in \{1,\ldots ,m\}\), there exists a unique line \(\ell _i \subset \mathbb R ^4\) through \((s^*,t^*) \in \mathbb R ^4\) such that \(f_i\) is constant on \(\ell _i \cap C\). Moreover, there exists at most one index \(j\ne i\) such that \(\ell _i=\ell _j\).

- (v)
For any \(i,j\in \{1,\ldots ,m\}\), any \((s,t) \in C\), and any neighborhood \(U\subseteq C\) of \((s,t)\), there exists \((s^{\prime },t^{\prime })\in U\) such that \(f_i(s,t)<f_i(s^{\prime },t^{\prime })\) and \(f_j(s,t)<f_j(s^{\prime },t^{\prime })\).

### *Proof*

(i) This immediately follows from the fact that \(f_i(s^*,t^*)={\text {len}}_{u_i,v_i}(s^*,t^*)\).

We now show the convexity of \(\alpha _i\) on any convex subset \(C \subset \mathsf{VR }(u^{\prime }_i)\cup \mathsf{VR }(u_i)\). Note that the convexity of \(\omega _i\) can be shown in the same way. There are two cases: \(u^{\prime }_i = u_i\) or \(u^{\prime }_i \ne u_i\). For the former case, \(\alpha _i\) is convex on \(C\) since it measures the Euclidean distance between \(u_i\) and a given point in \(C\). For the latter case, let \(\ell _0\) be the line through \(u_i,\,u^{\prime }_i\), and also \(s^*\). Then \(C\) may be partitioned by \(\ell _0\) into two regions \(A_1\) and \(A_2\), where \(A_1 = C \cap \mathsf{VR }(u^{\prime }_i)\) and \(A_2 = C\setminus A_1\). Note that \(\alpha _i\) is convex on \(A_1\) and on \(A_2\). Thus, we are done by checking every point on \(\ell _0 \cap C\).

Pick any \(s \in \ell _0 \cap C\) and any line \(\ell \subset \mathbb R ^2\) through \(s\). Let \(\theta \) be the angle between \(\ell _0\) and \(\ell \). If we restrict the domain of \(\alpha _i\) on \(\ell \cap C\), then one can check with elementary calculus that both the derivatives of \(\Vert s-u_i\Vert + \Vert u_i - u^{\prime }_i\Vert \) and of \(\Vert s-u^{\prime }_i\Vert \) are equal to \(c\cos \theta \) at \(s\) for some constant \(c\). Hence, \(\alpha _i\) is smooth and convex along \(\ell \). Since we have taken any line \(\ell \) through any point on \(\ell _0 \cap C\), this suffices to prove the convexity of \(\alpha _i\) on \(C\).

The projections of \(\ell _i\) onto the \((s_x, s_y)\)-plane and the \((t_x, t_y)\)-plane appear the lines through \(s^*\) and \(u_i\) and through \(t^*\) and \(v_i\), respectively. Hence, one can easily check that \(f_i\) remains constant on \(\ell _i \cap D_i\), which completes the proof of the first part of the claim.

We now show the second part of the claim. As observed above, we have that the projection of \(\ell _i\) onto the \((s_x, s_y)\)-plane is the line through \(s^*\) and \(u_i\). Also, the projection of \(\ell _i\) onto the \((t_x,t_y)\)-plane is the line through \(t^*\) and \(v_i\). Hence, \(\ell _i=\ell _j\) implies that \(u_i,\,u_j,\,s^*\) are collinear and \(v_i,\,v_j,\,t^*\) are collinear. First, since the pairs \((u_i, v_i)\) are all distinct, we have \(u_i \ne u_j\) or \(v_i \ne v_j\). If \(u_i = u_j\) and \(v_i\ne v_j\), then one can easily check that \(\ell _i \ne \ell _j\) from the geometric interpretation of \(\ell _i\) as shown in Fig. 3. We hence have \(u_i \ne u_j\) and \(v_i\ne v_j\). Moreover, \(s^*\) must lie in between \(u_i\) and \(u_j\) and \(t^*\) must lie in between \(v_i\) and \(v_j\) by definition; if \(u_j\) lies in between \(u_i\) and \(s^*\), then the first corner of \(\pi _i\) from \(s^*\) becomes \(u_j\) since the three are collinear. Therefore, for each \(i\in \{1,\ldots , m\}\), there is at most one index \(j\in \{1,\ldots , m\}\) such that \(i\ne j\) and \(\ell _i = \ell _j\).

(v) Pick any \(i, j \in \{1, \ldots , m\}\) and consider the sublevel sets \(L_i = \{(\tilde{s},\tilde{t})\in \mathbb R ^4 \mid f_i(\tilde{s},\tilde{t}) \le f_i(s,t)\}\) and \(L_j = \{(\tilde{s},\tilde{t})\in \mathbb R ^4 \mid f_j(\tilde{s},\tilde{t}) \le f_j(s,t)\}\). Since \(f_i\) and \(f_j\) are convex and non-constant functions, \(L_i\) and \(L_j\) are closed convex sets that have \((s,t)\) on their boundaries. Therefore, there exist hyperplanes \(h_i\) and \(h_j\) tangent to \(L_i\) and \(L_j\), respectively, at \((s,t)\). Let \(h_i^{\oplus }\) be a closed half-space bounded by \(h_i\) that avoids \(L_i\) and \(H^{\prime }_i:=\{(s^{\prime },t^{\prime })\in h_i^\oplus \mid \Vert (s^{\prime },t^{\prime })-(s,t)\Vert =1\}\) be a closed hemisphere on the unit sphere centered at \((s,t)\). Define \(H^{\prime }_j\) analogously for \(h_j\).

Since \(H^{\prime }_i\) and \(H^{\prime }_j\) are closed hemispheres with a common center, \(H^{\prime }_i \cap H^{\prime }_j \ne \emptyset \). By construction, we have \(f_i(s,t)\le f_i(s^{\prime },t^{\prime })\) for any \((s^{\prime },t^{\prime })\in H^{\prime }_i\), and \(f_j(s,t)\le f_j(s^{\prime },t^{\prime })\) for any \((s^{\prime },t^{\prime })\in H^{\prime }_j\). On the other hand, by Property (iv) of the lemma, the equality holds only when \((s^{\prime }, t^{\prime })\) lies on line \(\ell _i\) or \(\ell _j\), respectively. Therefore, for any \((s^{\prime }, t^{\prime }) \in (H^{\prime }_i \cap H^{\prime }_j) \setminus (\ell _i \cup \ell _j)\), the claimed inequalities \(f_i(s,t) < f_i(s^{\prime },t^{\prime })\) and \(f_j(s,t) < f_j(s^{\prime },t^{\prime })\) hold strictly. The last task is to check that \((H^{\prime }_i \cap H^{\prime }_j) \setminus (\ell _i \cup \ell _j) \ne \emptyset \), which follows by Lemma 1. \(\square \)

Returning to the proof of Theorem 2, we take a convex neighborhood \(C\) of \((s^*, t^*)\) satisfying Property (ii) of Lemma 3 and apply Theorem 1. Note that Properties (i)–(iii) of Lemma 3 ensure that the preconditions of Theorem 1 are satisfied.

*Case* (B-B): *When Both* \(s^*\) *and* \(t^*\) *Lie on* \(\mathcal B \). In this case, we assume that \(s^*\in e_s \in E\) and \(t^*\in e_t \in E\). The outline of the proof is analogous to the above discussion for Case (I-I); the only difference is that the search space has a lower dimension.

### **Lemma 4**

- (i)
\(\bar{f_i}(\zeta _s^*,\zeta _t^*) = {\hbox {d}}(s(\zeta _s^*), t(\zeta _t^*))\) for any \(i\in \{1,\ldots ,m\}\).

- (ii)
There exists a convex neighborhood \(C \subset \mathbb R ^2\) of \((\zeta ^*_s,\zeta ^*_t)\) with \(C \subseteq \bigcap _{i=1}^{m} D_i\) such that \({\hbox {d}}(s(\zeta _s), t(\zeta _t))= \min _{i\in \{1,\ldots ,m\}} \bar{f_i}(\zeta _s, \zeta _t)\) for any \((\zeta _s, \zeta _t)\in C\).

- (iii)
Each of the functions \(\bar{f_i}\) for \(i \in \{1,\ldots , m\}\) is convex on \(C\).

- (iv)
If there exists a line \(\ell _i \subset \mathbb R ^2\) such that \(\bar{f_i}\) is constant on \(\ell _i \cap C\), then \(u_i\) lies on the line supporting \(e_s\) and \(v_i\) lies on the line supporting \(e_t\).

- (v)
For any \(i\in \{1,\ldots ,m\}\), any \((\zeta _s,\zeta _t) \in C\), and any neighborhood \(U\subseteq C\) of \((\zeta _s,\zeta _t)\), there exists \((\zeta _s^{\prime },\zeta _t^{\prime })\in U\) such that \(\bar{f_i}(\zeta _s,\zeta _t)<\bar{f_i}(\zeta _s^{\prime },\zeta _t^{\prime })\).

Note that the above claims are almost identical to those of Lemma 3. The results have been adapted taking into account that \(\bar{f_i}\) is the composition of \(f_i\) and both \(\zeta _s\) and \(\zeta _t\). Proofs follow verbatim, thus we omit them. Property (v) is the only exception: since the degrees of freedom have decreased, we cannot certify the existence of points arbitrarily close that increase two functions \(\bar{f_i}\). Instead, we will use the second property of Lemma 2 to lead to a contradiction.

Recall that by the first claim of Lemma 2 we have \(m\ge 2\). Thus, we are done by showing that the case \(m=2\) is not possible. Suppose that \(m=2\). Then, by Theorem 1, there exists a line \(\ell \subset \mathbb R ^2\) through \((\zeta ^*_s, \zeta ^*_t) \in \mathbb R ^2\) such that \({\hbox {d}}\) is constant on \(\ell \cap C\). By the second claim of Lemma 2, there exists a vertex \(v\in V_{s^*}\) off the line supporting \(e_s\). Without loss of generality, we assume that \(v = v_2\). By Property (iv) of Lemma 4, function \(\bar{f_2}\) cannot remain constant in any line.

Now, we proceed as in Case (I-I). Consider any small neighborhood \(U\subseteq C\) of \((\zeta _s^*, \zeta _t^*)\). Any point \((\zeta _s^{\prime }, \zeta _t^{\prime })\in \ell \cap C\) with \((\zeta _s^{\prime }, \zeta _t^{\prime })\ne (\zeta ^*_s, \zeta ^*_t)\) satisfies the strict inequality \({\hbox {d}}(s(\zeta _s^{\prime }), t(\zeta _t^{\prime }))=\bar{f_1}(\zeta _s^{\prime }, \zeta _t^{\prime }) < \bar{f_2}(\zeta _s^{\prime }, \zeta _t^{\prime })\), since \(\bar{f_2}\) cannot remain constant and \({\hbox {d}}\) is a local maximum. Thus, there exists a sufficiently small neighborhood \(U^{\prime } \subseteq U\) of \((\zeta _s^{\prime }, \zeta _t^{\prime })\) such that \({\hbox {d}}(s(\zeta _s), t(\zeta _t))=\bar{f_1}(\zeta _s, \zeta _t)\) for all \((\zeta _s, \zeta _t)\in U^{\prime }\).

Now, we apply Property (v) of Lemma 4 to obtain a point \((\zeta _s^{\prime \prime }, \zeta _t^{\prime \prime })\) arbitrarily close to \((\zeta _s^*, \zeta _t^*)\) with strict inequality \({\hbox {d}}(s(\zeta _s^{\prime \prime }), t(\zeta _t^{\prime \prime })) > {\hbox {d}}(s(\zeta _s^*), t(\zeta _t^*)) = {\hbox {d}}(s^*, t^*)\), contradicting the maximality of \((s^*, t^*)\). We hence conclude that \(m=|\mathcal{V }(s^*,t^*)| \ge 3\) for Case (B-B) when both \(s^*\) and \(t^*\) lie on \(\mathcal B \).

*Case* (B-I): *When* \(s^* \in \mathcal B \) *and* \(t^*\in {\text {int}}\,\mathcal{P }\). This case is a mixture of the two previous cases. Without loss of generality, we can also assume that \(s^* \in e_s \in E\) and \(t^* \in {\text {int}}\,\mathcal{P }\). We define \(s(\zeta _s)\) as in Case (B-B) with \(s(\zeta ^*_s) = s^*\). We now define function \(\hat{f_i} :D_i \rightarrow \mathbb R \) as \(\hat{ f_i}(\zeta _s, t_x, t_y) := \alpha _i(s(\zeta _s)) + {\hbox {d}}(u^{\prime }_i, v^{\prime }_i) + \omega _i(t_x,t_y)\), where \(D_i := s^{-1}((\mathsf{VR }(u^{\prime }_i) \cup \mathsf{VR }(u_i)) \cap e_s) \times (\mathsf{VR }(v^{\prime }_i) \cup \mathsf{VR }(v_i))\) is a subset of \(\mathbb R ^3\).

We obtain another analogue of Lemmas 3 and 4.

### **Lemma 5**

- (i)
\(\hat{f_i}(\zeta _s^*,t^*) = {\hbox {d}}(s(\zeta _s^*), t)\) for any \(i\in \{1,\ldots ,m\}\).

- (ii)
There exists a convex neighborhood \(C \subset \mathbb R ^3\) of \((\zeta ^*_s,t^*)\) with \(C \subseteq \bigcap _{i=1}^{m} D_i\) such that \({\hbox {d}}(s(\zeta _s), t)= \min _{i\in \{1,\ldots ,m\}} \hat{f_i}(\zeta _s, t)\) for any \((\zeta _s, t)\in C\).

- (iii)
Each of the functions \(\hat{f_i}\) for \(i\in \{1,\ldots ,m\}\) is convex on \(C\).

- (iv)
For any \(i\in \{1,\ldots ,m\}\), there exists a unique line \(\ell _i \subset \mathbb R ^3\) through \((\zeta _s^*, t^*) \in \mathbb R ^3\) such that \(\hat{f_i}\) is constant on \(\ell _i \cap C\). Moreover, there is at most one index \(j\ne i\) such that \(\ell _i=\ell _j\).

- (v)
For any \(i,j\in \{1,\ldots ,m\}\), any \((\zeta _s,t) \in C\), and any neighborhood \(U\subseteq C\) of \((\zeta _s,t)\), there exists \((\zeta _{s}^{\prime },t^{\prime })\in U\) such that \(\hat{f_i}(\zeta _s,t)<\hat{f_i}(\zeta _{s}^{\prime },t^{\prime })\) and \(\hat{f_j}(\zeta _s,t)<\hat{f_j}(\zeta _{s}^{\prime },t^{\prime })\).

We proceed as in Case (B-B). Suppose \(m\le 3\) and apply Theorem 1. Then we obtain a line \(\ell \) such that the geodesic distance (composed with \(\zeta _s\)) is constant on \(\ell \cap C\). However, since at most two functions \(f_i\) can remain constant on \(\ell \) by Property (iv) of Lemma 5, there must exist a point arbitrarily close to \((\zeta ^*_s,t^*)\) with strictly larger function value. Details are almost identical to the previous cases, and we get the claimed bound \(m = |\mathcal{V }(s^*, t^*)| \ge 4\) for Case (B-I).

The claimed bounds on \(|V_{s^*}|\) and \(|V_{t^*}|\) are shown by Lemma 2, which completes the proof of Theorem 2. \(\square \)

## 5 Computing the Geodesic Diameter

Since a diametral pair is in fact maximal, it falls into one of the cases shown in Theorem 2. In order to find a diametral pair we examine all possible scenarios accordingly.

Cases (V-*), where at least one point is a corner in \(V\), can be handled in \(O(n^2 \log n)\) time by computing \(\mathsf{SPM }(v)\) for every \(v\in V\) and traversing it to find the farthest point from \(v\), as discussed in Sect. 2. We thus focus on Cases (B-B), (B-I), and (I-I), where a diametral pair consists of two non-corner points.

From the computational point of view, the most difficult case corresponds to Case (I-I) of Theorem 2. In particular, if \(|V_{s^*}|=|V_{t^*}|=5\), ten corners of \(V\) are involved and thus any exhaustive method would check \(O(n^{10})\) possibilities to find maximal pairs of this case. Observe that such a case can happen even under a general position assumption as shown in Appendix 1(c). By Theorem 2, in Case (I-I), it is guaranteed that there are at least five distinct pairs \((u_1, v_1), \ldots , (u_5,v_5)\) of corners in \(V\) such that \({\text {len}}_{u_i,v_i}(s^*,t^*) = {\hbox {d}}(s^*,t^*)\) for any \(i\in \{1,\ldots ,5\}\) and the system of equations \({\text {len}}_{u_1,v_1}(s,t)= \cdots = {\text {len}}_{u_5,v_5}(s,t)\) determines a 0-dimensional zero set, corresponding to a constant number of candidate pairs in \({\text {int}}\,\mathcal{P }\times {\text {int}}\,\mathcal{P }\). On the other hand, each path-length function \({\text {len}}_{u,v}\) is an algebraic function of degree at most 4. Thus, given five distinct pairs \((u_i,v_i)\) of corners, we can compute all candidate pairs \((s,t)\) in \(O(1)\) time by solving the system.^{4} For each candidate pair we compute the geodesic distance between the pair to check its validity. Since the geodesic distance between any two points \(s,t \in \mathcal{P }\) can be computed in \(O(n\log n)\) time [13], we obtain a brute-force \(O(n^{11}\log n)\)-time algorithm, checking \(O(n^{10})\) candidate pairs obtained from all possible combinations of 10 corners in \(V\).

As a different approach, one can exploit the \(\mathsf{SPM }\)-*equivalence decomposition* of \(\mathcal{P }\), which subdivides \(\mathcal{P }\) into regions such that the shortest path map of any two points in a common region are *topologically equivalent* [8]. It is not difficult to see that if \((s,t)\) is a pair of points that equalizes any five path-length functions, then both \(s\) and \(t\) appear as vertices of the decomposition. However, the current best upper bound on the complexity of the \(\mathsf{SPM }\)-equivalence decomposition is \(O(n^{10})\) [8], and thus this approach hardly leads to a remarkable improvement.

Instead, we do the following for Case (I-I) with \(|V_{s^*}|= 5\). We choose any five corners \(u_1,\ldots ,u_5 \in V\) (as a candidate for the set \(V_{s^*}\)) and overlay their shortest path maps \(\mathsf{SPM }(u_i)\). Since each \(\mathsf{SPM }(u_i)\) has \(O(n)\) complexity, the overlay consists of \(O(n^2)\) cells. Any cell of the overlay is the intersection of five cells associated with \(v_1,\ldots ,v_5 \in V\) in \(\mathsf{SPM }(u_1),\ldots ,\mathsf{SPM }(u_5)\), respectively. Choosing a cell of the overlay, we get five (possibly, not distinct) corners \(v_1,\ldots , v_5\) and a constant number of candidate pairs by solving the system \({\text {len}}_{u_1,v_1}(s,t)=\cdots = {\text {len}}_{u_5,v_5}(s,t)\). We iterate this process for all possible tuples of five corners \(u_1,\ldots ,u_5\), to obtain a total of \(O(n^7)\) candidate pairs, spending \(O(n^7 \log n)\) time. Note that the other subcases with \(|V_{s^*}| \le 4\) can be handled similarly, resulting in \(O(n^6)\) candidate pairs.

The validity of each candidate pair \((s,t)\) is examined by checking if the paths from \(s\) through \(u_i\) and \(v_i\) to \(t\) are indeed shortest. For the purpose, we evaluate its geodesic distance \({\hbox {d}}(s,t)\) using a two-point query structure of Chiang and Mitchell [8]. For a fixed parameter \(0<\delta \le 1\) and any fixed \(\varepsilon >0\), one can construct, in \(O(n^{5+10\delta +\varepsilon })\) time, a data structure that supports \(O(n^{1-\delta }\log n)\)-time two-point shortest path queries. The total running time is \(O(n^7 \log n) + O(n^{5+10\delta +\varepsilon }) + O(n^7)\times O(n^{1-\delta }\log n)\). We set \(\delta = \frac{3}{11}\) to optimize the running time to \(O(n^{7+\frac{8}{11}+\varepsilon })\).

Also, we can use an alternative two-point query data structure whose performance is sensitive to the number \(h\) of holes [8]: after \(O(n^5)\) preprocessing time using \(O(n^5)\) storage, two-point queries can be answered in \(O(\log n +h)\) time.^{5} Using this alternative structure, the total running time of our algorithm amounts to \(O(n^7 (\log n + h))\). Note that this method gives a better bound than the previous one when \(h= O(n^\frac{8}{11})\).

The other cases can be handled analogously with strictly better time bound. For Case (B-I), by Theorem 2, we have \(|\mathcal{V }(s^*, t^*)| \ge 4\) and thus there are at least four distinct pairs \((u_i, v_i)\) of corners with \({\text {len}}_{u_i,v_i}(s^*,t^*) = {\hbox {d}}(s^*, t^*)\). Here, we handle only the case of \(|V_{t^*}|= 3\) or \(4\). For the subcase with \(|V_{t^*}|= 4\), we choose any four corners from \(V\) as \(v_1, \ldots , v_4\) as a candidate for \(V_{t^*}\) and overlay their shortest path maps \(\mathsf{SPM }(v_i)\). The overlay, together with \(V\), decomposes \(\partial \mathcal{P }\) into \(O(n)\) intervals. Each such interval determines \(u_1,\ldots , u_4\) as above, and the side \(e_s \in E\) on which \(s^*\) should lie. Now, we have a system of four equations in four variables: three from the corresponding path-length functions \({\text {len}}_{u_i,v_i}\) with \(1 \le i \le 4\) which should be equalized at \((s^*,t^*)\), and the fourth from the supporting line of \(e_s\). Solving the system, we get a constant number of candidate maximal pairs, again by Theorem 2. In total, we obtain \(O(n^5)\) candidate pairs. The other subcase with \(|V_{t^*}| = 3\) can be handled similarly, resulting in \(O(n^4)\) candidate pairs. As above, we can exploit two different structures for two-point queries. Consequently, we can handle Case (B-I) in \(O(n^{5+\frac{10}{11}+\varepsilon })\) or \(O(n^5 (\log n + h))\) time.

In Case (B-B) when \(s^*, t^* \in \mathcal B \), we have \(|V_{s^*}| = 2\) or \(3\). For the subcase with \(|V_{s^*}|=3\), we choose three corners as a candidate of \(V_{s^*}\) and take the overlay of their shortest path maps \(\mathsf{SPM }(u_i)\). It decomposes \(\partial \mathcal{P }\) into \(O(n)\) intervals. Each such interval determines three corners \(v_1, v_2, v_3\) forming \(V_{t^*}\) and a side \(e_t \in E\) on which \(t^*\) should lie. Note that we have only three equations so far; two from the three path-length functions and the third from the line supporting to \(e_t\). Since \(s^*\) also should lie on a side \(e_s\in E\) with \(e_s\ne e_t\), we need to fix such a side \(e_s\) that \(\bigcap _{1\le i\le 3} \mathsf{VR }(u_i)\) intersects \(e_s\). In the worst case, the number of such sides \(e_s\) is \(\Theta (n)\). Thus, we have \(O(n^5)\) candidate pairs for Case (B-B); again, the other subcase with \(|V_{s^*}| = 2\) contributes to a smaller number \(O(n^4)\) of candidate pairs. Testing each candidate pair can be done as above, resulting in \(O(n^{5+\frac{10}{11}+\varepsilon })\) or \(O(n^5(\log n +h))\) total running time.

Alternatively, one can exploit a two-point query structure only for boundary points on \(\partial \mathcal{P }\) for Case (B-B). The two-point query structure by Bae and Okamato [5] builds an explicit representation of the graph of the lower envelope of the path-length functions \({\text {len}}_{u,v}\) restricted on \(\partial \mathcal{P }\times \partial \mathcal{P }\) in \(O(n^5 \log n \log ^* n)\) time.^{6} Since \(|\mathcal{V }(s^*,t^*)|\ge 3\) in Case (B-B), such a pair appears as a vertex on the lower envelope. Hence, we are done by traversing all the vertices of the lower envelope.

Case | Independent of \(h\) | Dependent on \(h\) |
---|---|---|

(V-*) | \(O(n^2 \log n)\) | |

(B-B) | \(O(n^5\log n \log ^* n)\) | \(O(n^5(\log n + h))\) |

(B-I) | \(O(n^{5+\frac{10}{11}+\varepsilon })\) | \(O(n^5(\log n + h))\) |

(I-I) | \(O(n^{7+\frac{8}{11}+\varepsilon })\) | \(O(n^7 (\log n + h))\) |

As Case (I-I) is the bottleneck, we conclude the following.

### **Theorem 3**

Given a polygonal domain having \(n\) corners and \(h\) holes, the geodesic diameter and a diametral pair can be computed in \(O(n^{7+\frac{8}{11}+\varepsilon })\) or \(O(n^7 (\log n+ h))\) time in the worst case, where \(\varepsilon \) is any fixed positive number.

## 6 Concluding Remarks

We have presented the first algorithms that compute the geodesic diameter of a given polygonal domain. As mentioned in the introduction, a similar result for convex 3-polytopes was shown in [17]. We note that, although the main result of this paper is similar, the techniques used in the proof are quite different. Indeed, the key requirement for our proof is the fact that shortest paths in our environment are polygonal chains whose vertices are in \(V\), a claim that does not hold in higher dimensions (even in 2.5-D surfaces). It would be interesting to find other environments in which a similar result holds.

Another interesting question would be finding out how many maximal pairs a polygonal domain can have. The analysis of Sect. 5 gives an \(O(n^7)\) upper bound. On the other hand, one can easily construct a simple polygon in which the number of maximal pairs is \(\Omega (n^2)\). Any improvement on the \(O(n^7)\) upper bound would lead to an improvement in the running time of our algorithm.

Though in this paper we have focused on *exact* geodesic diameters only, an efficient algorithm for finding an *approximate* geodesic diameter would be also interesting. Notice that any point \(s\in \mathcal{P }\) and its farthest point \(t\in \mathcal{P }\) yield a \(2\)-approximate diameter; that is, \({\hbox {diam}}(\mathcal{P }) \le 2 \max _{t\in \mathcal{P }} {\hbox {d}}(s,t)\) for any \(s\in \mathcal{P }\). Also, based on a standard technique using a rectangular grid with a specified parameter \(0 < \varepsilon < 1\), one can obtain a \((1+\varepsilon )\)-approximate diameter in \(O((\frac{n}{\varepsilon ^2}+\frac{n^2}{\varepsilon })\log n)\) time as follows. Scale \(\mathcal{P }\) so that \(\mathcal{P }\) can fit into a unit square, and partition \(\mathcal{P }\) with a grid of size \(\varepsilon ^{-1}\times \varepsilon ^{-1}\). We define the set \(D\) as the point set that has the center of grid squares (that are inside \(\mathcal{P }\)) and intersection points between boundary edges and grid segments. It is easy to see that the distance between any two points \(s\) and \(t\) in \(\mathcal{P }\) is within a \((1+\varepsilon )\) factor of the distance between two points of \(D\). Hence, for each point of \(D\) we compute its furthest neighbor (in \(O(n\log n)\) time), and keep the pair of points of largest distance.^{7} Since \(D=O(\frac{1}{\varepsilon ^2}+\frac{n}{\varepsilon })\) we obtain the aforementioned bound.

Breaking the quadratic bound in \(n\) for the \((1+\varepsilon )\)-approximate diameter seems a challenge at this stage. We conclude by posing the following problem: for any or some \(0 < \varepsilon < 1\), is there any algorithm that finds a \((1+\varepsilon )\)-approximate diametral pair in \(O(n^{2-\delta }\cdot \mathrm poly (1/\varepsilon ))\) time for some positive \(\delta >0\)?

## Footnotes

- 1.
Personal communication with Joseph S. B. Mitchell.

- 2.
Personal communication with Valentin Polishchuk.

- 3.
We reserve the term “vertex” for 0-dimensional faces of subdivisions of a certain space.

- 4.
Here, we assume that fundamental operations on a constant number of polynomials of constant degree with a constant number of variables can be performed in constant time.

- 5.
If \(h\) is relatively small, one could use the structure of Guo et al. [11] which answers a two-point query in \(O(h \log n)\) time after \(O(n^2\log n)\) preprocessing time using \(O(n^2)\) storage, or another structure by Chiang and Mitchell [8] that supports a two-point query in \(O(h\log n)\) time, spending \(O(n+h^5)\) preprocessing time and storage.

- 6.
More precisely, in \(O(n^4\lambda _{65}(n)\log n)\) time, where \(\lambda _{m}(n)\) stands for the maximum length of a Davenport-Schinzel sequence of order \(m\) on \(n\) symbols.

- 7.
The idea of this approximation algorithm is due to Hee-Kap Ahn.

## Notes

### Acknowledgments

We thank Hee-Kap Ahn, Jiongxin Jin, Christian Knauer, and Joseph Mitchell for fruitful discussion. We also thank Joseph O’Rourke for pointing out the reference [21]. Work by S.W. Bae was supported by National Research Foundation of Korea (NRF) Grant funded by the Korea government (MEST) (No. 2010-0005974 and NRF-2013R1A1A1A05006927). M. Korman received the support of the Secretary for Universities and Research of the Ministry of Economy and Knowledge of the Government of Catalonia, the European Union, and ESF EUROCORES Programme EuroGIGA-ComPoSe IP04-MICINN Project EUI-EURC-2011-4306. Work by Y. Okamoto was supported by Global COE Program “Computationism as a Foundation for the Sciences” and Grant-in-Aid for Scientific Research from Ministry of Education, Science and Culture, Japan, and Japan Society for the Promotion of Science.

## References

- 1.Agarwal, P.K., Aronov, B., O’Rourke, J., Schevon, C.A.: Star unfolding of a polytope with applications. SIAM J. Comput.
**26**(6), 1689–1713 (1997)Google Scholar - 2.Aronov, B., Fortune, S., Wilfong, G.: The furthest-site geodesic Voronoi diagram. Discrete Comput. Geom.
**9**, 217–255 (1993)MathSciNetzbMATHCrossRefGoogle Scholar - 3.Asano, T., Toussaint, G.: Computing the geodesic center of a simple polygon. Technical Report SOCS-85.32, McGill University, Montreal (1985)Google Scholar
- 4.Bae, S.W., Chwa, K.-Y.: The geodesic farthest-site Voronoi diagram in a polygonal domain with holes. In: Proceedings of 25th Annual Symposium Computational Geometry (SoCG), pp. 198–207 (2009)Google Scholar
- 5.Bae, S.W., Okamoto, Y.: Querying two boundary points for shortest paths in a polygonal domain. Comput. Geom.
**45**(7), 284–293 (2012)MathSciNetzbMATHCrossRefGoogle Scholar - 6.Bae, S.W., Korman, M., Okamoto, Y.: The geodesic diameter of polygonal domains. In: Proceedings of 18th Annual European Symposium on Algorithms. Part 1. Lecture Notes in Computer Science, vol. 6346, pp. 500–511 (2010)Google Scholar
- 7.Chazelle, B.: A theorem on polygon cutting with applications. In: Proceedings of 23rd Annual Symposium on Foundations of Computer Science (FOCS), pp. 339–349 (1982)Google Scholar
- 8.Chiang, Y.-J., Mitchell, J.S.B.: Two-point Euclidean shortest path queries in the plane. In: Proceedings of 10th ACM-SIAM Symposium on Discrete Algorithms (SODA), pp. 215–224 (1999)Google Scholar
- 9.Cook, A.F., IV, Wenk, C.: Shortest path problems on a polyhedral surface. In: Proceedings of 11th International Symposium on Algorithms and Data Structures (WADS), pp. 156–167 (2009)Google Scholar
- 10.Guibas, L.J., Hershberger, J.: Optimal shortest path queries in a simple polygon. J. Comput. Syst. Sci.
**39**(2), 126–152 (1989)MathSciNetzbMATHCrossRefGoogle Scholar - 11.Guo, H., Maheshwari, A., Sack, J.-R.: Shortest path queries in polygonal domains. In: Proceedings of the 4th International Conference on Algorithmic Aspects in Information and Management (AAIM). Lecture Notes in Computer Science, vol. 5034, pp. 200–211 (2008)Google Scholar
- 12.Hershberger, J., Suri, S.: Matrix searching with the shortest path metric. SIAM J. Comput.
**26**(6), 1612–1634 (1997)MathSciNetzbMATHCrossRefGoogle Scholar - 13.Hershberger, J., Suri, S.: An optimal algorithm for Euclidean shortest paths in the plane. SIAM J. Comput.
**28**(6), 2215–2256 (1999)MathSciNetzbMATHCrossRefGoogle Scholar - 14.Koivisto, M., Polishchuk, V.: Geodesic diameter of a polygonal domain in \(O(n^4\log n)\) time. CoRR, http://arxiv/abs/1006.1998 (2010)
- 15.Mitchell, J.S.B.: Shortest paths among obstacles in the plane. Int. J. Comput. Geom. Appl.
**6**(3), 309–331 (1996)zbMATHCrossRefGoogle Scholar - 16.Mitchell, J.S.B.: Shortest paths and networks. In: Handbook of Discrete and Computational Geometry, 2nd edn, Chap. 27, pp. 607–641. CRC Press, Boca Raton (2004)Google Scholar
- 17.O’Rourke, J., Schevon, C.: Computing the geodesic diameter of a 3-polytope. In: Proceedings of the 5th Annual Symposium on Computational Geometry (SoCG), pp. 370–379 (1989)Google Scholar
- 18.O’Rourke, J., Suri, S.: Polygons. In: Handbook of Discrete and Computational Geometry, 2nd edn, Chap. 26, pp. 583–606. CRC Press, Boca Raton (2004)Google Scholar
- 19.Pollack, R., Sharir, M., Rote, G.: Computing the geodesic center of a simple polygon. Discrete Comput. Geom.
**4**(6), 611–626 (1989)MathSciNetzbMATHCrossRefGoogle Scholar - 20.Suri, S.: The all-geodesic-furthest neighbors problem for simple polygons. In: Proceedings of 3rd Annual Symposium on Computational Geometry (SoCG), pp. 64–75 (1987)Google Scholar
- 21.Zalgaller, V.A.: An isoperimetric problem for tetrahedra. J. Math. Sci.
**140**(4), 511–527 (2007)MathSciNetCrossRefGoogle Scholar