Combinatorial Analysis of a Subtraction Game on Graphs

We define a two-player combinatorial game in which players take alternate turns; each turn consists on deleting a vertex of a graph, together with all the edges containing such vertex. If any vertex became isolated by a player's move then it would also be deleted. A player wins the game when the other player has no moves available. We study this game under various viewpoints: by finding specific strategies for certain families of graphs, through using properties of a graph's automorphism group, by writing a program to look at Sprague-Grundy numbers, and by studying the game when played on random graphs. When analyzing Grim played on paths, using the Sprague-Grundy function, we find a connection to a standing open question about Octal games.


Introduction
A graph G = (V, E) is a set V of vertices and a set E of edges connecting pairs of vertices. In this work we consider only graphs that are finite, simple and undirected. As customary, the degree of a vertex v, denoted deg(v), is the number of edges that are incident with v. We say that a vertex v is isolated if deg(v) = 0. A graph is said to be connected if, given any two vertices u, v ∈ V (G), there is a path in G from u to v. Two graphs are said to be disjoint when their vertex sets are disjoint; we will use the notation G ∪ H for the graph formed by two disjoint graphs, G and H. The join of two graphs G and H, denoted G + H, is the graph with vertex-set V (G + H) = V (G) ∪ V (H) and edge-set E(G + H) = E(G) ∪ E(H) ∪ {vw; v ∈ V (G), w ∈ V (H)}. Finally, we will denote paths, cycles and wheels by P n , C n , and W n respectively, where n is the number of vertices in the graph, and G will denote the graph with V (G) = V (G) and edges connecting only vertices that were not connected in G. More information about graphs may be found in [3].
In order to define our game we re-phrase well-known notions in combinatorial game theory for a game played on graphs. For further reading about game theory, we direct the reader to [1]. Definition 1. A two-player game is said to be impartial if the outcome of the game depends only on what player goes first. A two-player game is said to be combinatorial if both players have perfect information, there is no chance involved, the game ends after a finite number of moves, the game is impartial, and there is no draw. A two-player game is said to be normal if the last player to make a legal move is the winner.
Definition 2. Let G and H be graphs on which a combinatorial game can be played.
1. If H is obtained from G after a game move, then we will call H a follower of G in the game. 2. If, given a graph H, there is a strategy to win for the next player making a move then we will say that H is an N position (the N is for next). If, given a graph H, the next player making a move does not have a strategy to win then H is a P position (the P is for previous).
Remark 1. Not having a strategy to win means the other player has a strategy to win. This follows from the Sprague-Grundy Theorem, see [11] and [17]. So, if G is the starting graph and Player 1 will move first, then G being an N position means Player 1 has a strategy to win the game, but if G is a P position then Player 2 has a strategy to win the game.
Next we define our game, which we call Grim.
Definition 3. Given a graph H, we define a legal move of Grim on H by a player selecting and consequently deleting a vertex. When this vertex is deleted all edges adjacent to this vertex are also deleted, together with any other vertices (if any) that have become isolated because of the move. The game starts with Player 1 moving first on a pre-arranged, starting position, graph G (naturally, if G had any isolated vertices these would be deleted before the first player can move). After that, the two players alternate turns, making legal moves on the follower resulted from the previous player's move. They play until all vertices have been deleted. We refer to the winner of the game, or winner of the graph, as the player who makes the last legal move.
Remark 2. Grim is a normal combinatorial two-player game. Given the nature of the game, we will also say it is a vertex deletion game.
Note that changing the starting graph may change the way Grim is played completely. So, in this article we are not just studying a specific game, but a family of them. This property is commonplace in the study of games played on graphs, of which there is a wide variety, see e.g. Node Kayles in [2] and [10], Connect-it [12], Take Turn [16], and [7], [13] and [15].
Our interest in the subject of games played on graphs is due to the papers by Fukuyama (see [8] and [9]), where he studies Nim on graphs.
Our study of Grim is split as follows: In Section 2 we look at weighted graphs and prove that an extension of Grim to these graphs is unnecessary, as the strategies that could be used to play Grim in weighted graphs are the same as those used to play Grim on certain unweighted graphs. In Section 3 we find winning strategies for when Grim is played on complete and complete multipartite graphs. In Section 4 we look at how certain symmetries in a graph could be exploited to guarantee a victory when Grim is played on such a graph. In Section 5 we study paths, cycles, and other related graphs by using Sprague-Grundy functions; in this way we discover an interesting connection between Grim played on paths and an open problem about Octal games. Finally, in Section 6 we consider random graphs in order to learn whether Player 1 has an overall better chance of winning at Grim.

Weighted Graphs
It is not unusual to wonder whether a game played on graphs could be extended to be played on graphs with weighted vertices, maybe by thinking about the vertices of the graph as heaps of chips/tokens that can be removed one at a time by players. Of course, this way of playing Grim is similar to the way Nim is played, and thus it has been considered in the past (e.g. [5]). In this section we prove that the natural variation of Grim on weighted graphs is nothing but regular Grim on a different family of graphs.
When playing Grim on a weighted graph, we only allow a vertex with weight t to be deleted after it has been selected t times, or if it has been completely isolated. Thus, we can create many different games from the same graph by giving each vertex a new random weight.
As we studied these graphs, we discovered that we could replace a vertex with weight t with t 'regular' vertices that do not share any edges. In order to prove such a claim the concept of a blowup of a vertex becomes necessary.
Definition 4. Let G be a graph with weighted vertices. Let v ∈ V (G) having weight one and t ∈ N. A t-blowup of v is an independent set I v = {v 1 , v 2 , . . . , v t } of vertices of weight 1 that 'takes the place' of v. More precisely, wherever there was an edge joining v to w ∈ V (G) there is an edge joining v j with w, for all j = 1, . . . , t.
The graph obtained by the t-blowup of v will be denoted G(tv). Similarly, for v, w ∈ V (G) and s, t ∈ N we denote a 'double blowup' G(tv)(sw) as G(tv, sw). For multiple blowups we extend in the natural way the notation set of double blowups.
Note that G(1v) = G, for all v ∈ V (G). Lemma 1. Let t ∈ N. Let G be a graph with weighted vertices, and let v ∈ V (G) have weight t. We denote by G(v) the t-blowup of the graph obtained by reducing the weight of v to one. Then, the outcome of playing Grim on G or on G(v) is the same.
Proof. Let I = {v 1 , . . . , v t } be the independent set used to obtain G(v). There are two possible ways to delete v while playing on G, thus we look at the following two cases: Case 1 : Try to isolate v in G. Using the same moves needed to remove all of v's neighbors in G we can isolate every vertex in I (in G(v)).
Case 2 : Removing v in G by repeatedly using it in the game. In order to remove v from G, it has to be selected t times. To fully remove I from G(v), each of the t vertices in I must be selected and removed. Thus removing I from G(v) requires an equivalent process as that needed to remove v from G.
Therefore, game play with v or with I will involve the same strategies. Finally, replacing v with I will not affect the other vertices in the graph, and thus it will not affect playing with them.
An easy induction argument proves the main theorem of this section.
. . , t n )-blowup of the graph obtained by reducing (if possible) the weight of each vertex of G to one. Then, the outcome of playing Grim on G or on We conclude that Grim on weighted graphs does not need to be studied separately, and so from now on the game discussed is always Grim played on unweighted graphs.
Before we move on, we would like to let the the reader know that we will often use the word graph to mean the game played on that graph (as in 'Player 1 wins graph G'). Most proofs in the following sections somehow describe the specific strategy to be used to win.

Complete and complete multipartite graphs
In this section we obtain specific strategies to win at Grim for complete graphs and complete multipartite graphs. We start with a theorem about complete graphs. Proof. The case n = 1 is immediate, as no game is ever played. For n > 1, all moves are equivalent in a complete graph, and a move will always yield a complete graph, so the game always lasts n − 1 moves.
Grim played on complete bipartite graphs will be analyzed next.
Theorem 2. Let m, n ∈ N. Then, the following hold.
1. K 1,n is an N position. 2. Assume m, n > 1. Then, K m,n is an N position if and only if m + n is odd.
Proof. The first claim is immediate. For the second claim we start by settling a base case. For K 2,2 , whatever move Player 1 makes, the follower is always K 1,2 . By part 1, Player 2 wins this graph. Now we proceed by induction on k = m + n. Part 1 and the base case considered above tell us that we have the result for k = 3, 4. So, assume the result holds for Case 1: If k + 1 is odd, then k + 1 ≥ 5. WLOG assume that a > 2 and let Player 1 move by creating the follower K a−1,b . Since both a − 1, b > 1 we use the induction hypothesis to determine that Player 1 wins K a,b .
Case 2: If k + 1 is even, then k + 1 ≥ 6. If WLOG a = 2 then Player 1 would not want to move to create the follower K 1,b , as this would be won by Player 2. However, if they moved to create the follower K 2,b−1 then they would lose anyway, by induction, as 2, b − 1 > 1. Now, if a, b > 2 then whatever move Player 1 makes they would lose by induction, as a − 1, b − 1 ≥ 2.
In the rest of this section we extend Theorem 2 to most multipartite graphs. At this point we would like to remark that the only way to delete a vertex in a complete multipartite graph and, by doing so, isolate other vertices would be when we were making a move on K 1,n , which is a graph already studied in Theorem 2. This unique situation indicates that we should take a closer look at graphs that may have K 1,n as a follower; K 1,1,n is the only one of those graphs that has not been already studied in Theorem 2. Looking at the behavior of K 1,n we obtained our next result. Proof. We start by noticing that the case m = n = 1 is immediate. We will prove the case m = 1, n > 1 by induction on n. Our base cases are K 1,1,1 and K 1,1,2 .
We know that the first graph is a P position, and clearly, Player 1 wins K 1,1,2 by leaving the follower K 1,1,1 after their first move. For n > 2, Player 1 should start by leaving K 1,1,n−1 as a follower (otherwise Player 2 would win the game immediately). Player 2 could leave K 1,n−1 or K 1,1,n−2 as a follower. In the first case, Player 1 wins G, and in the second case induction forces the result we wanted. Let us assume that m = 2 and n ≥ 2. If n is even then Player 1 leaves K 2,n as a follower, which by Theorem 2 is won by Player 1. If n is odd then Player 1 leaves K 1,1,n as a follower, and thus they win G by using the strategy discussed above.
Finally, assume m, n ≥ 3. Since none of the players would like to leave K 1,2,k as a follower then the winners of these graphs will alternate depending on n being even or odd. Thus we look at the 'base case' K 1,3,3 , which is an N position by Theorem 2, to get the desired result.
The complete tripartite graphs 'missing' from Lemma 3, and most of the other complete multipartite graphs are considered in the following theorem. Proof. Let G = K n1,n2,··· ,nt , where t > 2 and n i ≥ 2, for all i = 1, . . . , t. We define S = {n i ; n i ≡ 1 (mod 2)}.
Suppose that |V (G)| is even and n i ≥ 2, for all i = 1, . . . , t. Note that |S| is either 0 or even.
Case 1: |S| = 0, i.e. each partition of G contains an even number of vertices. The strategy for Player 2 is as follows: the game starts with Player 1 deleting any vertex from the graph. Since the partition where this vertex was will have at least one more vertex in it, Player 2 deletes a vertex in it. In this way, Player 2 always has an available move in the same partition that Player 1 has chosen to play on. Hence, Player 2 is always the last person to delete a vertex from every partition of G, and thus they will always have the last move in the game, as they will be the only person able to play in the state K 1,ni , when that time comes.
Case 2: |S| = 2k, for some non-zero k ∈ N. Now the strategy for Player 2 is two-fold: if Player 1 moves in an 'even' partition of G then Player 2 follows the strategy in Case 1, but if Player 1 deletes a vertex in an 'odd' partition then Player 2 deletes a vertex in one of the other odd partitions (there would be an odd number of them available). Note that after one move by each player, the follower obtained would either be a graph that Case 1 considers, or G would have |S| = 2(k − 1), and thus an induction argument would finish the proof. Note that the base case(s) of this induction could be track down to knowing who wins K odd, odd or K even, even , which are both P positions by Theorem 2. Now suppose that |V (G)| is odd and n i ≥ 2, for all i = 1, . . . , t. Since there must be some n i ∈ S, the strategy for Player 1 is to delete any vertex in a partition with an odd number of vertices. In this way, they would leave a follower with an even number of vertices that also has every partition containing more than 1 vertex. For this follower, Player 1 will move second and thus will win the graph.
We now look at a specific family of multipartite graphs allowing singletons as partitions.
Proof. If |V (G)| is odd then Player 1 leaves K n2,...,nt as a follower, which is a P position (by Theorem 3), and thus Player 1 wins G. Now, if |V (G)| is even then Player 1 would not want to leave K n2,...,nt as a follower, as in this case, by Theorem 3, Player 2 would win G. Hence, Player 1 would leave WLOG K 1,n2−1,n3,...,nt as a follower. If n 2 > 2 then by the previous case we would get that Player 2 wins G. If we allow r − 1 > 0 of the n i to be equal to 2 then, after re-arrangement if needed, we get G = K 1,2,...2,nr+1,...,nt , where n r+1 , . . . , n t > 2. Note that r < t because |V (G)| is even. In this case, Player 1 leaves K 1,2,...2,nr+1−1,...,nt as a follower, and thus Player 1 wins G using the strategy discussed for the case |V (G)| odd.
There are several complete multipartite graphs that we have not studied, and we will not study in this paper; these, after a re-arrangement if needed, have the form K 1,··· ,1,n k+1 ,...,nt , where 3 < t, 1 ≤ k ≤ t, and n i ≥ 2, for all i = k + 1, . . . , t. Some of them may be studied very easily, for example K 1,...,1 is a P position if and only if t is odd. The conditions needed to understand others are much more complex. For instance, if k > 1 and k > α k,t = (n k+1 + · · · + n t ) − (t − k), then K 1,··· ,1,n k+1 ,...,nt is a P position if and only if k and α k,t have different parity.
On the other hand, in order to understand the case k ≤ α k,t we need to look at these two parameters and also to how much bigger than k α k,t is.
Also, unlike most of the graphs studied in this section, K 1,n and K 1,2,n are always won by Player 1 independent on the parity of n. This situation is not that uncommon in the graphs we have not studied here, for instance the family of graphs of the form K 1,1,3,n , for n ≥ 3, are also won by Player 1 by leaving the follower K 1,3,n for n even and K 1,1,2,n for n odd. There are several other families, similar to K 1,1,3,n , that may be proven to be won by Player 1 only.
All this suggests that a complete theory of dealing how Grim would play on multipartite graphs allowing singletons as partitions is very complex, and thus we plan to study it separately in a future article.
Other 'standard' families of graphs can be studied in a similar fashion to what has been done in this section with complete and complete multipartite graphs. However, as it was seen in this section, and we will see again in Section 5, the analysis of Grim gains complexity quickly. Hence, in the following sections we will study Grim on graphs by using a less direct set of techniques.

Automorphisms
Certain symmetries in a graph can be exploited to obtain strategies for winning at Grim. In this section we prove a couple of results of this type, and then we apply them to a few families of graphs.

Definition 5.
A function σ is said to be an automorphism of a graph G if σ permutes the vertices of G while preserving incidence. The group (under composition) of all the automorphisms of G is denoted Aut(G).
Theorem 4. Let G be a graph, and assume that Aut(G) has an element σ of order Proof. Let σ ∈ Aut(G) be such that v = σ(v) and vσ(v) / ∈ E(G), for all v ∈ V (G). We will prove that if Player 1 moves by selecting a vertex v, then Player 2 can always move by selecting σ(v).
We will proceed by contradiction. Suppose that at a certain stage of the game, and for the first time, Player 1 moves by selecting a vertex v leaving a follower that does not contain σ(v). If σ(v) was already deleted when Player 1 made their move, then either σ(v) was deleted by Player 2, which would contradict that v had not been deleted at this point, or σ(v) was deleted by becoming isolated, which would force (as σ ∈ Aut(G)) v to be isolated. In either case, the situation is impossible. So, the only option would be that σ(v) gets isolated at the time of deleting v. But v and σ(v) are not adjacent, so deleting v cannot isolate σ(v).

Corollary 1. Let G be a graph with no isolated vertices, and assume that Aut(G)
has an element σ of order 2 such that v 0 = σ(v 0 ), for exactly one v 0 ∈ V (G), and vσ(v) / ∈ E(G), for all v ∈ V (G). Then, G is an N position.
Proof. Player 1 starts the game by deleting v 0 , leaving a follower that is a P position by Theorem 4. Hence, G is an N position.
The following corollary summarizes a few applications of Theorem 4 and Corollary 1.
(1) If n is odd, and n ≥ 3, then P n is an N position.
(2) If n is even, and n ≥ 4, then C n is a P position.
(3) If n is odd, and n ≥ 5, then W n is an N position.
(4) G ∪ G is a P position, for all non-empty graphs G.
Proof. (1) Use Corollary 1 with σ the reflection across the middle vertex of P n .
(2) Modeling C n with a regular n-gon. Use Theorem 4 with σ defined by reflecting every vertex across the center of the polygon.
(3) Use the same function in the proof of (2), but now apply Corollary 1, as the center of the wheel is fixed.
(4) Use Theorem 4 with σ the identification between the two copies of G.
Theorem 4 and Corollary 1 can also be used in the study of Cartesian products of graphs. Corollary 3. Let n > 1, G 1 , · · · , G n be graphs, and G = G 1 · · · G n .
(1) If G 1 , · · · , G n satisfy the hypothesis in Theorem 4, then, G is a P position.
(2) If G 1 , · · · , G n satisfy the hypothesis in Corollary 1, then G is an N position.
Proof. (1) Let σ i ∈ Aut(G i ) be the automorphism satisfying the hypothesis in Theorem 4. It is easy to see that σ defined by is an automorphism of G also satisfying the hypothesis in Theorem 4. The result follows.
The proof for (2) uses the very same ideas, so we omit it.
An attempt to find strategies that allow us to determine who would win G H, for arbitrary graphs G and H, was made but it failed because we realized that keeping track of all the possible avenues the game could take was an impossible task. A natural approach to how to 'keep track' of what happens in a game is discussed in the following section.

The Sprague-Grundy Function
One of the most useful tools in the study of combinatorial games is the Sprague-Grundy function. We proceed to define it, in the context of Grim, and then we focus our efforts on finding its values for paths.  The process to calculate the Sprague-Grundy values by hand is laborious, so we wrote a program in Visual FoxPro to compute the Sprague-Grundy value of Grim on paths. We focused on paths because in Corollary 2 we learned that odd paths are N positions, but when wanting to look at even paths no pattern seemed to exist.
Using our program, we were able to compute all the values of SG(P n ) 1 for up to n = 10 7 . Using these results we know that if n ≤ 10 7 , then SG(P n ) = 0 only when n ∈ {4, 12, 20, 30, 46, 72, 98, 124, 150, 176, 314, 408}, which is something Lacko and Lacki (unpublished work, see [14]) had also determined (although they consider P 1 a P position while we do not consider P 1 a graph where we would play Grim, as all isolated vertices in a graph are deleted before a game starts). Moreover, they also claim that SG(P n ) = 0 for all values in the range 10 7 ≤ n ≤ 10 8 . The obvious question, at this point, is whether or not there are any other even paths with SG(P n ) = 0. It turns out that the answer to this question is related to a different open problem in game theory.
Definition 8. An octal game is a normal impartial game played on heaps of chips. A move consists of taking a number of chips from a single heap, eliminating them, and then redistributing the remaining chips in the heap (if any left) into 0 (all chips in the heap were eliminated), 1 (leave the remaining chips intact), or 2 heaps; this number is fixed in advance for the game and depends only on how many chips were eliminated in the move. Given that there are several variables to determine at the beginning of the game, the rules of the game are encoded into a string of digits as follows: If in a move we remove k chips from a heap and we are allowed to break the remaining ones into a heaps then we say that χ k (a) = 1. In the case that we were not allowed to break the remaining ones into a heaps we say that χ k (a) = 0. The code of the game is d = 0.d 1 d 2 . . ., where It follows that, since 6 = 2 1 + 2 2 , the game Octal .6 is a game in which every move consists of one chip being removed from a heap and what remains of that heap must be left in exactly 1 or 2 non-empty heaps.
Several octal games have Sprague-Grundy sequences that after a while become periodic (see [6], for example); it is not know whether Octal .6 has a period. This is relevant to us because the terms in the sequences of Sprague-Grundy numbers for Grim on paths and Octal .6 are the same (see Theorem 5 below). Thus our question about values of n for which SG(P n ) = 0 becomes a problem about when Octal .6 is won by Player 2, which is an open problem (e.g. see [4]).
In order to create some intuition on the reader about our next result, we notice that we can identify removing a chip from a heap in Octal .6 to deleting a vertex in a path (under Grim rules). More explicitly, depending on what vertex we delete, we always leave one or two paths left; these two paths would be the equivalent of the two heaps left after removing a chip in Octal .6. Proof. Let n ∈ N, O n be Octal .6 played on a heap of size n, and P n be Grim played on a path on n vertices. We will prove that SG(P n ) = SG(O n ). We will do this by induction on n.
For n = 1 we get that both games are trivial, and thus SG(P 1 ) = SG(O 1 ) = 0. We now assume that SG(P i ) = SG(O i ), for all i ≤ n.
First we notice that the followers of P n+1 and O n+1 are: Using Nim Sum (see [1]), denoted + N below, to evaluate the Sprague-Grundy number of the followers of P n+1 and O n+1 , we get: SG(P n+1 ) = mex{SG(P n ), SG(P n−1 ) + N SG(P 1 ), SG(P n−2 ) + N SG(P 2 ), . If we knew all the values in the sequence {SG(P n )} ∞ n=1 we would also know several other Sprague-Grundy sequences. We present two results of this type, without a proof, in the following corollaries. In particular, C n is a P position when n is even.
Finally, we get a result about wheels that depends on whatever knowledge we had about paths.

Definition 9.
A wheel graph on n vertices is defined by W n = C n−1 + K 1 . K 1 is called the center of the wheel. Proof. W n has only two followers: C n−1 , obtained from deleting the center of the wheel and W ′ n−1 , obtained by deleting a vertex different from the center of W n . If Player 1 wins P n , then they can win W n+2 by removing the center vertex and leaving C n+1 as a follower, this then forces Player 2 to leave P n as a follower, which is an N position.
If Player 2 wins P n , then since W n+2 has only two followers and both of them are one deleted vertex away from P n , Player 2 can leave P n as a follower after their first move.

Grim on Random Graphs
We are interested in understanding what happens when Grim is played on a random graph. Our main reason is that evidence in previous sections has shown that the game seems to favor Player 1 overall. In order to do this, we will use Erdős-Rényi random graphs.
Definition 10. Let n ∈ N and 0 ≤ p ≤ 1. An Erdős-Rényi random graph G(n, p) is defined by having n vertices and, for any pair of vertices, the existence of an edge connecting them has probability p.
In this section, we will work on identifying probabilities p for which Player 1 and Player 2 have equal chances of winning a random graph G(n, p).
Remark 4. The probability of any given graph on n vertices and k edges to exist is given by p k (1 − p) ( n 2 )−k . So, if p = 0.5, then all possible graphs on n vertices have equal probability to exist; this value being (1/2) ( n 2 ) .