The Inverse Voronoi Problem in Graphs
We introduce the inverse Voronoi diagram problem in graphs: given a graph with positive edge-lengths and a collection of subsets of vertices of , decide whether is a Voronoi diagram in with respect to the shortest-path metric. We show that the problem is NP-hard, even for planar graphs where all the edges have unit length. We also study the parameterized complexity of the problem and show that the problem is W-hard when parameterized by the number of Voronoi cells or by the pathwidth of the graph. For trees we show that the problem can be solved in near-linear time and provide a lower bound of time for trees with vertices.
Keywords: distances in graphs, Voronoi diagram, inverse Voronoi problem, NP-complete, parameterized complexity.
Let be a metric space, where . Let be a subset of . We refer to each element of as a site, to distinguish it from an arbitrary point of . The Voronoi cell of each site is then defined by
The Voronoi diagram of in is
It is easy to see that, for each set of sites, each element of belongs to some Voronoi cell . Therefore, the sets in cover . On the other hand, the Voronoi cells do not need to be pairwise disjoint. In particular, when some point is closest to two sites, then it is in both Voronoi cells.
In the inverse Voronoi problem, we are given a metric space and a sequence of subsets of that cover . The task it to decide whether is a Voronoi diagram in . This means that we have to decide whether there exists sites such that, for each index , we have .
The inverse Voronoi problem is closely related to problems in classification and clustering. In pattern recognition, a classic paradigm to classify is to use the nearest neighbor rule: given a learning set of objects that are already classified, each new object is classified into the same class as its closest object from . To reduce the size of the learning set, Hart  introduced the concept of consistent subsets. A subset of the learning set is a consistent subset if, for each object from , the object and its closest neighbor in are in the same class. An equivalent, alternative perspective of this is given by Voronoi diagrams: in the Voronoi diagram of a consistent subset , each object of belongs to a Voronoi cell defined by a site if and only if and belong to the same class. Ritter et al.  introduced the problem of finding consistent subsets of minimum size. Surveying the research in this applied area is beyond the scope of our research. We refer to Biniaz et al.  and Gottlieb et al.  for some of the latest algorithmic results on this topic. Considering each class as a Voronoi cell, the inverse Voronoi problem is asking precisely whether there exists a consistent subset with one element per class. Such consistent subset has of course to be of optimal size.
Let be an undirected graph with vertices and abstract, positive edge-lengths . The length of a path in is the sum of the edge-lengths along the path. We define the (shortest-path) distance between two vertices and of , denoted by , as the minimum length over all paths in from to .
Since is a metric space, we can consider the concepts of Voronoi cells and Voronoi diagrams for this space. We denote them by and respectively. Moreover, when the graph is clear from the context, we remove the subindex and thus just talk about and .
In this paper we consider computational aspects of the inverse Voronoi problem when the metric space is the shortest-path metric in a graph. Thus, we consider the following problem.
Graphic Inverse Voronoi
Input: , where is a graph with positive edge-lengths and is a sequence of subsets of vertices of that cover .
Question: Are there sites such that for each ?
As far as the existence of polynomial-time algorithms is concerned, it is equivalent to consider a graph or a finite metric space. Indeed, for each finite metric space we can build a graph that encodes those distances by using a complete graph with edge-lengths, and, inversely, given a graph, we can compute the matrix of distances between all pairs of vertices in polynomial time. However, considering special classes of graphs may be useful to get more efficient algorithms.
First we show that the problem Graphic Inverse Voronoi is NP-hard even for planar graphs where the candidate Voronoi cell are pairwise disjoint and each has at most vertices. The reduction is from a variant of Planar -SAT. The bound on the number of vertices per cells is tight: when each candidate Voronoi cell has vertices, the problem can be solved using -SAT.
Many graph decision and optimization problems admit fixed-parameter tractable (FPT) algorithms with respect to additional parameters that quantify how complex is the input; see for instance . Using the framework of parameterized complexity, we provide stronger lower bounds when parameterized by the number of sites and the pathwidth of . More precisely, assuming the Exponential Time Hypothesis (ETH), we show that the problem cannot be solved in time nor in time , for any computable function . These hardness results hold for graphs where all the edges have unit length.
Then we consider efficient algorithms for the problem Graphic Inverse Voronoi when the underlying graph is a tree. One has to be careful with the size of the description of the input because the size of the Voronoi diagram may be quadratic in the size of the tree. For example, in a star with leaves and sites in of the leaves, each Voronoi cell has size , and thus an explicit description of the Voronoi diagram has size . Motivated by this, we define the description size of an instance for the Graphic Inverse Voronoi to be .
We show that the problem Graphic Inverse Voronoi for trees can be solved in for arbitrary trees. We also show a lower bound of in the algebraic computation tree model for trees with arbitrary edge-lengths.
One may be tempted to think that the problem is easy for trees. Our near-linear time algorithm for arbitrary trees is far from trivial. Of course we cannot exclude the existence of a simpler algorithm running in near-linear time, but we do think that the problem is more complex than it may seem at first glance. Figure 1 may help understanding that the interaction between different Voronoi cells may be more complex than it seems.
In our solution we first make a reduction to the same problem in which Voronoi cells are disjoint, and then we make another transformation to an instance having maximum degree . Finally, we employ a bottom-up dynamic programming procedure that, to achieve near-linear time, uses dynamic binary search trees to manipulate sets of intervals.
Voronoi diagrams on graphs were first investigated by Erwig , who showed that they can be efficiently computed. Subsequently, graph Voronoi diagrams have been used in a variety of applications. For instance, Okabe  describes several applications of graph Voronoi diagrams. More recent applications, many of them for planar graphs, can be found in [7, 9, 13, 14, 19, 22]. Voronoi diagrams in graphs have also been considered in the context of the so-called Voronoi game [3, 15] and in the context of topological data analysis .
On the other hand, the inverse Voronoi problem in the traditional, Euclidean setting has been studied since the mid 1980s, starting with the seminal paper by Ash and Bolker . We are not aware of any previous work considering the graphic inverse Voronoi problem.
For a positive integer we use the notation .
Consider an instance to the Graphic Inverse Voronoi and a candidate solution . We say that and () are compatible if we have for each , for each , and for each . Consider a fixed index . It is straightforward from the definition that if and only if and are compatible for all . (Here it is relevant the assumption that is .)
The following results are folklore. In all cases we use as the ground graph that defines the metric. Note that in the following claims it is important that has positive edge-lengths.
We have remarked before that Voronoi cells need not be disjoint. A vertex belongs to various Voronoi cells if it is equidistant to different sites. An alternative is to define cells using strict inequalities. More precisely, for a set of sites , the open Voronoi cell of each site is then defined by
In this case, the cells are disjoint but they do not necessarily form a partition of . The following lemmas are straightforward and we omit their proofs.
For each set of sites and each site we have and
For each set of sites, each site , and each vertex , every shortest path from to is contained in , the subgraph of induced by . The same statement is true for .
A consequence of this Lemma is that the shortest path from to has a part with vertices inside followed by a part with vertices of .
Given an instance for the problem Graphic Inverse Voronoi, where is a tree, and a candidate solution , we can check in time whether is indeed a solution.
We add a new vertex (called the apex) to and connect it to each candidate site with edges of the same positive length. See the left drawing in Figure 2. The resulting graph has treewidth , and thus we can compute shortest paths from to all vertices in linear time . Let be the distance in from to .
Next we build a digraph describing the shortest paths from to all other vertices. The vertex set of is . For each arc , where , we add to if and only if . With this we obtain a directed acyclic graph that contains all shortest paths from to every and, moreover, each directed path in is indeed a shortest path in . See Figure 2 right.
Now we label each vertex with the indices of those sites , whose Voronoi cells contain , as follows. We start setting for each site . Then we consider the vertices in topological order with respect to . For each vertex , we set to be the union of , where iterates over the vertices of with arcs in pointing to . It is easy to see by induction that . During the process we keep a counter for , and if at some moment we detect that the counter exceeds , we stop and report that is not a solution. Otherwise, we finish the process when we computed the sets .
Now we compute the sets for . This is done iterating over the vertices and adding to each site of . This takes time. Note that . It remains to check that for all . For this we add flags to that are initially set to false. Then, for each , we do the following: check that , iterate over the vertices of setting the flags to true, iterate over the vertices of checking that the flags are true, iterate over the vertices of setting the flags back to false. The procedure takes time and, if all the checks were correct, we have for all . ∎
3 Hardness of the Graphic Inverse Voronoi
In this Section we sow that the problem Graphic Inverse Voronoi is NP-hard, even for planar graphs. Stronger lower bounds are derived assuming the Exponential Time Hypothesis (ETH). We will reduce from a variant of the satisfiability (SAT) where each clause has literals, all the literals are positive, and we want that each clause is satisfied at exactly one literal. The problem can be stated combinatorially as follows.
Input: , where is a ground set and is a family of subsets of of size 3.
Question: Is there a subset such that for each ?
In this combinatorial setting, represents the variables, represents the clauses with positive literals each, and represents the variables that are set to true.
The incidence graph of an instance has vertex set and and an edge between and precisely when . The graph is bipartite.
As shown by Mulzer and Rote , the problem Positive 1-in-3-SAT is NP-complete even when the incidence graph is planar.
The Graphic Inverse Voronoi problem is NP-hard on planar graphs with unit edge-lengths, even when the candidate Voronoi cells are disjoint sets of size at most 3.
We reduce from Positive 1-in-3-SAT with planar incidence graphs. Let be an instance of Positive 1-in-3-SAT with planar incidence graph. We produce an equivalent instance of Graphic Inverse Voronoi as follows. See Figure 3
For each element , we add two vertices and to the vertex set of , and we connect them by an edge. We add the set to the candidate Voronoi cells .
For each subset , we add three vertices , , and to , and we connect the three pairs by an edge, forming a triangle. We add the set to .
Finally, for each and each with , we link to by an edge.
This finishes the construction of . We observe that the sets of are indeed pairwise disjoint and of size or . The graph is planar since it is obtained from the planar incidence graph by adding pendant vertices and splitting each vertex representing a subset (with three neighbors) into a triangle in which each vertex is linked to one distinct neighbor.
If there is a solution to the instance , we position the sites in the following way. For each , we place the site of in if , and in , otherwise. For each , we place the site of in , where is the unique element of . We denote by the obtained set of sites. We check that this placement defines the same Voronoi cells as specified by .
For each , we have , since by construction there is no site in . The only neighbors of are vertices for some values of . However, those neighbors do not contain a site of by construction. On the other, there is always a site of at distance at most of , whereas is at distance of . Hence, .
Similarly, for each , we have , since by construction there is no site in . The only neighbors of are vertices for some values of , but since , by construction, also belongs to . Therefore, .
Finally, consider some , where . We have because is the only site in . The only other neighbor of is , which is in . The only neighbor of with is which is at distance of and at distance of the site . Thus, .
If there is no solution to the instance , we show that there is no solution to the Graphic Inverse Voronoi instance . Fix a position of the sites. The set of sites has to intersect each exactly once. Define the set
As is not a solution for the Positive 1-in-3-SAT instance, there is a such that . We now turn our attention to the site chosen for . We distinguish two cases: and . If , for every position of the site, say in (with ), then contains , and therefore cannot be equal to . Now if , let and be two sites of with . Since contains precisely one site, we have or If , then contains , and therefore cannot be equal to . Similarly, if , then . In both cases, we reach the conclusion that there cannot be a solution for the instance .
Note that in the argument we did not use that or are planar. ∎
Using additional properties of the reduction from (Planar) 3-SAT to (Planar) Positive 1-in-3-SAT given by Mulzer and Rote  and the Sparsification Lemma, we derive the following conditional lower bound.
Unless the Exponential Time Hypothesis fails, the problem Graphic Inverse Voronoi cannot be solved in time in general graphs and in time in planar graphs, where is the number of vertices, even when the potential Voronoi cells are disjoint and of size at most 3.
Applying the reduction of Mulzer and Rote  to a 3-SAT instance with variables and clauses gives an instance to Positive 1-in-3-SAT with variables and clauses. This is so because in their reduction each clause is replaced locally using new variables and clauses. The reduction and the proof used in Theorem 4 then gives an instance with vertices. (The reduction also works for non-planar instances, as mentioned at the end of the proof.) Therefore, if we could solve Graphic Inverse Voronoi in time , we could solve any 3-SAT instance with variables and clauses in time . However, the Sparsification Lemma  rules out, under the Exponential Time Hypothesis, a running time for 3-SAT.
The reduction from 3-SAT to Planar 3-SAT given by Lichtenstein  increases quadratically the number of variables and clauses. Together with the reduction of Mulzer and Rote from (Planar) 3-SAT to (Planar) Positive 1-in-3-SAT and our reduction in the proof of Theorem 4, we conclude that each instance of 3-SAT with variables and clauses becomes an instance of Graphic Inverse Voronoi where the graph is planar and has . Again, solving the problem in planar graphs in time time for planar graphs would contradict the Sparsification Lemma. ∎
This upper bound of for the size of the potential Voronoi cells is sharp.
One can solve in polynomial time instances where . We show that the problem can be solved in polynomial time when each potential Voronoi cell has at most two points not contained in other potential cells. For this, one uses a reduction to -SAT. Inspired by Lemma 1, we say that each defines the potential open Voronoi cell
The Graphic Inverse Voronoi problem can be solved in polynomial time when all the potential open Voronoi cells are of size at most .
We present a polynomial reduction to 2-SAT. See Figure 4 for an example. Let be the Graphic Inverse Voronoi instance. We denote by the open potential Voronoi cell of the potential Voronoi cell . By assumption, . Because of Lemma 1, if the instance has a solution, then . For each open cell , we introduce a variable . We interpret putting the site on one fixed but arbitrary vertex of to setting to true, and putting the site on the other vertex (if it exists) to setting to false. Now, if and only if for each pair of sites with and :
every vertex of is strictly closer to than to , and
every vertex of is strictly closer to than to , and
every vertex of is equidistant to and .
Therefore, one just needs to check that each pair of sites of is compatible, that is, satisfies those three conditions.
We define the following set of 2-SAT constraints. For each open cell of size , we add the clause , which forces to set to true. For each pair which is not compatible we add the clause where (resp. ) is the opposite literal to the one chosen by placing a site in (resp. ).
It is easy to check that the produced 2-SAT formula is satisfiable if and only if there is a pairwise compatible set of sites. This is in turn equivalent to the existence of a solution for the Graphic Inverse Voronoi instance. ∎
4 Hardness parameterized by the number of Voronoi cells
In the previous section we showed that the problem Graphic Inverse Voronoi is NP-hard. Stronger lower bounds are derived under the assumption of the Exponential Time Hypothesis (ETH). We will prove the following result.
The Graphic Inverse Voronoi problem is W-hard parameterized by the number of candidate Voronoi cells. Furthermore, for -vertex graphs and subsets to be candidate Voronoi cells, for any computable function , there is no algorithm to solve the Graphic Inverse Voronoi problem in time, unless the Exponential Time Hypothesis fails. The claim holds even for graphs with unit edge-lengths.
Note that it is trivial to solve the problem in time: just try each tuples of vertices as candidate sites and check each of them. The remaining of this section is devoted to prove Theorem 7. We will reduce from the following problem:
Multicolored Subgraph Isomorphism
Input: , where is a graph whose vertex set is partitioned into pairwise disjoint sets , and a pattern graph with vertex set .
Question: Can we select vertices for every such that we have for each ?
When the answer is positive, we say that is isomorphic to a multicolored subgraph of . It follows from the work of Marx  that, assuming the Exponential Time Hypothesis, the Multicolored Subgraph Isomorphism cannot be solved in time for any computable function , even when the pattern has edges. This lower bound is made explicit for example in [22, Corollary 5.5], where is assumed to be -regular.
Consider an instance to the Multicolored Subgraph Isomorphism problem , where are the partite classes of and has edges. We assume for simplicity that each vertex of has degree at least . For each , let denote the edges of with one endpoint on and the other endpoint in . We shall assume that is empty whenever because those edges can be removed without affecting the instance. We build an instance for the Graphic Inverse Voronoi problem as follows.
We start with and .
For each , we add all edges between all the vertices in .
We subdivide each edge of with a new vertex, which we call .
For each , let be the vertices used to subdivide . We add all edges between all the vertices in .
For each , we add to .
All the edges have unit length. This completes the construction of and . Note that has candidate Voronoi regions, while has vertices and
The next two lemmas show that the pair is a correct reduction from Multicolored Subgraph Isomorphism to Graphic Inverse Voronoi. The intuition of the reduction is that selecting the site of each Voronoi cell corresponds to selecting an edge of for each . Moreover, the selection of the edges we make need to have compatible endpoints in each partite set , as otherwise we do not get the correct Voronoi cells.
If is isomorphic to a multicolored subgraph of , then has a set of sites such that .
Assume that is isomorphic to a multicolored subgraph of . This means that there are vertices , for every , such that for every . This means that, for every , the vertex obtained when subdividing belongs to . We define for every and .
We claim that is a set of sites in such that , for every for every . This claim implies the lemma.
For each and for each vertex of we have the following distances
Therefore, each vertex in is at distance at most from some vertex of and each vertex in is at distance at most from some vertex of .
Now we note that, for each , each vertex of is strictly closer to than to any other site. Furthermore, for each , each vertex of has the same distance to each site with , and a larger distance to each with . Therefore The result follows. ∎
If has as set of sites such , then is isomorphic to a multicolored subgraph of .
Let be a set of sites in such that . For each , let be the site of with .
Because of Lemma 1, each belongs to
In the last equality we have used that each vertex of has degree at least , which means that each is contained in at least sets of . We conclude that, for each , the site must be in .
Since each site is in , for each for each , the construction of implies that there are unique vertices and such that is the vertex obtained when subdividing the edge connecting and . In particular, is an edge of .
Fix the index and consider two edges incident to . We must have , as otherwise we would have , which would imply that and would contradict the definition of . Therefore, each of the (three) edges of define the same vertex . We denote this vertex henceforth .
We have found vertices with the property that , for each , and such that the edge in , for each . This means that is isomorphic to the multicolored subgraph of defined by . ∎
Proof of Theorem 7.
As shown in Lemmas 8 and 9, has a multicolored subgraph isomorphic to if and only if is a valid Voronoi diagram of . Thus, the answer to Multicolored Subgraph Isomorphism and Graphic Inverse Voronoi is the same.
Recall that has candidate Voronoi regions. If we could solve each instance of the Graphic Inverse Voronoi problem with vertices and sites in time , for some computable function , then we could solve the instance in
time, for some computable function . However, this also means that we could solve the Multicolored Subgraph Isomorphism in with pattern in time, and this contradicts the Exponential Time Hypothesis. ∎
5 Hardness parameterized by the pathwidth and the treewidth
In this section we show that the Graphic Inverse Voronoi problem is unlikely to be fixed parameter tractable with respect to the pathwidth of the graph. Since the pathwidth is always smaller than the treewidth, this implies the same result for the treewidth. More precisely, in this section we will prove the following.
The Graphic Inverse Voronoi problem is W-hard parameterized by the pathwidth of the input graph. Furthermore, for -vertex graphs with pathwidth , there is no algorithm to solve the Graphic Inverse Voronoi problem in time for any computable function , unless the Exponential Time Hypothesis fails. The claims hold even for graphs with unit edge-lengths and disjoint candidate Voronoi cells.
In order to show that we will reduce from the following W-hard problem.
Multicolored Independent Set
Input: A graph whose vertex set is partitioned into pairwise disjoint sets .
Question: Is there an independent set of size in such that , ?
The Multicolored Independent Set problem is W-hard with respect to and cannot be solved in time for any computable function , assuming the Exponential Time Hypothesis [10, Corollary 14.23]. The lower bounds still hold if all the partite sets have the same cardinality and the there are no edges connecting any two vertices within a set .
Let be an instance of Multicolored Independent Set such that . Let be the number of edges in . We build an equivalent Graphic Inverse Voronoi instance where the treewidth of is . This instance will have unit edge-length edges and the sets in will be pairwise disjoint.
Our global strategy for the reduction is to propagate a vertex choice in each with a path-like structure with rows and columns. In each column, we introduce a single distinct edge of so that the pathwidth of the built graph stays in . Figure 8 shows the whole reduction in the graph of Figure 7. (Seeing the details requires zooming in.) In Figure 9 we show a part of the construction in detail showing also the notation we employ. The detailed construction is as follows.
For each and , we add to an independent set of size . The vertices of the independent set are denoted by to , the third index being in one-to-one correspondence with the vertices of .
For each and , we add two vertices and . Furthermore, for each , we connect to by a private path of length , and we connect to by a private path of length . For each and , we connect and by an edge.
For each and , we add three new vertices , and . For each , we add a private path of length between and . Furthermore, we connect and with an edge and add a path of length with one extreme on and the other extreme connected through an edge to . (Thus and are connected with a path of length .)
For each and , we denote by the set of vertices comprising and all the paths going from this independent set to , , and , including those three vertices. We add , , and to the candidate Voronoi cells .
We call -th column the set for a fixed . We introduce exactly one distinct edge of per column. Let be any ordering of the edges of . We put an edge gadget encoding in the -th column, for every . Assume that is an edge between the -th vertex of and the -th vertex of where . We add a path of length between and . We add a path of length between the middle vertex of and a new vertex, denoted . (The vertex has degree 1 and it is at distance from and from .) We add as a candidate Voronoi region to . The subgraph induced by is the edge gadget of .
That finishes the construction of and of . All the edges of have unit length. One can observe that is made of pairwise disjoint sets and it contains candidate Voronoi cells. We first show that the pathwidth (and thus also the treewidth) of is at most . For that, we use the pursuit-evasion game characterization of pathwidth.
The pathwidth of is at most .
In the pursuit-evasion game, searchers try to find a fugitive hidden at an edge of the graph. The searchers occupy vertices of the graph (at most one searcher per vertex). At each step, the searchers can change their position arbitrarily (they do not need to travel via edges), whereas the fugitive can move along any path that does not cross a searcher and occupy a new edge (or stay put). The fugitive is caught when both endpoints of her/his edge is occupied by a searcher. The minimum number of searchers needed to get a winning strategy for the searchers is equal to the pathwidth plus one.
We present a winning strategy for capturing a fugitive in using searchers. We make rounds where in the -th round, , we scan completely the -th column and the gadget for .
At the start of the -th round we have searchers placed at the vertices and for all . Assume that the edge is between the -th vertex of and the -th vertex of . We place two searchers at and . Let be the set of vertices where we have searchers. They will stay there for most of the -th round. We then search the whole first column plus the edge gadget of using the remaining three searchers. For this, we note that each connected component of contained in the -th column and the connected component induced by has pathwidth , and thus it can be be searched with three searchers. At this point, the fugitive, if not captured yet, has to be to the right of the searchers placed at , that is, on some edge incident to some vertex defined by . If , we are done since there are no edges left to host the fugitive. Otherwise, we move the searchers from to , then the searchers from to , and start the next round. ∎
We now show the correctness of the reduction.
If has a multicolored independent set of size , then there is a set such that .
Assume there is a multicolored independent set of size in . We define the set of sites as follows.
For each , we place a site on the vertices