• Aucun résultat trouvé

Flooding games on graphs

N/A
N/A
Protected

Academic year: 2022

Partager "Flooding games on graphs"

Copied!
20
0
0

Texte intégral

(1)

Flooding games on graphs

A. Lagoutte

a

M. Noual

b

E. Thierry

b

a ENS Cachan, Computer Science Department, Cachan, France

b LIP, Université de Lyon, CNRS UMR5668, ENS Lyon, UCB Lyon 1, France

Abstract

We study a discrete diusion process introduced in some combinatorial puzzles called Flood-It andMad Virus that can be played online [4,5] and whose computational complexities have been recently studied [1,6]. Originally dened on regular boards, we show that studying their dynamics directly on general graphs is valuable: we synthesize and extend previous results, we solve the 2-Free-Flood-Itvariant (open problem in [1]) by computing a graph radius and we characterize the underlying graphs in Flood-Itand Mad Virus as particular subclasses of planar graphs.

Keywords: combinatorial puzzle, colored graph, neighborhood contraction, planar graphs.

1 Introduction

There exists a family of combinatorial games (Flood-It [4], Mad Virus [5],

Honey-Bee [2]) which rely on a common discrete diusion dynamics. In this paper, we study the graph versions of those ooding games that have been originally dened on boards whose tiles are regular polygons (squares for

Flood-It, hexagons for Mad Virus and Honey-Bee).

The game called Flood-It is played by one player on a k-coloured board where one particular tile S (called ooding tile) is xed. A colored component is a maximal set of connected tiles with the same color. The aim of the game is to ood the entire board as fast as possible. At each move, the player chooses a colour c. The coloured component containing S is changed into colour c and as a result merges with all adjacentc-coloured components.

After a nite number of moves, all tiles end with the same colour, the board is ooded (i.e. monochromatic). A sequence of moves is here a sequence of colors. Free-Flood-It[1] is a version ofFlood-Itin which the player may also choose the ooding tile at each move. A sequence of moves is thus an ordered list of couples (ci, Ti)such that ci is the colour andTi the tile that are chosen

(2)

at move numberi. In both versions, a ooding sequence is a sequence of moves ooding the entire board.

S S S

S S

Figure 1. Flood-Iton a square board: a ooding sequence green,yellow,green,pink.

Those ooding games have a natural generalization to connected undirected graphs. In ak-coloured connected graphG= (V, E, κ)with colorationκ:V → {1, . . . , k}, vertices of V (resp. edges of E) play the same role as tiles (resp.

edges of tiles) of the board. Thus, ac-coloured componentC ofG(1≤c≤k) is a maximal set of connected vertices that have the same colour. The problem k-Flood-It (resp. k-Free-Flood-It), denotedk−FI(resp. k−FFI) takes ak- coloured connected graph as input and consists in nding a shortest ooding sequence. Board ooding games are now particular instances of the graph ooding games k-FI and k-FFI by considering the graphs of adjacent tiles.

Recently two studies have investigated the computational complexity for solving those puzzles. In [1], Cliord et al. focus onFlood-ItandFree-Flood- Itonly for square boards composed ofn×nsquare tiles. They show that when k ≥3, both decision problems associated to k-FI and k-FFI are NP-complete on the square boards (and thus for general graphs). When k = 2, they note that 2-FI can be solved in polynomial time since there is no choice for the ooding sequence (alternation of the two colours), but solving 2-FFI for the square board is left open. Independently, in [6], Fleischer and Woeginger have studied the Honey-Bee-Solitaire dened on arbitrary graphs which is exactly the general Flood-It game dened above, but they did not tackle the

Free-Flood-It version. They have focused on particular classes of graphs: co- comparability graphs, split graphs, trees, yielding other NP-hardness proofs.

In this paper, we present new results on those ooding games on graphs, including unpublished [9,10]. In Section 2, we put forward hard instances of k-FI and k-FFI based on trees and explain how they encapsulate and extend previously known results. All those hard instances have at least three colors and a vertex of degree at least three. It is then shown that as soon as the number of colors or the maximum degree of the graph is bounded by 2, one can solve the puzzle in polynomial time thanks to shortest or longest path computations. We thus solve an open problem of [1] asking for the complexity of 2-FFI, stated for square boards and now solved for general graphs. In Section 3, we re-focus on the game on boards and show that the underlying

(3)

graphs can be fully characterized as particular subclasses of planar graphs.

Section 4concludes the paper with some open questions.

2 Complexity results

For any k-coloured graph G = (V, E, κ) we dene the reduced graph G˜ = ( ˜V ,E,˜ κ)˜ in which all c-coloured components (c ∈ {1, . . . , k}) have been re- duced to one c-coloured vertex and any two vertices v, u∈V˜ are connected if and only if they belong to adjacent coloured components of G. By the maxi- mality of the coloured components ofG, the extremities of any edge inG˜have dierent colours, κ˜ denes a proper k-coloration of G˜. Note that the reduced graph G˜ is a minor of Gsince it can be obtained by edge-contractions. It can be easily constructed from GinO(|E|)time: any graph traversal which iden- ties the coloured components by exploring at rst vertices with an identical colour is suitable (e.g. see [10]). In addition, a sequenceS of moves obviously oods the entire graph Gif and only if S also oods entirely its reduced ver- sion. In terms of reduced graphs, a ooding sequence is a sequence leading to a singleton as last reduced graph. A ooding sequence for Free-Flood-It and 2 colours is illustrated on Figure 2 with both the original dynamics and the associated sequence of reduced graphs. Note that for 2 colours, each move is fully specied by the ooded vertex whose new colour is forced.

a b

c d

e

j i g h f

a b c d e

f

g h

j i

a b c d e

f

g h

j i

a b c d e

f

g h

j i

c d

e

a i g

a g

d

g g

g

g

g d

d

a b c d e

f

g h

j i

Figure 2. A 2-FFI instance and a sequence of moves over an initial colouring along with the sequence of associated reduced graphs.

First we present hardness complexity results where we link recently pub- lished results, revisit their proofs and extend them to get new results. We call willow trees the trees composed of a set of disjoint paths joined by a vertex adjacent to one extremity of each path.

(4)

Proposition 2.1 For any xed k ≥ 3, the decision versions of k-FI and k- FFI are NP-complete on willow trees.

The proof relies on a reduction from a particular version of the shortest common supersequence problem. Though it mixes several arguments used in [1,6], it rene their results (see the appendix for a discussion).

It is clear that any class of coloured graphs whose reduced graphs contain those trees with proper colorations, should win back the hardness results. It is formalized in the next corollary.

Corollary 2.2 Let G be a class of graphs such that there exists a polynomial P(.) and a polynomial time algorithm nding for any willow tree T with n vertices a graph G ∈ G with O(P(n)) vertices that can be reduced to T by edge-contractions. Then for any xed k ≥3, k-FI andk-FFIare NP-hard and their decision versions are NP-complete.

It can be easily checked that the class of square grids (resp. triangular grids, hexagonal grids) underlying the board game with square tiles (resp.

hexagonal tiles, triangular tiles) satises the conditions of Corollary 2.2. A way to embed trees is illustrated on Figure 3. This schematic gure gives an idea of the shapes and the positions of the connected subsets that once contracted into single vertices will give the willow tree on the left. Note that the corollary does not mention colorations (which can be put later), here grey and white zones just indicate the connected components to contract.

It yields an unied proof that the original board gamesFlood-Itand Mad Virus are NP-hard as soon as there are 3 colours (which was unknown, but likely, for Mad Virus).

a b c

d e

g f

a

f

c d

e g

b d

e a

b c

f g

a

g b c e f

d

a willow tree square grid (Flood-It [4]) triangular grid (Mad Virus [5]) hexagonal grid

Figure 3. Willow trees can be obtained by contracting connected subsets in dierent kinds of grids.

Now we show that if the maximum degree in the graph is at most 2 (paths or cycles) or the number of colors is at most 2, one can nd some solution in polynomial time

(5)

Proposition 2.3 k-FI on a cycle of order n (for unbounded k) can be solved in time O(n2) or O(NlogN) where N is the number of pairs of vertices with the same color.

The boundO(n2)is obtained by dynamic programming and the other one O(NlogN) where N ≤ n2 is achieved by computing the height of a partial order of dimension 2. The same complexities apply to paths (see Appendix).

Now we consider general graphs but with 2 colors only. As before we work exclusively with the reduced graphs. Each move is only dened by the choice of a vertex s and the new reduced graph is obtained by contracting {s} ∪N(s) into a single vertex (still denoteds). We denote this neighborhood contraction by G = (V, E) −→s G0 = (V0, E0) where V0 = V \ N(s) and E0 = (E\ {su∈E|u ∈N(s)})∪ {sv|∃u ∈N(x), uv ∈E}. Now the question is the number of neighborhood contractions sucient to reduce the initial graph into a singleton.

Let us recall a few denitions about distances in an undirected graphG= (V, E). LetdG(u, v)be the distance betweenuandvinG. Vertices at distance d fromu are denoted NGd(u) ={v ∈V | dG(u, v) =d}. The eccentricity of u is dened as εG(u) = max{dG(u, v) | v ∈ V}. The radius of G is R(G) = min{εG(u)| u∈V} and its center is C(G) = {u∈V |εG(u) =R(G)}.

The following obvious result allows to derive that 2−FI is in P:

Lemma 2.4 The number of neighborhood contractions at vertex s required to reduce a graph to a singleton is exactly the eccentricity εG(s). As a con- sequence, solving 2−FI comes to computing the eccentricity of the ooding vertex s in the initial reduced graph, and the shortest ooding sequence for 2−FFI is always at most the radius of the initial reduced graph.

Then thanks to a couple of lemmas (detailed in the Appendix), we show the intuitive result that a neighborhood contraction does not change a lot the distances and thus the radius of the graph.

Lemma 2.5 Let G = (V, E) and G0 = (V0, E0) such that G −→s G0. Then, R(G)−1≤ R(G0) ≤ R(G). Moreover, if s ∈ C(G), then R(G0) = R(G)−1 and s ∈C(G0).

As a consequence of the two preceding lemmas, we get:

Lemma 2.6 A graph G= (V, E)can be reduced to a singleton byR(G)neigh- borhood contractions and no less. To do so, one can choose any vertex inC(G) to perform all the contractions.

Now if we come back to 2−FFI, since the reduced graph of an arbitrary

(6)

coloured graph may be constructed in linear time, by applying the previous lemma reinterpreted in terms of ooding sequence, we settle the complexity of the puzzle (solving an open problem in [1]):

Proposition 2.7 2-FFI is in P: it can be solved in time O(nm), i.e., the time needed to compute the radius of the associated reduced graph (and to nd a vertex in the center of this graph).

3 Characterisation results

In this section we turn back to the original ooding game on coloured boards and show that their reduced graph have a strong structure. We are able to characterize the reduced graphs for square boards, and this can be extended to some other boards: q-boards and boards with holes (see Appendix).

Let G = (V, E) be a planar graph and G0 = (V, E0) be any multigraph obtained by duplicating some edges ofG. Then, any planar map ofG0 is called a multiple planar map of G. In particular any planar map of G is a multiple planar map of G. The idea is that, in some cases, a multiple planar map of G has useful properties (in particular, concerning the number of edges on each face) that no planar map of G has. With several lemmas (see Appendix), we obtain the following characterization in the case of square boards:

Proposition 3.1 Ak-coloured graphGis the reduced graph of somek-coloured square boardB if and only if it is ak-colorable planar graph such that the graph G0 obtained by recursively removing vertices of degree 1 in G has a multiple planar map in which all faces have no more than 4 edges.

4 Conclusion

Though board congurations have a very particular structure as shown in Section 3, we have illustrated that studying the board ooding games under a graph point of view is valuable. It brought a proof that 2-FFIis polynomial by putting forward the core parameter which is the radius of a graph. Among the questions directly left open in our work, we conjecture that solving k-FFI remains polynomial for cycles and unbounded k. As a matter of fact, one can question whether k-FI and k-FFI really have dierent complexities up to a polynomial reduction, e.g. is there a class of graphs where one problem can be shown polynomial whereas the other one is NP-hard ? More generally, one can wonder on which classes of graphs solving k-FI and k-FFI is polynomial for unbounded k.

(7)

References

[1] D. Arthur and R. Cliord et M. Jalsenius et A. Montanaro et B. Sach. The complexity of ood lling games. In FUN'2010, volume 6099 of LNCS, pages 307318. Springer, June 2010.

[2] A. Born. Flash application for the computer game "biene" (honey-bee), 2009.

http://www.ursulinen.asn-graz.ac.at/Bugs/htm/games/biene.htm.

[3] A. Darte. On the complexity of loop fusion. Parallel Computing, 26(9):1175 1193, 2000.

[4] Flood-It (ash game). http://floodit.appspot.com/.

[5] Mad Virus (ash game). http://www.bubblebox.com/play/puzzle/539.htm.

[6] R. Fleischer and G. J. Woeginger. An algorithmic analysis of the honey-bee game. In FUN'2010, volume 6099 of LNCS, pages 178189. Springer, June 2010.

[7] M. R. Garey and D. S. Johnson. Computers and Intractability: A Guide to the Theory of NP-Completeness. W. H. Freeman, 1979.

[8] D. E. Knuth. The Art of Computer Programming, volume 3. Addison-Wesley, 1973. Section 5.1.4.

[9] A. Lagoutte. 2-free-ood-it is polynomial. arxiv, LIP, CNRS UMR5668, ENS Lyon, UCB Lyon 1, August 2010. http://arxiv.org/abs/1008.3091.

[10] A. Lagoutte. Jeux d'inondation dans les graphes. Hal archive, LIP, CNRS

UMR5668, ENS Lyon, UCB Lyon 1, August 2010.

http://hal.archives-ouvertes.fr/hal-00509488_v1/.

[11] T. Nishizeki and S. Rahman. Planar Graph Drawing, volume 12 of LNSC. World Scientic Publishing Company, 2004.

[12] E. Verbin. Is this game np-hard ? (Sariel's blog), May 2009.

http://valis.cs.uiuc.edu/blog/?p=2005.

(8)

A Introduction

Board ooding games as particular instances of graph ooding games.

Board ooding games are now particular instances of the graph ooding gamesk-FI andk-FFIby considering the graphs of adjacent tiles as illustrated on Figure A.1.

square boardsquare grid hexagonal boardtriangular grid triangular boardhexagonal grid

Figure A.1. Three types of boards and their underlying graphs (in bold) where each vertex corresponds to a tile.

State of the art.

Recently two studies have investigated the computational complexity for solving those puzzles. In [1], Cliord et al. focus onFlood-ItandFree-Flood- Itonly for square boards composed ofn×nsquare tiles. They show that when k ≥3, both decision problems associated to k-FI and k-FFI are NP-complete on the square boards. As a direct consequence, the same hardness results hold for k-FI and k-FFI for arbitrary graphs. When k = 2, they note that 2-FI can be solved in polynomial time since there is no choice for the ooding sequence (alternation of the two colours), but solving 2-FFI for the square board is left open. Several other results about approximability and bounds are investigated there. Independently, in [6], Fleischer and Woeginger have studied the Honey-Bee-Solitaire dened on arbitrary graphs which is exactly the generalFlood-Itgame that we have dened above for graphs, but they did not tackle the Free-Flood-Itversion. They have focused on particular classes of graphs, showing that k-FI is: polynomial for co-comparability graphs and unbounded k and for split graph with xed k, NP-hard for split graphs with unboundedk and for trees with xedk≥3. Thus it yields two other proofs of NP-hardness of k-FI for arbitrary graphs. As a matter of fact, the rst proof that k-FI was NP-hard on square boards was given by Verbin [12] for k ≥ 6 and he was close to the case of trees.

(9)

B Complexity results

Transformation of the reduced graph after a move.

If G = (V, E, κ) is a reduced graph with proper coloration κ, the new reduced graph after a move using s as ooded vertex and c as new colour is G0 = (V0, E0, κ0) where:





V0 =V \Nc(s) with Nc(s) = {v ∈V | sv∈E and κ(v) =c}

E0 = (E\ {sv ∈E |κ(v) = c})∪ {sw | ∃v ∈Nc(s), vw ∈E}

κ0(s) = cand ∀v 6=s, κ0(v) = κ(v) NP-completeness for trees.

Proposition B.1 For any xed k ≥ 3, the decision versions of k-FI and k-FFI are NP-complete on willow trees.

Proof The idea is to use a reduction from a variant of the problemSCSwhich consists in nding a shortest common supersequence of a set of words on an alphabet Σ(NP-complete decision version denoted [SR8] in [7]). This variant considers a xed alphabet Σ = {a1, a2, . . . , ak} with k ≥ 3, and restricts the problem SCSto sets of words that do not contain any word starting with letter a1 nor any word having two identical consecutive letters. It is used in [6] and denoted MSCS (Modified SCS). In [3], Darte has shown that for any xed k ≥3, the associated decision version remains NP-complete.

We rst show that k-FI` (with ` as the input threshold for the decision version) is NP-complete. Let W = {w1, . . . wm} be a set of words over the alphabet Σ = {a1, . . . , ak}. Suppose W is an instance of SCS. Then, no word wi starts with letter a1 and thus we may construct the following k- coloured reduced tree A. A contains one root vertex r of colour c1 and m linear branches. Branch Bi represents wordwi. Its rst vertex is connected to vertex r and to the second vertex ofBi. The second vertex of Bi is connected to the rst vertex of Bi and to its third, and so on Vertex number qof branch Bi has colour cj if letter number q of word wi isaj. By the hypotheses made, the colours given to each vertex do indeed dene a proper k-coloration. The root vertex of A, r, is the start vertex of the flood-it game. Then, it is easy to see that a word w=aσ1aσ2. . . aσ` is a common supersequence ofW, if and only if cσ1, cσ2. . . cσ` is a ooding sequence of colours of A.

Now, we show that the free version of the game is NP-complete. The diculty here is that the player may choose a sequence of colours that covers

(10)

all letters of all words wi but in an order that does not respect the order according to which they appear in these words. To make sure this does not happen, we modify the tree A built in the previous paragraph. We suppose that all words in W have no more thann letters. LetA now be the tree that still has the same root vertex r as above but has n+ 1copies of each branch Bi. On one hand, as above, any common supersequence w =aσ1aσ2. . . aσ` of W yeilds a ooding sequence of moves(cσ1, r),(cσ2, r). . .(cσ`, r)that oods A entirely from vertexronly. On the other hand, the copies of each branch make sure that any optimal sequence of moves must ood from vertex r and thus yeild a common supersequence of W. Indeed, suppose that S is an optimal ooding sequence of moves of length`. Then, all copies of any branchBimust be ooded similarly (in particular, if one of them is ooded entirely through vertex r, then they all are). Suppose one move ofS chooses as ooding vertex vertex number q > 0 inside a copy of branch Bi. Then, for every one of the n+ 1copies ofBi there is a move ofS that chooses the vertex numberq >0of this branch as ooding vertex. Each of these n+ 1 moves oods at most two vertices (verticesq−1andq+1of the branch). But, since copies ofBihave no more thann vertices,n+ 1is strictly more than the number of moves needed to ood all n+ 1 copies of Bi chosing r as ooding vertex. As a consequence S is not optimal. Since this is a contradiction, any optimal ooding sequence contains only moves whose ooding vertex is r.

Remark B.2 The proof of Proposition B.1mixes some arguments used in the literature. First the problem SCS is at the heart of the NP-hardness proofs about square grids [1,12] and trees [6]. Then the NP-hardness of k-FI is proved for willows trees in [6]. However this work fails to get the NP-completeness results about the decision problem because the authors re-design a reduction from SCS to MSCS which is a Turing reduction but not a many-to-one (Karp) reduction (should one use their reduction, adjusting the integer decision parameter for MSCS requires some knowledge about the number of 0 in a shortest common supersequence for the SCS instance). The reduction used in [1] to prove the NP- completeness fork-FIon square grids is slightly dierent from the construction we suggest on Figure 3: our reduced graphs exactly t the initial willow trees, whereas their reduced graphs contain many twin vertices and an extra gadjet.

Nonetheless both reductions are close: up to quotienting by the twin relation, they get willow trees and they could get rid of their gadjet by using MSCS instead of SCS as starting problem. Finally the duplication argument used to prove the hardness of k-FFI on those trees is the same as in [1] but we show that n+ 1 copies are sucient instead of the 2|Σ|n+ 1 copies of [1].

(11)

Polynomial algorithm for cycles.

Proposition B.3 k-FI on a cycle of order n (for unbounded k) can be solved in time O(n2) or O(NlogN) where N is the number of pairs of vertices with the same color.

Proof The reduced graph of a k-coloured cycle is still a cycle which can be compute in O(n). Thus we assume that we start with a proper k-coloration κ over a cycle with V = {0,1, . . . , n −1} and E = {i(i+ 1) | 0 ≤ i <

n} ∪ {(n−1)0}. Suppose w.l.o.g. that vertex 0 is the ooding vertex.

One can get theO(n2)complexity by dynamic programming. Let us dene the following variables:





F(i, j) = min. nb. of moves to ood {j, j+ 1, . . . , n−1,0,1, . . . , i} ∀ 1≤i < j≤n−1, F(i,0) = min. nb. of moves to ood {0,1, . . . , i} ∀ 0≤i≤n−1, F(0, j) = min. nb. of moves to ood {j, j + 1, . . . , n−1,0} ∀ 0≤j ≤n−1.

Those values can be computed thanks to the next simple recursive equations (with the convention (n−1) + 1 = 0):













F(0,0) = 0

F(i,0) =F(i−1,0) + 1 for all 1≤i≤n−1, F(0, j) =F(0, j+ 1) + 1 for all 1≤j ≤n−1,

F(i, j) = min{F(i−1, j) + 1, F(i, j+ 1) + 1} if 1≤i < j ≤n−1 and κ(i)6=κ(j), F(i, j) =F(i−1, j+ 1) + 1 if 1≤i < j ≤n−1 and κ(i) =κ(j).

The minimum length of a ooding sequence is thenmin0≤i≤n−1F(i, i+ 1). Its computation only requiresO(n2)time and one can retrieve a shortest ooding sequence with no extra cost up to a constant factor.

To get theO(NlogN) complexity, let us say that a couple(i, j)is valid if 1≤i < j ≤n−1andκ(i) = κ(j). A valid couple(i, j)is said to be interlocked into another valid couple if (i0, j0) if i < i0 and j0 < j. This is a partial order relation that we denote (i, j) ≺ (i0, j0). Let ` be the maximum length of a chain in this order, i.e. the maximum number of interlocked valid couples (i1, j1) ≺ (i2, j2) ≺ · · · ≺ (i`, j`). Then the shortest ooding sequences have n−1−` moves and such a sequence can be computed inO(N2logN). Indeed, any sequence of moves propagate the ooding in both directions from vertex 0.

A move oods at most two vertices since we start with a proper coloration.

The sub-sequence of moves ooding two vertices simultaneously corresponds to interlocked valid couples, i.e. a chain for our order. The length of the ooding

(12)

sequence is clearly equal to n−1 minus the length of this sub-sequence (each move ooding a couple saves one move to ood the whole set V \ {0}). Thus any ooding sequence has at least n−1−` moves. Conversely given a chain for the order ≺, consider the sequence of colors associated with each valid couple of the chain (in increasing order). Then one can easily complete this sequence into a ooding super-sequence where each valid couple of the chain will be ooded by only one move. By choosing a chain of maximum length ` one gets a shortest ooding sequence of length n−1−`.

Computing the set of theN valid couples can be done in O(N)by aO(n) bucket sort of vertices along their colors. The order ≺ is a partial order of dimension 2, thus one can nd a chain of maximum length in O(NlogN) time, by using the Schensted-like algorithm presented in Knuth [8] (Section 5.1.4).

The same reasoning and algorithm apply for paths where the ooding vertex is at any position: starting from the reduced graph which is still a path, number the vertices from one extremity of the path, say that the ooding vertex is s, the same kind of dynamic programming works and for the other approach dene valid couples as couples (i, j)wherei < s < j, and dene the relation ≺by (i, j)≺(i0, j0) if i0 < iand j < j0.

Corollary B.4 k-FI on a path of order n (for unbounded k) can be solved in time O(n2)or O(NlogN) where N is the number of pairs of vertices with the same color.

Remark B.5 For now, co-comparability graphs were the only class where k- FI is known to be polynomial for unbounded k. The class of cycles adds a new set of examples since the only cycles belonging to co-comparability graphs are C3 andC4. Note that all paths are co-comparability graphs. The complexity of the solution for co-comparability graphs presented in [6] is not fully analyzed, it seems that it can be implemented in O(n2) for paths.

2-Free-Flood-It.

Now we consider general graphs but with 2 colors only. As before we work exclusively with the reduced graphs (note that with proper 2-colorations, those reduced graphs are bipartite). Let G= (V, E) be the reduced graph at some step with its proper 2-coloration κ. Each move is fully dened by the choice of a vertex s whose new color is imposed since there are only 2 colors available.

After this update, vertex s has the same color as all its neighbors since we started from a proper 2-coloration. The new reduced graph G0 = (V0, E0) is

(13)

clearly dened by V0 =V \N(s) (contraction of the zone {s} ∪N(s) into a single vertex still denoted s) and E0 = (E \ {su ∈ E|u ∈ N(s)})∪ {sv|∃u ∈ N(x), uv ∈ E}. We call this transformation a neighborhood contraction at vertex s, and denote it G−→s G0. It is a particular case of edge contractions.

Now in this specic case of 2−FI and 2−FFI, in terms of reduced graphs, a ooding sequence is a sequence of neighborhood contractions leading the singleton graph as illustrated on Figure2. It is also clear that we do not need to consider the 2-colorations any longer, we just work with graphs subjected to neighborhood contractions.

Let us recall a few denitions about distances in an undirected graphG= (V, E). LetdG(u, v)be the distance betweenuandv inG. The set of vertices at distance d fromu ∈V is denoted NGd(u) ={v ∈V | dG(u, v) =d} (Nd(u) for short). The eccentricity of u is dened as εG(u) =max{dG(u, v)| v ∈V}. The radius ofGisR(G) =min{εG(u)|u∈V}and its center isC(G) ={u∈ V | εG(u) = R(G)}. It is well known that for any connected graph G, given the adjacency matrix of Gand a vertex u∈V, by performing a breadth rst search starting in u, we can compute εG(u) in timeO(|E|).

The following obvious result allow to derive that 2−FI is in P:

Lemma B.6 The number of neighborhood contractions at vertex s required to reduce a graph to a singleton is exactly the excentricity εG(s). As a conse- quence, solving 2−FI comes to compute the excentricity of the ooding vertex s in the initial reduced graph, and the shortest ooding sequence for 2−FFI is always at most the radius of the initial reduced graph.

Proof Let G= (V, E) and G0 = (V0, E0)such thatG−→s G0. One can easily check that for all d ≥1, NGd0(s) = NGd+1(s), and thus εG0(s) = εG(s)−1. To conclude, note that G is a singleton s if and only if εG(s) = 0.

Lemma B.7 Let G = (V, E) and G0 = (V0, E0) such that G −→s G0. Then,

∀u, v ∈V0, 0≤dG(u, v)−dG0(u, v)≤2.

Proof Indeed, if d0 = dG0(u, v) < d = dG(u, v), then, in G0, there exists a pathPuv= [u0 =u, u1, . . . , uk−1, s=uk, uk+1, . . . , ud0 =v]fromutov passing through s of length d0 (if Puv didn't pass through s, it would exist in G and then d ≤ |Puv| =d0). This implies that in G, one of the two following paths

(14)

of respective lengths d0+ 2 and d0+ 1 exists:

P1 = [u, u1, . . . , uk−1, w, s=uk, w0, uk+1, . . . , v]

orP2 = [u, u1, . . . , uk−1, w, w0, uk+1, . . . , v]

wherew ∈N(s)∩N(uk−1) and w0 ∈N(s)∩N(uk+1),

In both cases, we get d≤max{|P1|,|P2|}=d0+ 2.

Lemma B.8 Let G= (V, E)with radiusR(G) = R. Then ∀w∈C(G), ∃u∈ NR(w), ∃v ∈NR(w)∪NR−1(w) such that no path of length d≤R from w to v intersects a minimal path (of length R) from w to u.

Proof The proof is illustrated by Figure B.1. The existence of u ∈ NR(w) is trivial. Dene Pwu = [w = u0, . . . , uR = u] as a minimal path from w to u. Note that the following necessarily holds: dG(u1, u) = R −1 and ∀v ∈ V, dG(u1, v) ≤1 +dG(w, v). If there is no v 6=u in NR(w)∪NR−1(w), then ε(u1) = R−1< R which is a contradiction. Thus, letv ∈NR(w)∪NR−1(w), v 6=u and let Pwv = [w =v0, . . . , vd = v], be a path of length d ≤R from w to v. If Pwv intersects Pwu, then there exists i and j such that ui = vj and [u1, u2, . . . , ui =vj, . . . , vd=v]is a path of length no greater thand−1≤R−1 (i ≤j because otherwise there is a path from w to u shorter than Pwu) from u1 tov. As a consequence, dG(u1, v)≤ R−1. Thus, again, if forall vertex v inNR(w)∪NR−1(w), there is a path of lengthd≤R fromw tov intersecting a minimal path from wto u, then ε(u1) =R−1< R. This is contradiction.

d∈ {R1, R}

R1 R

d1R1

w v

u ui u1

Figure B.1.

Lemma B.9 Let G = (V, E) and G0 = (V0, E0) such that G −→s G0. Then, R(G)−1≤ R(G0) ≤ R(G). Moreover, if s ∈ C(G), then R(G0) = R(G)−1 and s ∈C(G0).

Proof Trivially, R(G0) cannot be bigger than R(G) = R. Let us show that it cannot be smaller than R −1. Assume that it is: R(G0) ≤ R −2. Let w ∈ C(G0). By hypothesis, ∀v ∈ V, dG0(w, v) ≤ R −2. By Lemma B.7,

(15)

it also holds that ∀v ∈ V, dG(w, v) −dG0(w, v) ≤ 2. Consequently, ∀v ∈ V, dG(w, v) ≤ R, i.e., w ∈ C(G). Now, let u and v be as in Lemma B.8:

dG(w, u) =R, dG(w, v)∈ {R−1, R} and no path of length d≤R fromw to v intersects a minimal path from w to u.

On the rst hand, since dG(w, u) = R, R(G0) ≤ R−2 and dG(w, u)− dG0(w, u)≥ 2, the following holds: dG(w, u)−dG0(w, u) = 2. Therfore, inG, any minimal path Pwu fromw to u passes throughs. On the other hand, for similar reasons, dG(w, v)−dG0(w, v)≥1 but no minimal path Pwv (of length dG(w, v) ∈ {R −1, R}) from w to v passes through s (otherwise it would intersect Pwu). However, since dG0(w, u) < dG(w, u), Pwv must be shortened in G0. From this, we derive that dG(w, v)−dG0(w, v) = 1, dG(w, v) = R−1 and Pwv passes through exactly 2 neighbours s1 and s2 of s: Pwv = [w = v0, . . . , s1 =vi, s2 = vi+1, . . . , vd = v]. But then, [w =v0, . . . , s1 =vi, s, s2 = vi+1, . . . , vR−1 = v] is a path of length (R− 1) + 1 = R from w to v that intersects Pwu. This is a contradiction.

The statement about neighborhood contractions at the center is a direct consequence of εG0(s) = εG(s)−1already noticed for Lemma B.6.

Lemma B.10 A graph G = (V, E) can be reduced to a singleton by R(G) neighborhood contractions and no less. To do so, one can choose any vertex in C(G) to perform all the contractions.

Proof By Lemma B.6, it can be done in R(G) moves and as a direct conse- quence of Lemma B.9 it cannot be done in less.

Note that all the previous lemmas apply to any connected graph, not neces- sarily bipartite. Now if we come back to 2− FFI, since the reduced graph of an arbitrary coloured graph may be constructed in linear time, by apply- ing Lemma B.10 reinterpreted in terms of ooding sequence, we settle the complexity of the puzzle (solving an open problem in [1]):

Proposition B.11 2-FFI is in P: it can be solved in time O(nm), i.e., the time needed to compute the radius of the associated reduced graph (and to nd a vertex in the center of this graph).

C Characterisation results

In this section we turn back to the original ooding game on coloured boards and show the equivalence between such games and games on a certain class of coloured graphs. First, let us detail some new or extended denitions that will be used in the sequel.

(16)

Let B be a coloured board. First of all we dene ⊥B to be the exterior of B. Then, we dene the reduced graph of B as the coloured graph G = (V, E, κ) where the set V equals the set of coloured components of B and for all vertices u, v ∈ V the edge (u, v) belongs to E if and only if u and v are adjacent components in B. Note that there is no vertex in G that represents⊥B. The grid of B is the graph whose vertices are the intersection points of tiles of B and whose edges are the edges of the tiles (the grid is thus, the dual of the graph representing the adjacency relation between tiles of B). Frontiers of the board are paths in its grid that separate two dierent coloured components or that delimit one coloured component from ⊥B. The frontiers of a coloured component are the frontiers that are adjacent to it. B is called a q-board if every vertex of its grid has degree q (i.e., in every point of the board where tiles intersect, exactly q tiles intersect). For instance, the hexagonal board as in Mad Virus [5] is a 3-board and the usual square board as in flood-it is a 4-board. B is said to be at if none of its coloured components has less than 2 distinct frontiers that separates it from other coloured components. Thus, if B is at, no coloured component is contained strictly in another coloured component nor is it contained in the union of ⊥B and another coloured component. If B is not at, we dene F(B) to be the attened version of B, i.e., the at coloured board obtained by (recursively) colouring every coloured component u with the colour of v if u is contained strictly in v or in the union of v and ⊥B. Note that a coloured component u has degree 1 in the reduced graph of B if and only if, in B, it contains no other coloured component but is strictly contained in one. Since a at board B contains no such coloured component u, all vertices have degree strictly greater than 1in the reduced graph of B.

The last denition concerns planar graphs rather than boards. Thus, let G = (V, E) be a planar graph. Let G0 = (V, E0) be any multiple graph obtained by adding copies of edges (u, v) ∈ E. Then, any planar map of G0 is called a multiple planar map of G. In particular any planar map of G is a multiple planar map of G. The idea is that, in some cases, a multiple planar map ofGhas useful properties (in particular, concerning the number of edges on each face) that no planar map of Ghas.

Lemma C.1 Let B be a at coloured q-board and let G be the reduced graph of B. Then, G has a multiple planar map in which faces have no more than q edges and no vertex has degree less than 2.

Proof The fact that no vertex of the reduced graph ofB has degree less than 2comes directly from the fact that B is at. For the sake of simplicity, in the

(17)

rest of this proof, we (seriously) abuse language and confuse planar graphs with their most natural planar maps (yielded by the constructions that are described).

LetH be the graph whose edges are the frontiers of B and whose vertices are vertices of the grid that are endpoints of a frontier. All frontiers have two endpoints since B is at. Moreover, vertices of the grid tangent to just two components are vertices on frontiers that are not frontier endpoints and by denition of q, there are no vertices of the grid that are tangent to more than q components. Thus, there is a bijection between vertices of H and vertices of the grid which are tangent to k ∈ {3, . . . , q} distinct coloured components.

Consequently, the degree of any vertex ofH belongs to{3, . . . , q}. In addition, by construction, H is planar (the grid is planar and H is obtained from the grid by removing some vertices and some edges) and is such that each face of H corresponds to a coloured component of B and two faces of H share an edge if and only if the corresponding coloured components of B are adjacent.

Note thatHmay contain multiple edges between two vertices (see FigureC.1).

This happens when two vertices of the grid represent the intersections between the same coloured components of B (this, in turn, happens only when some coloured components of B are concave).

Now, letG0 be the coloured planar graph obtained by removing the vertex

B and its incident edges from the dual of H. Every vertex of G0 corre- sponds to a (non-exterior) face of H and has the colour of the corresponding coloured component of B. Two vertices of G0 are adjacent if and only if the two corresponding faces of H share at least one edge, i.e., if and only if the two corresponding coloured components of B are adjacent. Again, note that there may be several edges between two vertices of G0 (see Figure C.1). This happens when two faces ofHshare more than one edge, i.e., two coloured com- ponents of B (one of them necessarily concave) share more than one frontier.

The number k of edges of a face of G0 equals the degree of the corresponding vertex of H, minus one if this vertex is incident to the exterior face of H. Therefore, k≤q holds.

Finally, let Gbe the graph which has exactly one copy of each edge ofG0. Clearly, G is the reduced graph of B and the planar map of G0 is a multiple

planar map of G. 2

Corollary C.2 Let B be a coloured q-board and let G be the reduced graph of B. Then, the graph obtained by recursively removing vertices of degree1 in G (i.e., the graph obtained by removing all subtrees of G) has a multiple planar map in which faces have no more than q edges.

(18)

B0 B=F(B0) H G0

15 14

18 11 17

10 12 16

13

2 1

4 5

3 6 8

9 7 2

3

6 8 9 12 13 16 14 18

15 11 17

1 5

10 4

B 7 I H

J A

C D

G

E F

I C

D B E F G

H J A

Figure C.1. From left to right, a 3-boardB0, its attened versionB =F(B0)and the graphsHandG0as in the proof of LemmaC.1. Letters refer to coloured components and numbers to nodes that are endpoints of frontiers. The reduced graph G of B can be obtained by removing the dotted edges inG0, that of B0 can be obtained by adding one node incident to Aand another incident toB.

Proof Construct the multiple planar map G0 of the reduced graph of F(B) as in the proof of LemmaC.1. Then, add subtrees that correspond to coloured components of B that are included in one another.

Lemma C.3 Let Gbe a coloured planar graph such that the graphG0 obtained by recursively removing vertices of degree 1 in G has a multiple planar map in which all faces (except eventually the external face) have no more than 4 edges. Then, there exists a coloured square board whose reduced graph is G. Proof First, let G = (V, E, κ) be a coloured planar graph with no vertices of degree less than 2 and whose multiple planar map G0 has faces with no more than 4 edges. Suppose that the external face of G0 has k edges. Let H be the planar graph obtained from the dual of G0 the following way: the subgraph induced by the node representing the external face ofG0 is removed.

A cycle of length k is added around the remaining graph. Every node of this cycle is connected to exactly one node of the dual in a way that the graph remains planar (see nodes in gray and edges in bold in the the graph H pictured in Figure C.1). Thus, every vertex of G corresponds to a closed face of H which can be coloured with the colour of that vertex. The maximal degree in H is 4. Then there exists an orthogonal drawing of H [11]. In other words, it is possible to draw H such that all vertices are represented by points of the plane and all edges are represented by chains of horizontal and vertical segments. It is easy to see that, as a result, H can be drawn on the square grid such that each of its coloured faces becomes a coloured connected component of the square board. In the case where G does have vertices of degree1, coloured components corresponding to vertices in subtrees ofGmay be added to B by including them strictly and recursively inside pre-existing

(19)

coloured components in a way that the adjacencies of components required by the subtrees are respected.

Note that when the faces of G0 (dened as in Lemma C.3) have no more than3edges, a construction similar to that of the proof of LemmaC.3may be used to nd a hexagonal board whose reduced graph isG. Indeed, vertices of H = (VH, EH)have degree no more than3and there still exists an orthogonal drawing of H (see Figure C.2). In the general case, to nd a q-board whose reduced graph is a given graph G such that G0 has faces with no more than q edges, one can use the fact that any planar graph may be drawn with a straight-line drawing and thus, every vertex v of H can be mapped to an element of Z2 φV(v) = (a, b) ∈ Z2. However, one also needs to dene a map between edges (u, v) of the graph and paths P = φE(u, v) in the grid that guarantees that φE(u, v) is a path from φV(u) to φV(v) that intersects no other path φE(u0, v0) (except possibly in φV(u)or φV(v)). We leave the proof of the existence of such maps as an open problem.

Figure C.2.

As a result of Lemmas C.1 and C.3, we obtain the following characteriza- tion in the case of square boards:

Proposition C.4 A k-coloured graph G is the reduced graph of some k- coloured square board B if and only if it is a k-colorable planar graph such that the graph G0 obtained by recursively removing vertices of degree 1 in G has a multiple planar map in which all faces have no more than 4 edges.

We have mentioned above the holes in themad virusboard. More generally, we dene a hole in an arbitraryk-colouredq-board as a0-coloured component of the board that cannot be ooded. Under the supposition that holes are allowed, we obtain the following result:

Proposition C.5 A k-coloured reduced plane graphGis the reduced graph of some k-coloured square board with holes.

Proof Let H be the graph obtained from the dual of G as in the proof

(20)

of Lemma C.3. Let v be a vertex of H with degree d > 4 and such that NH(v) = {u1, . . . , ud}. Dene a new graph H0 such that for every such vertex of degreed >4,vis replaced bydnew verticesv1,. . . ,vdrespectively connected to u1,. . . , ud and connected together so that [v1, . . . , vd, v1] forms a cycle as in gure C.3. The graph H0 is such that all vertices have degree no greater than 4. By the construction described in the proof of Lemma C.3, H0 can be drawn on the grid of a square board such that each vertex ofGcorresponds to a connected component of the board and the adjacencies dened by the edges

of G are respected between these components. 2

Future hole

Figure C.3. The transformation mentioned in the proof of PropositionC.5. On the left the central node has degree 6. On the right, this node has been replaced by nodes of degree3that delimit a closed face that will become a hole in the associated board.

Références

Documents relatifs

The problem of deciding the existence of a SEPI from G to G’ is NP-complete, but show that when G is fixed, this problem can be decided in constant-time (hint: this

Fog computing platforms must carefully control the number and placement of application replicas to ensure guaranteed proximity between the users and the replicas serving their

3.3.3 Unicyclic graphs with exactly three vertices of maximum degree 3 whose exactly two belongs to the

In Section 4, we deal with the case where the matroid is 4–connected up to separators of size 4, and in Section 5 we complete the proof of Theorem 1.2.. Section 5 begins with

L’archive ouverte pluridisciplinaire HAL, est destinée au dépôt et à la diffusion de documents scientifiques de niveau recherche, publiés ou non, émanant des

The next multicolumns exhibit the results obtained on instances 1.8 and 3.5: “P rimal best ” presents the average value of the best integer solution found in the search tree; “Gap

L’archive ouverte pluridisciplinaire HAL, est destinée au dépôt et à la diffusion de documents scientifiques de niveau recherche, publiés ou non, émanant des

We extend this algorithm by consider- ing all the search spaces needed for the dissimilarity computation between the unknown and the training graphs as a single search space..