1 Introduction

Conflict-free colorings, or CF-colorings for short, were introduced by Even et al. [8] and Smorodinsky [14] to model frequency assignment to base stations in wireless networks. In the basic setting one is given a set S of objects in the plane—often disks are considered—and the goal is to assign a color to each object such that the following holds: for any point p in the plane such that the set \(S_p:=\{D\in S\mid p\in D\}\) of objects containing p is non-empty, \(S_p\) must contain an object whose color is different from the colors of the other objects in \(S_p\). Even et al.  proved, among other things, that any set of disks admits a CF-coloring with \(O(\log n)\) colors. This bound is tight in the worst case. Since then many different geometric variants of CF-colorings have been studied. For example, Har-Peled and Smorodinsky [9] generalized the result to objects with near-linear union complexity, Even et al. [8] considered the dual version of the problem, Alon and Smorodinsky [3] proved better bounds for CF-coloring disks when the arrangement of disks is shallow, and Chen et al. [5] studied on-line versions of the problem. See the survey by Smorodinsky [16] for an overview of the results up to 2013. A restricted type of a CF-coloring is a unique-maximum (UM) coloring, in which the colors are identified with integers, and the maximum color in the set \(S_p\) is required to be unique. Another type of coloring, often used as an intermediate step to obtain a CF-coloring, is non-monochromatic (NM). In an NM-coloring—sometimes called a proper coloring—we only require that, for any point p in the plane, if the set \(S_p\) contains at least two elements, not all of them have the same color. Smorodinsky [15] showed that, if an NM-coloring of k elements using \(\beta (k)\) colors exists for every k, then one can CF-color n elements with \(O(\beta (n) \log n)\) colors.

CF- or NM-coloring objects in \(\mathbb {R} ^1\) is significantly easier than in the planar case. In \(\mathbb {R} ^1\) the objects become intervals (assuming we require the objects to be connected) and a folklore result states that any set of intervals in \(\mathbb {R} ^1\) can be CF-colored with three colors and NM-colored with two colors. This is achieved by the chain methods, which we describe in Sect. 1.1. Thus, unlike in the planar case, the number of colors for a CF- or NM-coloring of intervals in \(\mathbb {R} ^1\) does not depend on the number of intervals to be colored. The fact that CF- and NM-coloring intervals in \(\mathbb {R} ^1\) is easy explains why there is not much work on coloring intervals. Exceptions are the papers by Abam et al. [1] on the online version of the problem, and by De Berg et al. [7] on the dynamic version.

We are interested in 1-dimensional spaces that have a more complex topology than \(\mathbb {R} ^1\). In particular, we consider network spaces: 1-dimensional spaces with the topology of an arbitrary (finite) graph. It is convenient to view a network space \(\mathscr {N} \) as being embedded in \(\mathbb {R} ^2\), although the embedding is actually immaterial. In this view the nodes of \(\mathscr {N} \) are points in \(\mathbb {R} ^2\), and the edges are simple curves connecting pairs of nodes and otherwise disjoint. We let \(d:\mathscr {N} ^2 \rightarrow \mathbb {R} _+\) denote the geodesic distance on \(\mathscr {N} \). In other words, for two points \(p,q\in \mathscr {N} \)—these points may lie in the interior of an edge—we let \({{\,\mathrm{dist}\,}}(p,q)\) denote the minimum Euclidean length of any path connecting p to q in \(\mathscr {N} \). We consider two special types of network spaces, tree spaces and planar network spaces, whose topology is that of a tree and a planar graph, respectively.

The objective of this paper is to investigate the number of colors needed to CF- or NM-color a set \(\mathscr {A} \) of n objects in a network space, where we consider various classes of connected objects. (Here CF- and NM-colorings are defined as above. We define \(S_p\) to be the set of objects containing p, that is \(\{ o\in \mathscr {A} \mid p\in o \}\). A CF-coloring of the objects in \(\mathscr {A} \) is now defined as a coloring such that, for any point \(p\in \mathscr {N} \) with \(S_p\ne \emptyset \), the set \(S_p\) contains an object with a unique color. Moreover, an NM-coloring of the objects in \(\mathscr {A} \) is defined as a coloring such that, for any point \(p\in \mathscr {N} \) with \(S_p\) containing at least two elements, the set \(S_p\) is not monochromatic.) In particular, we consider (metric) balls on \(\mathscr {N} \)—the ball centered at \(p\in \mathscr {N} \)of radius \(\rho \) is defined as \(B(p,\rho ):= \{q\in \mathscr {N} \mid {{\,\mathrm{dist}\,}}(p,q)\leqslant \rho \}\)— and, for tree spaces, we also consider arbitrary connected subsets as objects. Note that if the given network space is a single non-self-intersecting curve, then our setting (both for balls and for connected subspaces) reduces to coloring intervals in \(\mathbb {R} ^1\). The main question we want to answer is: How does the maximum number of colors needed to NM- or CF-color a set \(\mathscr {A} \) of objects in a network space depend on the complexity of the network space and of the objects to be colored?

Our results We assume without loss of generality that the nodes in our network space either have degree 1 or degree at least 3—there are no nodes of degree 2. Nodes of degree 1 are also called leaves, and nodes of degree at least 3 are also called internal nodes.

We start by considering colorings on a tree space, which we denote by \(\mathscr {T} \). Let \(\mathscr {A} \) be the set of n objects that we wish to color, where each object \(T\in \mathscr {A} \) is a connected subset of \(\mathscr {T} \). Note that each such object is itself also a tree. From now on we refer to the objects in \(\mathscr {A} \) as “trees,” and always use “tree space” when talking about \(\mathscr {T} \). Observe that internal nodes of a tree are necessarily internal nodes of \(\mathscr {T} \), but a tree leaf may lie in the interior of an edge of \(\mathscr {T} \). We investigate CF- and NM-chromatic number of trees on a tree space as a function of the following parameters:

  • k, the number of leaves of the tree space \(\mathscr {T} \);

  • \(\ell \), the maximum number of leaves of any tree in \(\mathscr {A} \);

  • n, the number of objects in \(\mathscr {A} \).

We define the CF-chromatic number \(X_{{{\,\mathrm{cf}\,}}}^{\mathrm {tree},\mathrm {trees}} (k, \ell ; n)\) as the minimum number of colors sufficient to CF-color any set \(\mathscr {A} \) of n trees with at most \(\ell \) leaves each, in a tree space with at most k leaves. The NM-chromatic number \(X_{{{\,\mathrm{nm}\,}}}^{\mathrm {tree},\mathrm {trees}} (k, \ell ; n)\) is defined similarly. Rows 3 and 4 in Table 1 give our bounds on these chromatic numbers. Notice that the upper bounds do not depend on n. In other words, any set of trees in a tree space can be colored with a number of colors that depends only on the complexity of the tree space \(\mathscr {T} \) and of the trees in \(\mathscr {A} \). (Obviously the number of objects, n, is an upper bound on these chromatic numbers as well. To avoid cluttering the statements, we usually omit this trivial bound.)

Table 1 Overview of our results. The folklore result for intervals on the line (that is, in \(\mathbb {R} ^1\)) is explained in Sect. 1.1. The rest of the table uses the the following parameters: k, the number of leaves of the tree space; t, the number of internal nodes (that is, nodes of degree at least 3) of the (tree or planar network) space; \(\ell \), the maximum number of leaves of any tree to be colored; n, the number of objects

We also study balls in tree spaces. Here it turns out to be more convenient to not use k (the number of leaves) as the complexity measure of \(\mathscr {T} \), but t, the number of internal nodes of \(\mathscr {T} \).

We are interested in the chromatic numbers \(X_{{{\,\mathrm{cf}\,}}}^{\mathrm {tree},\mathrm {balls}} (t; n)\) and \(X_{{{\,\mathrm{nm}\,}}}^{\mathrm {tree},\mathrm {balls}} (t; n)\). Rows 5 and 6 of Table 1 state our bounds for these chromatic numbers.

After studying balls in tree spaces, we turn our attention to balls in planar network spaces. Our bounds on the corresponding chromatic numbers \(X_{{{\,\mathrm{cf}\,}}}^{\mathrm {planar},\mathrm {balls}} (t; n)\) and \(X_{{{\,\mathrm{nm}\,}}}^{\mathrm {planar},\mathrm {balls}} (t; n)\) are contained in row 7 and 8 of Table 1.

Related results Above we considered CF- and NM-colorings in a geometric setting, but they can also be defined more abstractly. A CF-coloring on a hypergraph \(\mathscr {H}=(V,E)\) is a coloring of the vertex set V such that, for every (non-empty) hyperedge \(e\in E\), there is a vertex in e whose color is different from that of the other vertices in e. In an NM-coloring any hyperedge with at least two vertices should not be monochromatic. Smorodinsky’s survey [16] also gives an overview of results on CF-colorings in this abstract setting.

The basic geometric version mentioned above—coloring objects in \(\mathbb {R} ^2\) with respect to points—can be phrased in terms of hypergraphs by letting the set of objects correspond to the node set V and, for each point p in the plane, creating a hyperedge \(e:=S_p\). Another avenue for constructing a hypergraph \(\mathscr {H}\) to be colored is to start with a graph \(\mathscr {N} \), let the vertices of \(\mathscr {H}\) be the nodes of \(\mathscr {N} \) and create hyperedges for (the sets of vertices of) certain subgraphs of \(\mathscr {N} \). For example, Pach and Tardos [12] considered the case where hyperedges are all the node neighborhoods. For this case, Abel et al. [2] recently showed that a planar graph can always be CF-colored with only three colors, if we allow some nodes to be uncolored. (If not, we can use a dummy color, thereby increasing the number of colors to four.) CF-coloring nodes with respect to neighborhoods has also been studied for various types of geometric intersection graphs; see the paper by Keller and Smorodinsky [11] and the references therein. As another example, we can let the hyperedges be induced by all the paths in the graph. This setting is equivalent to an older notion of node ranking [4], or ordered coloring [10]. Note that in the above results the goal is to color the nodes of a graph. We, on the other hand, do not want to color nodes, but objects (connected subsets) in a network space (which has a graph topology, but is a geometric object).

1.1 Preliminaries

We regularly make use of a folklore technique called the chain methods, to color intervals in \(\mathbb {R} ^1\) in a non-monochromatic or conflict-free fashion. This serves as a warm up but is also used as a tool later. We first explain the NM chain method, that uses at most two colors. We order the intervals left-to-right by their left endpoints (in case of ties, we take the longest interval first) and color them in this order using the so-called active color which is defined as follows. We start with greenFootnote 1 as the active color. We color the first interval, then change the active color to red. We then use the following procedure: we color the next interval I in the ordering using the active color, then if the right endpoint of I is not contained in any other already colored interval, we change the active color from red to green or green to red.

To obtain a CF-coloring the chain method proceeds as follows. First, the interval with the leftmost left endpoint—in case of ties, the longest such interval—is colored green. Next, the following procedure is repeated until we get stuck: Let I be the interval colored last. Among all intervals whose left endpoint lies in I and that are not contained in it, color the one extending farthest to the right red (if I is green) or green (if I is red). This creates a chain of alternating green and red intervals. Each remaining interval is now either completely covered by the already colored intervals, or it lies completely to the right of them. The former intervals are given a dummy color (grey), the latter intervals are colored by applying the above procedure again. Figure 1 shows an NM- and CF-coloring of an example instance.

Fig. 1
figure 1

Both chain methods applied to the same instance. The top coloring is non-monochromatic, and the bottom one is conflict-free (Color figure online)

Lemma 1

There is an NM-coloring of intervals on a line using two colors, and a CF-coloring using three colors.

Proof

We prove the CF-coloring is conflict-free; the proof for the NM-coloring is similar. Consider a point p contained in an interval. It is clear that p is contained in either a red or a green interval. We suppose without loss of generality it is contained in a red interval \(I_0=[a_0,b_0]\). We show it is not contained in another red interval. Let us suppose by contradiction that it is contained in another red interval \(I_1=[a_1,b_1]\) with \(a_1\geqslant a_0\). Then p must also be contained in a green interval \(I_2=[a_2,b_2]\), with \(a_1 \geqslant a_2 \geqslant a_0\). Moreover, we have that \(b_2 < b_1 \). Thus, \(I_2\) starts in \(I_0\) and extends further than \(I_1\), hence should have been chosen to be colored green, which is a contradiction. Therefore, p is always contained in at most one red interval, and similarly, in at most one green interval, and is always contained in a green or in a red interval. Thus the coloring is conflict-free. \(\square \)

2 Trees on Tree Spaces

2.1 The Upper Bound

Overview of the coloring procedure.

Let \(\mathscr {T} \) be a tree space with k leaves and let \(\mathscr {A} \) be a set of n trees in \(\mathscr {T} \), each with at most \(\ell \) leaves. We describe an algorithm that NM-colors \(\mathscr {A} \) in two phases: first, we select a subset \(\mathscr {C} \subseteq \mathscr {A} \) of size at most \(6k-12\) and color it with at most \(\min \left( \ell +1, 2 \sqrt{6k} \right) \) colors. In the second phase we extend this coloring to the whole set \(\mathscr {A} \) without using new colors.

An edge e of \(\mathscr {T} \) is a leaf edge if it is incident to a leaf; the remaining edges are internal. We define \(\mathscr {C} \subseteq \mathscr {A} \) as the set of at most \(6k-12\) trees selected as follows. For every pair (ev), where e is an edge of \(\mathscr {T} \) and v is an endpoint of e that is not a leaf of \(\mathscr {T} \), we choose two trees containing v and extending the furthest into e (if they exist), that is, trees T of \(\mathscr {A} \) containing v for which \(\text{ length }(T\cap e)\) is maximal, and place them in \(\mathscr {A} (e,v)\). If two or more trees of \(\mathscr {A} \) fully contain e, then \(\mathscr {A} (e,v)\) contains two of them, chosen arbitrarily. If a tree contains an internal edge e fully, it may be chosen by both endpoints. We now define \(\mathscr {A} (e):=\mathscr {A} (e,u) \cup \mathscr {A} (e,v)\) for each internal edge \(e=uv\), \(\mathscr {A} (e):= \mathscr {A} (e,v)\) for each leaf edge \(e=uv\) with non-leaf endpoint v, and \(\mathscr {C}:= \bigcup \mathscr {A} (e)\), with the union taken over all edges e of \(\mathscr {T} \). Then \(\mathscr {A} (e)\) contains at most four trees for any internal edge e and at most two trees for any leaf edge e. If \(\mathscr {T} \) has at most k leaves, it has at most k leaf edges and at most \(k-3\) internal edges; recall that \(\mathscr {T} \) has no degree-two nodes. Thus \(|\mathscr {C} |\leqslant 6k-12\), as claimed. We first explain how to color \(\mathscr {C} \).

Coloring \(\mathscr {C} \) We color \(\mathscr {C} \) in two steps. Let \(T \in \mathscr {C} \) be a tree. We define E(T) to be the set of edges e of \(\mathscr {T} \) with \(T\in \mathscr {A} (e)\). Firstly, if \(\ell > 2 \sqrt{6k}\) we select all subtrees T with \(|E(T)| \geqslant \sqrt{6k}\), and give each of them a unique color. Since \(\sum _{e} |\mathscr {A} (e)| \leqslant 6k-12\), there are at most \(\sqrt{6k}-1\) such trees, so we use at most \(\sqrt{6k}-1\) colors. For each uncolored \(T\in \mathscr {C} \), we create a new tree \(T'\), defined as the smallest tree containing \(\bigcup _{e\in E(T)} e\cap T\); see Fig. 2. \(T'\) has at most \(\ell ':=\min (\ell , \sqrt{6k})\) leaves because \(|E(T)|<\sqrt{6k}\). Define \(\mathscr {C} ':=\{T'\mid \text {uncolored } T\in \mathscr {C} \}\).

Fig. 2
figure 2

The original tree T (left), the set \(\bigcup _{e\in E(T)} e\cap T\) (middle), and the new tree \(T'\) (right)

The second step is to color \(\mathscr {C} '\). We need the following lemma, which shows that an NM-coloring of \(\mathscr {C} '\) carries over to \(\mathscr {C} \).

Lemma 2

Any NM-coloring of \(\mathscr {C} '\) corresponds to an NM-coloring of \(\mathscr {C} \), that is, if we give each tree \(T\in \mathscr {C} \) the color of the corresponding tree \(T'\in \mathscr {C} '\) then we obtain an NM-coloring.

Proof

Let q be a point on an edge e of \(\mathscr {T} \) contained in at least two trees of \(\mathscr {C} \) (if no such trees exists, the coloring is trivially non-monochromatic at q). Since q is contained in at least two trees of \(\mathscr {C} \), it is also contained in two trees of \(\mathscr {A} (e)\). Call these trees \(T_1\) and \(T_2\). Note that \(T_1\) either receives a color in the first coloring step—namely, when \(\ell > 2\sqrt{6k}\) and \(|E(T_1)|\geqslant \sqrt{k}\)—or \(T'_1\in \mathscr {C} '\) contains q, since \(e\in E(T_1)\). A similar statement holds for \(T_2\). Since the colors used in the first step are unique and \(\mathscr {C} '\) is NM-colored, this implies that \(T_1\) and \(T_2\) have different colors. Hence, \(\mathscr {C} \) is NM-colored. \(\square \)

Next we show how to NM-color \(\mathscr {C} '\). Fix an arbitrary internal node r of \(\mathscr {T} \) and treat \(\mathscr {T} \) as rooted at r. Our coloring procedure for \(\mathscr {C} '\) maintains the following invariant: any path from r to a leaf v of \(\mathscr {T} \) consists of three disjoint consecutive subpaths (some possibly empty), in this order, as illustrated in Fig. 3:

  • a non-monochromatic subpath containing the root on which at least two trees are colored with at least two different colors,

  • a singly-colored subpath covered by exactly one colored tree, and

  • an uncolored subpath containing the leaf on which no tree is colored.

Fig. 3
figure 3

A coloring of trees (left) and an illustration of the invariant for v (right) (Color figure online)

Observation 3

Any set of trees containing r and satisfying the invariant described above is NM-colored if we disregard uncolored trees.

We color the trees \(T\in \mathscr {C} '\) that contain r in an arbitrary order, using \(\ell '+1\) colors, as follows: for each leaf v of T, we follow the path from v to the root r to find a singly-colored part. Note that if we find a singly-colored part—by the invariant there is at most one such part on the path from v to r—we cannot use that color for T. Since T has at most \(\ell '\) leaves, this eliminates at most \(\ell '\) colors. Hence, at least one color remains for T.

Lemma 4

The procedure described above maintains the invariant and colors all trees of \(\mathscr {C} '\) containing r with at most \(\ell '+1\) colors.

Proof

Suppose the invariant holds before the coloring of T. Then we need to make sure the invariant still holds after T has been colored. Let w be a leaf of \(\mathscr {T} \) and \(\pi _w\) the path from w to the root. Let v be the closest point to w in \(\pi _w \cap T\). Note that v always exists as \(r \in \pi _w \cap T\). Now let \(\pi _v\subseteq \pi _w\) be the path from v to r. It is obvious that \(\pi _w \cap T = \pi _v\). Then the part of \(\pi _v\) that was uncolored (if it was non-empty) now is singly-colored. The part that was singly-colored now becomes non-monochromatic, as we eliminated that color for T, while the part that was already non-monochromatic stays non-monochromatic. Therefore the invariant is indeed maintained for \(\pi _w\), concluding the proof. \(\square \)

Once all the trees containing r are colored we delete r from \(\mathscr {T} \), that is, we consider the space \(\mathscr {T} {\setminus }\{r\}\), and we take the closures of the resulting connected components. This creates a number of subspaces such that each uncolored tree in \(\mathscr {C} '\) is contained in exactly one of them. Consider such a subspace \(\mathscr {T} '\) and let \(r'\) be the neighbor of r in \(\mathscr {T} '\). We now want to recursively color the uncolored trees in \(\mathscr {T} '\), taking \(r'\) as the root of \(\mathscr {T} '\). However, the invariant might not hold on the edge e from \(r'\) to the old root r: Since now r is considered a child of \(r'\), the order of the three parts might switch on e—see Fig. 4. Suppose this is the case, and let \(c_e\) be the color of the singly-colored part on the edge e. (If the singly-colored part is empty, we can cut the tree between the non-monochromatic and the uncolored part and recurse immediately, which maintains the invariant.) Note also that, for the order to switch, the non-monochromatic part needs to end on e, and therefore the only color used in any singly-colored part of the tree rooted at \(r'\) is \(c_e\). We overcome this problem by carefully choosing the order in which we color the trees containing \(r'\). Namely, we fist color the tree T extending the farthest into e. In this case, there is only one color forbidden, namely \(c_e\). We can therefore easily color T. We then trim the tree space \(\mathscr {T} '\) to remove any non-monochromatic and single colored part, as shown in Fig. 4. This restores the invariant, and so we can continue the coloring process.

Fig. 4
figure 4

When recursing on the subspace rooted at \(r'\) (leftmost), the invariant does not hold anymore (middle left), as the parts are switched on the edge between r and \(r'\). To remedy this, we first color the tree extending the farthest into that edge (middle right), starting from \(r'\). We then trim the tree space to fix the invariant (rightmost) (Color figure online)

Lemma 5

\(\mathscr {C} \) admits an NM-coloring with \(\min (\ell +1, 2\sqrt{6k})\) colors.

Proof

The fact that the procedure above produces an NM-coloring follows from Lemmas 2 and 4. When \(\ell >2\sqrt{6k}\) we use \(\sqrt{6k}-1\) colors to deal with trees T with \(|E(T)|{\geqslant }\sqrt{6k}\) and \(\ell '+1\leqslant \min (\ell ,\sqrt{6k})+1{\leqslant } \sqrt{6k}+1\) colors for the other trees, giving \(2\sqrt{6k}\) colors in total. When \(\ell {\leqslant } 2\sqrt{6k}\) we do not treat the trees with \(|E(T)|{\geqslant }\sqrt{6k}\) separately, so we just use \(\ell '+1{\leqslant } \min (\ell ,\sqrt{6k}){+}1{\leqslant } \ell {+}1\) colors. \(\square \)

Extending the coloring from \(\mathscr {C} \)to \(\mathscr {A} \) Let \(c :\mathscr {C} \rightarrow \mathbb {N} \) be an NM-coloring on \(\mathscr {C} \). We extend the coloring to \(\mathscr {A} \) as follows. We start by coloring all trees in \(\mathscr {A} {\setminus } \mathscr {C} \) containing an internal node of \(\mathscr {T} \) using an arbitrary color already used. We then treat all edges in an arbitrary order, coloring all trees contained in the edge, as follows.

Let \(e=rr'\) be an arbitrary edge of \(\mathscr {T} \) and \(\mathscr {A} ^*(e)\) be the set of uncolored trees contained in e. We color \(\mathscr {A} ^*(e)\) as follows. We first color the set of uncolored trees contained in e naively using the chain method. For this we use two new colors, which are used for all chains—we can re-use the same two colors for the chains, since trivially the chains in two different edges \(e,e'\) do not interact. However, we can avoid using two extra colors and re-use the colors from \(\mathscr {C} \) as explained next.

First, if \(c \) uses a single color, then each node of \(\mathscr {T} \) is contained in at most one tree. We then forget the trivial coloring \(c \) and use the chain method from scratch on \(\mathscr {A} \). We start at an arbitrarily fixed leaf u of \(\mathscr {T} \), and for any other leaf \(u'\), we consider the path between u and \(u'\) and use the chain method on the trees restricted to this path. Note that a tree T can be encountered on several different paths, but it receives the same color each time (since all these paths start at u and are identical up to the moment T is reached). Moreover, the coloring is non-monochromatic, since any point in \(\mathscr {T} \) is contained in a path from u to some leaf \(u'\).

We may now suppose that \(c \) uses at least two colors. Let \(T_r\in \mathscr {A} (e,r)\) and \(T_{r'}\in \mathscr {A} (e,r')\), be the trees extending the farthest into e (arbitrarily chosen in case of a tie). Note that these trees might not exist. Also note that \(T_r\) and \(T_{r'}\) are not in \(\mathscr {A} ^*(e)\). We define the following colors.

  • Let \(c_r\) be the color of \(T_r\), if \(T_{r}\) exists, and an arbitrary color otherwise.

  • Let \(c_{r'}\) be the color of \(T_{r'}\), if \(T_{r'}\) exists, and \(c (T_{r'})\ne c (T_{r})\) (if \(T_{r}\) does not exist, we assume this is always true), and an arbitrary color different from \(c_r\) otherwise.

We then do the following.

  1. (a)

    If \(T_{r}\) fully contains e, we color all trees in \(\mathscr {A} ^*(e)\) using \(c_{r'}\).

  2. (b)

    If \(T_{r'}\) fully contains e, we color all trees in \(\mathscr {A} ^*(e)\) using \(c_{r}\).

  3. (c)

    Otherwise, we use the chain method for NM-colorings using \(c_r\) and \(c_{r'}\) on \(\mathscr {A} ^*(e) \cup \{T_{r}\} \cup \{T_{r'}\}\). We start from r with color \(c_r\) so that \(T_{r}\) is the first tree colored and keep its color. We then check if the color of \(T_{r'}\) changed. If so, let \(\mathscr {C} _{r'}\subseteq \mathscr {C} \) be the subset of trees contained in the subspace rooted at \(r'\) (including e but not r) and excluding \(T_{r'}\). We exchange \(c_r\) and \(c_{r'}\) in \(\mathscr {C} _{r'}\); see Fig. 5.

Fig. 5
figure 5

If the color of \(T_{r'}\) changes with the chain method, we swap the labels of the old and new colors of \(T_{r'}\) in the subspace rooted at \({r'}\) (Color figure online)

The following lemma proves the extended coloring is non-monochromatic.

Lemma 6

Any NM-coloring c on \(\mathscr {C} \) can be extended to \(\mathscr {A} \) without using any extra color if c uses two colors or more, and with two colors otherwise.

Proof

Let \(\mathscr {A} _1\) be the subset of trees in \(\mathscr {A} {\setminus } \mathscr {C} \) that contain an internal node of \(\mathscr {T} \), and let \(\mathscr {A} _2\) be the remaining trees in \(\mathscr {A} {\setminus } \mathscr {C} \). By Lemma 5, we have an NM-coloring on \(\mathscr {C} \). To prove that the method described above gives us an NM-coloring on \(\mathscr {C} \cup \mathscr {A} _2\), we show that the following invariant holds each time an edge is colored: the coloring on \(\mathscr {C} \cup \mathscr {A} _2\) is non-monochromatic when restricted to colored trees. It is clear that before the first edge is colored, the coloring is non-monochromatic as at this point the only trees colored are exactly those in \(\mathscr {C} \). We hence only have to show the invariant still holds after coloring an edge \(e=rr'\). If we are in cases (a) or (b), the invariant trivially holds. It remains to consider the third case.

In case (c) we use the chain method on \(\mathscr {A} ^*(e) \cup \{T_{r}\} \cup \{T_{r'}\}\), which immediately implies the coloring is non-monochromatic on e. To prove it is also non-monochromatic elsewhere, let \(p\notin e\) be a point contained in at least two trees. Then we only have to show that the label swap we performed on one side of e keeps the coloring non-monochromatic. The point p cannot be contained in one tree containing r and one tree containing \(r'\) at the same time, because no tree contains e fully. Therefore, p is contained in at least two trees from one side of e, hence two trees of different color.

Furthermore, the trees in \(\mathscr {A} _1\) received an arbitrary color already used. To prove that this gives an NM-coloring for \(\mathscr {A} = \mathscr {C} \cup \mathscr {A} _1\cup \mathscr {A} _2\), it suffices to prove that each tree \(T\in \mathscr {A} _1\) is doubly-covered by \(\mathscr {C} \), that is, any point \(q\in T\) is contained in at least two trees in \(\mathscr {C} \). To this end, let e be an edge such that \(q\in e\). Then, since \(T\not \in \mathscr {C} \) and T contains an endpoint v of e, the two trees in \(\mathscr {A} (e,v)\) contain q. Hence, T is doubly-covered by \(\mathscr {C} \), as claimed. \(\square \)

Theorem 7

  1. 1.

    \(X_{{{\,\mathrm{nm}\,}}}^{\mathrm {tree},\mathrm {trees}} (k, \ell ; n) \leqslant \min \left( \ell +1, 2 \sqrt{6k} \right) \).

  2. 2.

    \(X_{{{\,\mathrm{cf}\,}}}^{\mathrm {tree},\mathrm {trees}} (k, \ell ; n)=O(\ell \log k)\).

Proof

For the NM-coloring part of the theorem, we use Lemmas 5 and 6. For the second part, if \(\ell > 2\sqrt{6k}\) we again reduce \(\mathscr {C} \) to \(\mathscr {C} '\) using at most \(\sqrt{6k}-1\) colors. Then use the result by Smorodinsky [15] on the NM-coloring on \(\mathscr {C} '\) provided by Lemma 4. Since this coloring uses at most \(\ell ' +1\) colors and \(|\mathscr {C} '|\leqslant 6k-12\), the CF-coloring uses \(O(\ell \log k)\) colors. We then extend the coloring to \(\mathscr {A} \) using similar techniques as for the NM-coloring. This coloring uses \(O(\sqrt{k} \log k)\) colors if \(\ell > 2\sqrt{6k}\), which is in \(O(\ell \log k)\), and directly \(O(\ell \log k)\) colors otherwise. Note that a direct application of the result of Smorodinsty [15] would give a \(O(\ell \log n)\) bound instead. \(\square \)

2.2 The Lower Bound

We show a lower bound for the number of colors needed to NM-color a set of trees in a tree space.

Theorem 8

For all n, k, and \(\ell \), there exist a tree space \(\mathscr {T} \) with k leaves and a set \(\mathscr {A} \) at most n trees on \(\mathscr {T} \), each with at most \(\ell \) leaves, such that any non-monochromatic coloring of \(\mathscr {A} \) uses at least \(\min \left( \ell +1, \left\lfloor \tfrac{1+ \sqrt{1+8k} }{2} \right\rfloor , n \right) \) colors. In other words,

$$\begin{aligned} X_{{{\,\mathrm{nm}\,}}}^{\mathrm {tree},\mathrm {trees}}(k, \ell ; n)\geqslant \min \left( \ell +1, \left\lfloor \tfrac{1+ \sqrt{1+8k} }{2} \right\rfloor , n \right) . \end{aligned}$$

Proof

Let \(\mathscr {T} \) be a star with k leaves. We construct the set \(\mathscr {A} \) of m trees such that, for each pair of trees \(T,T'\in \mathscr {A} \), there is a leaf of \(\mathscr {T} \) contained in T and \(T'\), and no other tree from \(\mathscr {A} \). Consequently, each tree in \(\mathscr {A} \) must be assigned a distinct color. To this end, we define \(m:=\min (\ell +1,m',n)\), where \(m':=\lfloor (1+ \sqrt{1+8k})/2 \rfloor \) is the largest integer such that \({m'\atopwithdelims ()2} \leqslant k \). Then, for every pair \(\{i,j\}\) with \(1\leqslant i<j \leqslant m\), we choose a distinct leaf of \(\mathscr {T} \) and associate it with \(\{i,j\}\). The total number of such pairs is \({m \atopwithdelims ()2} \leqslant {m' \atopwithdelims ()2} \leqslant k \), hence we can indeed associate a distinct leaf to each pair.

Let now \(\mathscr {A}:= \{ T_1,\ldots , T_m\}\) be the set of trees defined as follows: for each \(i=1,\ldots ,m\), the tree \(T_i\) is defined as the tree containing all the leaves associated with pairs \(\{i,j\}\) for some \(j\ne i\), i.e., \(T_i\) is the union, for all \(j\ne i\), of edges from the root to a leaf associated with \(\{i,j\}\). Figure 6 shows an example.

Fig. 6
figure 6

An example of the non-monochromatic lower bound for \(k=6\), \(\ell =3\), and \(n=4\). The tree \(T_1\) is drawn in gray

We now have to prove that the construction is possible within the parameters. Recall that \(m\leqslant n\) so we have indeed at most n trees in \(\mathscr {A} \), and that \(m\leqslant m'\) where \(m'\) is chosen to ensure k leaves are enough. We therefore only have to show that no tree \(T_i,\ldots , T_m\) has more than \(\ell \) leaves. However, the number of leaves of each tree \(T_i\) is at most \(m-1\), as we only create at most one leaf for \(T_i\) for each \(T_j\) with \(j\ne i\). Hence, since \(m\leqslant \ell +1\), each tree has at most \(\ell \) leaves. Thus, the construction does not violate the parameters.

Finally, each tree needs a distinct color, and since there are m trees, the number of colors needed is \(m=\min (\ell +1, \lfloor \tfrac{1+ \sqrt{1+8k} }{2} \rfloor , n)\). \(\square \)

Since any CF-coloring is also an NM-coloring, the lower bound in Theorem 8 holds for CF-coloring as well. The next theorem gives a stronger lower bound for CF-coloring in the case \(\ell =2\), that is, when the objects are paths.

Theorem 9

For all n and k, there exist a tree space \(\mathscr {T} \) with k leaves and a set \(\mathscr {A} \) of at most n paths in \(\mathscr {T} \) such that any conflict-free coloring of \(\mathscr {A} \) uses at least \(\lfloor \log _2 \min (k,n)\rfloor \) colors. In other words,

$$\begin{aligned} X_{{{\,\mathrm{cf}\,}}}^{\mathrm {tree},\mathrm {paths}}(k; n)\geqslant \lfloor \log _2 \min (k,n)\rfloor . \end{aligned}$$

Proof

Let \(\mathscr {T} \) be a rooted complete binary tree of height \(h=\lfloor \log _2 \min (k,n)\rfloor \). Note that \(\mathscr {T} \) has at most \(\min (k,n)\) leaves. For each leaf v of \(\mathscr {T} \), we define \(\pi _v\) to be the path from v to the root r of \(\mathscr {T} \). Our set \(\mathscr {A} \) of objects is now defined as \(\mathscr {A}:=\{ \pi _v \mid v \text { a leaf of } \mathscr {T} \}\). (Trivially, \(|\mathscr {A} |\leqslant n\).)

Let \(c:\mathscr {A} \rightarrow \mathbb {N} \) be a conflict-free coloring of \(\mathscr {A} \). We prove that c uses at least \(h=\lfloor \log _2 \min (k,n)\rfloor \) colors by induction on the height h of \(\mathscr {T} \). If \(h=0\), then there is only one degenerate path, i.e., a path of length 0, and the claim trivially holds. Suppose now that the claim holds for a tree of height \(h\geqslant 0\), and suppose the height of \(\mathscr {T} \) is \(h+1\). Since c is a conflict-free coloring, among the paths containing the root \(r_1:=r\) of \(\mathscr {T} \), there must be a path \(\pi _1\) of unique color. Since by construction all paths in \(\mathscr {A} \) contain the root, the color of \(\pi _1\) is unique among all paths. Let \(r_2\) be the child of \(r_1\) not contained in \(\pi _1\). We now use the induction hypothesis on the subtree rooted at \(r_2\) with paths containing \(r_2\) cut above it. Among these paths, there are h that use distinct colors. Moreover, none of these path can use \(c(\pi _1)\), as this color is unique among all paths. Hence, we have indeed \(h+1\) paths using distinct colors. This concludes the proof.

\(\square \)

The following theorem is a direct consequence of the previous two.

Theorem 10

For all nk, and \(\ell \), there exist a tree space \(\mathscr {T} \) with k leaves and a set \(\mathscr {A} \) of at most n trees in \(\mathscr {T} \) with at most \(\ell \) leaves each such that any conflict-free coloring of \(\mathscr {A} \) uses at least \(\min \left( \ell +1, \left\lfloor \tfrac{1+ \sqrt{1+8k} }{2} \right\rfloor \right) \) or \(\lfloor \log _2 \min (k,n)\rfloor \) colors, whichever is higher. In other words,

$$\begin{aligned} X_{{{\,\mathrm{cf}\,}}}^{\mathrm {tree},\mathrm {trees}}(k, \ell ; n)\geqslant \max \left\{ \begin{array}{l} \min \left( \ell +1, \left\lfloor \tfrac{1+ \sqrt{1+8k} }{2} \right\rfloor \right) \\ \lfloor \log _2 \min (k,n)\rfloor . \end{array} \right. \end{aligned}$$

3 Balls in Tree Spaces and on Planar Network Spaces

In this section we restrict the objects to balls. Let \(\mathscr {N} \) be a network space,  \({{\,\mathrm{dist}\,}}:\mathscr {N} ^2 \rightarrow \mathbb {R} \) a distance function on \(\mathscr {N} \), and let \(\mathscr {A} \) be a set of balls on \(\mathscr {N} \). We define the coverage \(cov_x(B)\) of a node x by a ball \(B=B(p,\rho )\) containing x as \(cov_x(B):=\rho -{{\,\mathrm{dist}\,}}(p,x)\). Given a node x contained in at least one ball from \(\mathscr {A} \), we define \(B_x\) as the ball maximizing the coverage of x, where we break ties using an arbitrary but fixed ordering on the balls. We say that \(B_x\) is assigned to x. Note that \(B_x\) does not exist if no ball contains x, and that a ball can be assigned to multiple nodes. We will regularly use the following lemma regarding the assigned balls.

Lemma 11

Let \(\mathscr {N} \) be a network space and x be an internal node of \(\mathscr {N} \).

  1. (i)

    If \(\mathscr {N} \) is a tree space, let \(\mathscr {T}_1,\ldots ,\mathscr {T}_{{\mathrm deg}(x)}\) denote the subtrees resulting from removing x from \(\mathscr {N} \) or, more precisely, the closures of the connected components of \(\mathscr {T}{\setminus }\{x\}\). Let p be a point in some subtree \(\mathscr {T}_i\) and suppose p is contained in a ball \(B\in \mathscr {A} \) whose center lies in \(\mathscr {T}_j\) with \(j\ne i\). Then \(p\in B_x\).

  2. (ii)

    Suppose x is contained in at least one ball in \(\mathscr {A} \). Let \(\pi \) be a shortest path from x to the center of \(B_x\), and let y be a node on the path \(\pi \). Then \(B_x\) is also assigned to y, that is, \(B_x=B_y\).

Proof

Part (i) follows immediately from the definition of \(B_x\). To prove part (ii), suppose for a contradiction that \(B_y \ne B_x\) for some \(y\in \pi \). Thus, \(cov_y(B_y) \geqslant cov_y(B_x)\). Because \(\pi \) is a shortest path from x to the center of \(B_x\), we have that \(cov_x(B_x) = cov_y(B_x) - {{\,\mathrm{dist}\,}}(x,y)\). Moreover, \( cov_y(B_y) - {{\,\mathrm{dist}\,}}(x,y) \leqslant cov_x(B_y)\) because of the triangle inequality. Hence, \(cov_x(B_x) \geqslant cov_x(B_y) \geqslant cov_y (B_y) -{{\,\mathrm{dist}\,}}(x,y) \geqslant cov_y(B_x) -{{\,\mathrm{dist}\,}}(x,y) =cov_x(B_x) \). Thus \( cov_x(B_x) = cov_x(B_y)\) and \(cov_y(B_x) = cov_y(B_y)\). However, this is a contradiction, as in case of a tie, we use the fixed ordering to choose which ball to assign to a node. \(\square \)

3.1 Tree Spaces: The Upper Bound

For balls on a tree space \(\mathscr {T} \), the upper bounds from Theorem 7 with \(\ell =k\) apply. Below we improve upon these bounds using the special structures of balls. Let \(\mathscr {T} \) be a tree with t internal nodes. We present algorithms to NM-color balls on trees using two colors, and CF-color them with \(\log t +3\) colors.

Let \(\mathscr {A} \) be a set of n balls on \(\mathscr {T} \). Let also \(\mathscr {C}:=\{B=B(c,\rho ) \mid \exists x: B=B_x \}\) be the set of balls assigned to at least one internal node. Recall that an internal node x is assigned the ball maximizing the coverage of x.

NM-coloring. We use a divide-and-conquer approach to NM-color \(\mathscr {A} \). If \(t=0\), that is, \(\mathscr {T} \) consists of a single node or a single edge, we use the chain method for NM-coloring with colors green and red. If \(t>0\), then we proceed as follows. Let \(e=uv\) be an edge of \(\mathscr {T} \). Let \(\mathscr {T} _u\), respectively \(\mathscr {T} _v\), be the closure of the connected component of \(\mathscr {T} {\setminus } e\) containing u, respectively v. Recall that \(B_u\) is the ball assigned to u and \(B_v\) the ball assigned to v. We may assume that both \(B_u\) or \(B_v\) exist, for otherwise the recursion is trivial. Observe that \(B_u\) and \(B_v\) may coincide. We define

$$\begin{aligned} \mathscr {A} (u) := \{ \hbox { balls } B\in \mathscr {A} \hbox {whose center lies in } \mathscr {T} _u \} \cup \{B_u\}. \end{aligned}$$

We recursively color \(\mathscr {A} (u)\) in \(\mathscr {T} _u\), obtaining colorings of \(\mathscr {A} (u)\) with colors green and red. In the recursive calls on \(\mathscr {A} (u)\), we “clip” the balls to within \(\mathscr {T} _u\). Note that the clipped balls are still balls in the space \(\mathscr {T} _u\). This is clear for the balls whose center lies in \(\mathscr {T} _u\). The center of \(B_u\) may not lie in \(\mathscr {T} _u\), but in that case it behaves within \(\mathscr {T} _u\) as a ball with center u and radius \(cov_u(B_u)\). We handle \(\mathscr {T} _v\) similarly.

Let \(\mathscr {A} (e):= \mathscr {A} {\setminus } (\mathscr {A} (u)\cup \mathscr {A} (v))\) be the set of the remaining balls. In other words, \(\mathscr {A} (e)\) contains the balls whose center is contained in e, except for \(B_u\) and \(B_v\). We color \(\mathscr {A} (e)\), possibly swapping colors in \(\mathscr {A} (u)\) or \(\mathscr {A} (v)\), as follows.

  • If \(B_u=B_v\), we first ensure that it gets the same color in both \(\mathscr {A} (u)\) and \(\mathscr {A} (v)\) by swapping colors in one of the two subsets if necessary. We then color all balls in \(\mathscr {A} (e)\) green if \(B_u\) is red, and red if \(B_u\) is green.

  • If \(B_u \ne B_v\), let \(\pi \) be a longest simple path in \(\mathscr {T} \) containing u and v. We color \(\mathscr {A} (e) \cup \{ B_u, B_v \}\) restricted to \(\pi \) using the non-monochromatic chain method. We then possibly swap colors in \(\mathscr {A} (u)\) and \(\mathscr {A} (v)\) so that \(B_u\) and \(B_v\) match the colors they were given by the chain method.

Both cases are illustrated in Fig. 7.

Fig. 7
figure 7

On the left, we have the two different initial cases, i.e., on the top, \(B_u\ne B_v\), on the bottom, \(B_u = B_v\). In the middle, the recursive call is made. On the right, we use the two recursive colorings and swap colors if needed (Color figure online)

Theorem 12

\( X_{{{\,\mathrm{nm}\,}}}^{\mathrm {balls},\mathrm {trees}} (t; n)=2\).

Proof

The coloring obviously uses two colors. It remains to show it is non-monochromatic. We use induction on t. If \(t=0\), the coloring is non-monochromatic since it uses the chain method.

Suppose now that \(t\geqslant 1\) and that the claim holds for any tree space with fewer than t internal nodes. Let p be a point contained in at least two balls.

If p is contained in balls only of \(\mathscr {A} (v)\), only of \(\mathscr {A} (u)\), or only of \(\mathscr {A} (e)\), it is contained in at least two balls of different colors. Indeed, the colorings of \(\mathscr {A} (v)\) and \(\mathscr {A} (u)\) are non-monochromatic since they use the method on a tree with fewer than t internal nodes and we can use the induction hypothesis. \(\mathscr {A} (e)\) is non-monochromatic due to the chain method.

It remains to consider the case where p is contained in balls from at least two of the sets \(\mathscr {A} (u)\), \(\mathscr {A} (v)\), and \(\mathscr {A} (e)\). We distinguish two cases: p is contained in a ball of \(\mathscr {A} (e)\) and p is not contained in a ball of \(\mathscr {A} (e)\).

If p is contained in a ball B of \(\mathscr {A} (e)\), we can assume without loss of generality that p is also contained in a ball of \(\mathscr {A} (v)\). By Lemma 11(i), we have that \(p \in B_v\).

If \(B_u = B_v\) then all balls in \(\mathscr {A} (e)\) are given a different color than \(B_v\) hence p is contained in two balls of different color. If \(B_u \ne B_v\) then we use the chain method on \(\pi \). Hence, if \(p\in \pi \), it is contained in two balls of different color. To show that if \(p\notin \pi \) then p is still contained in two balls of different colors, it suffices to notice that for any subset of balls of \(\mathscr {A} (e)\) in which p is contained, the point \(p' \in \pi \) at distance d(up) from u is contained in the same set of balls from \(\mathscr {A} (e)\) as \(\pi \) is the longest path containing e.

On the other hand, if p is not contained in a ball of \(\mathscr {A} (e)\), then it is contained in at least one ball from \(\mathscr {A} (u)\) and one from \(\mathscr {A} (v)\). By Lemma 11 we have that \(p \in B_u \cap B_v\).

We then have two cases. If \(B_u = B_v\), then p is contained in another ball of \(\mathscr {A} (u)\) or \(\mathscr {A} (v)\), and then the coloring is non-monochromatic by the induction hypothesis. Otherwise \(B_u\) and \(B_v\) are part of the chain \(\mathscr {A} (e) \cup \{ B_u, B_v \}\), and hence p is contained in at least two balls of different color. \(\square \)

CF-coloring The second algorithm CF-colors \(\mathscr {A} \) using \(\lceil \log t \rceil + 3\) colors. As before, define \(\mathscr {C}:=\{B=B(c,\rho ) \mid \exists x: B=B_x \}\). We explain how to color \(\mathscr {C} \) and then extend the coloring to \(\mathscr {A} \). Let r be a node whose removal results in subtrees each of at most t/2 internal nodes. We color \(B_r\) (if it exists) with a color indicating the current level of recursion (which is 1 in this initial call). Let \(\mathscr {T} _1,\ldots ,\mathscr {T} _{{\mathrm deg}(r)}\) be subtrees resulting from removing r, that is, the closures of the connected components of \(\mathscr {T} {\setminus }\{r\}\). For each \(i=1,\ldots , {\mathrm deg}(r)\), we recurse on \(\mathscr {T} _i\) with the balls from \(\mathscr {C} \) whose centers lie in \(\mathscr {T} _i\). In such a recursive call, we consider a node to be an internal node when it was an internal node in the original space \(\mathscr {T} \) and when it has not yet been selected as a splitting node in a previous call. Hence, when \(t=0\) in a recursive call on a subtree \(\mathscr {T}'\subset \mathscr {T} \), then \(\mathscr {T} '\) must be a single edge both of whose endpoints have already been treated.

The recursion stops when there are no more balls left (which must be the case when we have a recursive call with \(t=0\)).

Lemma 13

The above algorithm CF-colors \(\mathscr {C} \) using \(\lceil \log t \rceil \) colors.

Proof

The number of colors used follows immediately from the fact that \(\mathscr {T} \) is split into trees of at most t/2 internal nodes. We now show the coloring is indeed conflict-free by showing that it is a unique-minimum coloring: for any point p the minimum color among the colors of the balls containing p is unique. Let \(p\in \mathscr {T} \) be a point contained in two balls \(B_1=B(p_1,\rho _1)\) and \(B_2=B(p_2,\rho _2)\) both of color i. We show that this implies the existence of a ball containing p with a lower color value. Let \(v_1\) be the node \(B_1\) is assigned to, and \(v_2\) the node \(B_2\) is assigned to. Since \(B_1\) and \(B_2\) have the color i, they were contained in different trees when they were colored in the recursive process. Let \(v_0\) be the node that disconnected \(v_1\) and \(v_2\) and let \(B_0\) be the ball assigned to \(v_0\). Note that \(c(B_0)<i\).

We prove that \(p\in B_0\). Let \(\pi \) be the unique simple path between p and \(v_0\). It cannot be the case that both \(p_1 \in \pi \) and \(p_2 \in \pi \). Suppose without loss of generality that \(p_2 \notin \pi \). Since \(p\in B_2\), we have that \(cov_{v_0}(B_2) \geqslant {{\,\mathrm{dist}\,}}(p,v_0)\). And since \(cov_{v_0}(B_0) \geqslant cov_{v_0}(B_2)\), we have that \(p\in B_0\), concluding the proof. \(\square \)

We now wish to extend the coloring to balls in \(\mathscr {A} {\setminus } \mathscr {C} \). To this end, define \(\mathscr {T} ' := \mathscr {T} {\setminus } \cup \, \mathscr {C} \) to be the part of \(\mathscr {T} \) that remains after removing all points covered by the balls in \(\mathscr {C} \).

We finish the coloring with three more colors (using the chain method for CF-colorings) as explained next, resulting in \(\lceil \log t \rceil +3\) colors. We use the following lemma to show that the remaining balls can be reduced to intervals on disjoint lines. Note that the lemma does not use any assumption of tree spaces and can hence be applied also to planar network spaces.

Lemma 14

For any ball \(B\notin \mathscr {C} \), we have \(\{p \in B \mid p\notin \cup \, \mathscr {C} \} \subseteq e, \) where e is the edge containing the center of B.

Proof

Suppose for a contradiction that there is a point \(p\notin e\) contained in B but not in \(\cup \, \mathscr {C} \). Consider the endpoint v of e belonging to a geodesic from the center of B to p. We claim that \(cov_v(B)>cov_v(B_v)\), contradicting the definition of \(B_v\). Indeed, \(cov_v(B)>{{\,\mathrm{dist}\,}}(v,p)\) (since v lies on the geodesic from B’s center to p) and \(cov_v(B_v)<{{\,\mathrm{dist}\,}}(v,p)\) (since \(p\not \in \mathscr {C} \) and, hence, \(p\notin B_v\)). \(\square \)

Using these lemmas, we can upper bound the chromatic number as follows.

Theorem 15

\(X_{{{\,\mathrm{cf}\,}}}^{\mathrm {tree},\mathrm {balls}} (t; n) \leqslant \lceil \log t \rceil +3\).

3.2 Tree Spaces: The Lower Bound

Lemma 16

\(X_{{{\,\mathrm{cf}\,}}}^{\mathrm {tree},\mathrm {balls}} (t; n) \geqslant \left\lceil \log (t+1) \right\rceil .\)

Proof

Let \(\mathscr {T} \) be as follows. We take \(t+2\) points \(p_1,\ldots ,p_{t+2}\) in the plane, with \(p_i=(i, 0)\) for each \(i=1,\ldots , t+2\), and we link consecutive points with a unit distance segment. We then take \(t+2\) additional points \(p'_1,\ldots , p'_{t+2}\), with \(p'_i=(i,t+2)\), and for each \(i=1,\ldots ,t+2\) we link \(p_i\) and \(p'_i\) with a segment of length \(t+2\). Note that \(p_1\) and \(p_{t+2}\) do not count as internal nodes as their degree is two. Finally, we place \(t+1\) balls \(B_1=B(c_1,t+2),\ldots , B_{t+1}=B(c_{t+1}, t+2)\), for all \(i=1,\ldots ,t+1\), with \(c_i=(i+\frac{2}{3}, 0)\), see Fig. 8.

Fig. 8
figure 8

Example of the lower bound construction with \(t=3\). For clarity purposes, only \(B_2\) is displayed, in gray

Consider the hypergraph \(\mathscr {H}\) whose nodes are the balls \(B_i\), and whose hyperedges are the subsets of balls such that there is a point \(p\in \mathscr {T} \) contained in exactly that subset (and no other balls). We claim (and prove below) that the set of hyperedges is exactly the set \(\{ \{ B_i,B_{i+1},\ldots , B_j \} \mid i \geqslant j \}\). In other words, there is a hyperedge for a subset of balls if and only if there is an interval on the x-axis containing exactly the centers of these balls. Hence, we can apply the \(\left\lceil \log (t+1) \right\rceil \) lower bound for CF-coloring points with respect to intervals [8].

Observe that any p with y-coordinate 0 is contained in all balls, we can hence disregard those points. To prove the claim, note that if \(c_i\) is the ball center nearest to p, then \({{\,\mathrm{dist}\,}}(p,c_1)> {{\,\mathrm{dist}\,}}(p,c_2)> \cdots > {{\,\mathrm{dist}\,}}(p,c_i)\) and \({{\,\mathrm{dist}\,}}(p,c_{i+1})> \cdots > {{\,\mathrm{dist}\,}}(p,c_{t+2})\), which implies that any hyperedge is of the form \(\{B_i,B_{i+1},\ldots ,B_j\}\). On the other hand, the point \((\left\lfloor (j+i)/2 \right\rfloor ,t+2-(j-i)/2)\) is contained in exactly the balls \(B_i,B_{i+1},\ldots ,B_j\). \(\square \)

3.3 Planar Network Spaces

NM-coloring. We first explain how to NM-color balls on a planar network space \(\mathscr {N} \). Let again \(\mathscr {C} \) be the set \(\{B=B(c,\rho ) \mid \exists x: B=B_x \}\). We create a graph \(\mathscr {G}_\mathscr {C} \) whose node set is \(\mathscr {C} \) and whose edge set is defined as follows: there is an edge between B and \(B'\) if and only if there is an edge \(vv'\) in \(\mathscr {T} \) with \(B_v=B\) and \(B_{v'}=B'\). It follows from Lemma 11 that for any ball B, the set of nodes of \(\mathscr {N} \) to which B is assigned, together with the edges between these nodes, is a connected set. Therefore, \(\mathscr {G}_\mathscr {C} \) is planar as well since its nodes correspond to disjoint connected subspaces in the planar space \(\mathscr {N} \). We now use the Four Color Theorem to color \(\mathscr {G}_\mathscr {C} \) and we give each ball in \(\mathscr {C} \) the same color as the corresponding node in \(\mathscr {G}_\mathscr {C} \).

Lemma 17

The coloring on \(\mathscr {C} \) is non-monochromatic and uses at most four colors.

Proof

It is clear that the coloring uses at most four colors. Now let p be a point contained in two balls \(B_1\) and \(B_2\) of the same color. Let \(v_1\) and \(v_2\) be nodes of \(\mathscr {N} \) with \(B_1=B_{v_1}\) and \(B_2=B_{v_2}\). Let \(\pi _1\) and \(\pi _2\) be two shortest paths between p and \(v_1, v_2\), respectively. If all the nodes in \(\pi _1 \cup \pi _2\) are either assigned \(B_1\) or \(B_2\), then there is an edge between \(B_1\) and \(B_2\) in \(\mathscr {G}_\mathscr {C} \) and hence \(B_1\) and \(B_2\) are given different colors. Therefore there must be a node v in \(\pi _1 \cup \pi _2\) (we assume without loss of generality that \(v\in \pi _1\)) with \(B_v\notin \{ B_1, B_2 \}\) and \(c(B_v)=c(B_1)\). Note that if \(c(B_v)=c(B_1)\) for all \(v\in \pi _1\), then there must be an edge between two balls of the same color in \(\mathscr {G}_\mathscr {C} \) which is a contradiction, hence there must be a vertex \(v\in \pi _1\) with \(c(B_v)\ne c(B_1)\). Since \(\pi _1\) is a shortest path between \(v_1\) and p, and since \(v\in \pi _1\), we have that \(\pi _1\) contains a shortest path between v and p. Moreover, \(cov_v(B_v) \geqslant cov_v(B_1) \geqslant d(v,p)\), which implies that \(p \in B_v\) and concludes the proof. \(\square \)

We now wish to extend the coloring to balls in \(\mathscr {A} {\setminus } \mathscr {C} \). To this end, define \(\mathscr {N} ' := \mathscr {N} {\setminus } \cup \, \mathscr {C} \) to be the part of \(\mathscr {N} \) that remains after removing all points covered by the balls in \(\mathscr {C} \). The proof of the following lemma is similar to the proof of Lemma 14.

Lemma 18

Consider a ball \(B\in \mathscr {A} {\setminus }\mathscr {C} \), and let \(B' := B \cap \mathscr {N} '\). Then \(B'\) is contained in a single edge of \(\mathscr {N} '\).

For each edge e of \(\mathscr {N} '\), let \(\mathscr {A} (e)\) denote the set of balls contained in e. Let u and v denote the endpoints of the edge in \(\mathscr {N} \) containing e. We color the uncolored balls in e using the chain method with two colors different from \(c(B_u)\) and \(c(B_v)\). We have now colored the balls in \(\mathscr {C} \) as well as the balls in \(\mathscr {A} {\setminus }\mathscr {C} \) that lie at least partially in \(\mathscr {N} '\). Next we explain how to color the remaining balls, which are fully covered by the balls in \(\mathscr {C} \).

Lemma 19

For any uncolored ball B, there is a set of at most three colored balls such that B is contained in their union.

Proof

Any uncolored ball B is contained in \(\cup \, \mathscr {C} \). If B is fully contained in a single edge e of \(\mathscr {N} \), it must be covered by the two balls from \(\mathscr {C} \) extending the farthest into e, starting from each of the two endpoints. If not, let v be a node contained in B. Now \(B {\setminus } B_v\) is contained in a single edge e of \(\mathscr {N} \) and so \(B{\setminus } B_v\) can be covered by two balls (as just explained), which implies that B can be covered by three balls. \(\square \)

Using this lemma, we can easily finish the NM-coloring by coloring each uncolored ball with a color different from the three colored balls provided by Lemma 19.

Theorem 20

\(X_{{{\,\mathrm{nm}\,}}}^{\mathrm {planar},\mathrm {balls}} (t; n) = 4\).

Proof

The coloring obviously uses four colors at most. Moreover, it is easy to see the coloring is non-monochromatic. It remains to show that there is an instance requiring at least four colors. To that purpose, let \(\mathscr {N} \) be an embedding of \(K_4\) where all edges have length one. Then, for each node v of \(\mathscr {N} \), we create the ball B(v, 2/3). Since no two balls can have the same color, we need at least four colors. \(\square \)

CF-coloring We now explain how to CF-color balls on a planar network. As before, define \(\mathscr {C}:= \{B=B(c,\rho ) \mid \exists x: B=B_x \}\). We first CF-color \(\mathscr {C} \) using the following recursive algorithm introduced by Smorodinsky [15]: we select a maximum independent set in \(C_1:=\mathscr {C} \), we give it a color indicating the current level of recursion (which is 1 in this initial call), place all uncolored balls in \(C_2\), and recurse. We claim that for all i, the Delauney graph \(D_i:=(C_i,E_i)\) on the balls in \(C_i\) is planar, where \(E_i:= \{ \{B_1, B_2\} \mid \exists p\in \mathscr {N}: p \in B_1 \cap B_2 \text { and } \forall B\notin \{ B_1, B_2\} : p \notin B \} \).

Lemma 21

\(D_i\) is planar.

Proof

We draw \(D_i\) using the drawing of \(\mathscr {N} \) as follows: each ball is represented by its center. Then, for every edge in \(D_i\), we find a witness, that is a point contained in the intersection of the two balls and not in any other ball. We finally draw the edge as two geodesics on \(\mathscr {N} \): one from one endpoint to the witness point, and the other from the witness point to the other endpoint.

We claim that this drawing is plane. Suppose by contradiction that it is not the case and there is a crossing between the two edges \(B_1B_3\) and \(B_2B_4\). Suppose also that the endpoints of the two edges are distinct: the argument when an endpoint is shared is similar. Since we based our drawing on \(\mathscr {N} \), a planar graph, the point where the two edges cross must be a node x in \(\mathscr {N} \). Let \(w_{13}\) be the witness of the edge \(B_1B_3\) and \(w_{24}\) the witness of \(B_2B_4\). Figure 9 shows the two crossing edges, with the crossing node x in the middle, and the two witnesses \(w_{13}\) and \(w_{24}\) used to draw the geodesics.

Fig. 9
figure 9

We suppose for a contradiction that the edges \(B_1B_3\) and \(B_2B_4\) cross. The crossing point is a node x of \(\mathscr {N} \). Let \(w_{13}\) be the witness of the edge \(B_1B_3\) and \(w_{24}\) the winess of \(B_2B_4\)

Suppose, without loss of generality, that the distance from x to \(w_{24}\) is greater than or equal to the distance from  x to \(w_{13}\). Thus, the distance from the center of \(B_1\) to \(w_{24}\) is greater than or equal to that to \(w_{13}\). Hence, \(w_{13}\) is also contained in the ball \(B_1\), which contradicts the definition of a witness. Thus, the drawing is plane. \(\square \)

Using this lemma and the Four Color Theorem, we can find an independent in \(D_i\) of size at least \(|C_i|/4\). Thus, \(|C_{i+1}|\leqslant (3/4)\cdot |C_i|\), which implies that the total number of colors for \(\mathscr {C} \) is \(\lceil \log _{4/3} t \rceil \). (Note: Finding a four-coloring can be done in quadratic-time by the algorithm of Robertson et al. [13]. Alternatively, we can use a linear-time algorithm [6] to find an independent set of size at least n/5, leading to \(\lceil \log _{5/4} t \rceil \) colors.)

After coloring \(\mathscr {C} \), we still need to color the balls in \(\mathscr {A} {\setminus } \mathscr {C} \). Using Lemma 14, we have that for any such ball B, the set of points contained in B but not in any ball in \(\mathscr {C} \) is contained in one edge of \(\mathscr {N} \). Therefore, if we cut \(\cup \, \mathscr {C} \) out of \(\mathscr {N} \), the remaining space is a union of disjoint segments, and any object that is not colored is contained in at most one segment. We can therefore use the chain coloring on each segment with the two additional colors and the dummy one.

Finally, any point in \(\cup \,\mathscr {C} \) is contained in a ball in \(\mathscr {C} \) of unique color, and any point not in \(\cup \,\mathscr {C} \), is contained in at most one ball of each of the two additional colors. Therefore, the coloring is conflict-free. This yields the following theorem.

Theorem 22

\(X_{{{\,\mathrm{cf}\,}}}^{\mathrm {planar},\mathrm {balls}} (t; n) \leqslant \lceil \log _{4/3} t \rceil +3\).

4 Concluding Remarks

We studied NM- and CF-colorings on network spaces, where the objects to be colored are connected regions of the network space. We showed that the number of colors can be bounded as a function of the complexity (which depends on the type of space and of objects) of the network space and the objects, rather than on the number of objects. All our bounds are tight up to some constants, except for \(X_{{{\,\mathrm{cf}\,}}}^{\mathrm {tree},\mathrm {trees}} (k,\ell ; n)\) where the  upper bound is a factor \(\ell \) away from the lower bound. Closing this gap remains an open problem. It would also be interesting to find bounds on general connected objects on any network space, or other settings where the number of colors depends on the complexity of the space and objects rather the number of objects.