Manuscript Offprint
arXiv:2611.01012Mutual-visibility colouring with two colours is NP-complete for every fixed diameter
SIDDHESH CHAUBAL
ABSTRACT. A mutual-visibility set in a graph is a set of vertices such that any two vertices of are connected by a shortest path with no internal vertex in , and the mutual-visibility chromatic number is the minimum number of mutual-visibility sets needed to partition . Babu, Di Stefano and Lakshmanan showed that it is NP-complete to decide whether for graphs of diameter four. We show that the problem remains NP-complete for graphs of diameter , for every fixed ; diameter two is the smallest diameter for which the problem is non-trivial. The proof rests on a reformulation of for diameter-two graphs as the 2-colourability of an associated hypergraph, and on a reduction from 2-colourability of 3-uniform hypergraphs without short cycles.
1. INTRODUCTION
Mutual visibility in graphs was introduced by Di Stefano [6]: a set is called a mutual-visibility set (MV set) of if any two vertices are -visible, that is, joined by a shortest -path all of whose internal vertices lie outside . Klavžar, Kuziak, Valenzuela Tripodoro and Yero [9] introduced the corresponding colouring problem. A partition of into MV sets is called a mutual-visibility colouring of , and the mutual-visibility chromatic number is the minimum number of parts in such a partition. They asked about its computational complexity [9, Problem 8.1], and Babu, Di Stefano and Lakshmanan [1] proved that it is NP-complete to decide whether , already for graphs of diameter four. Related variants (independent, total, dual and outer mutual-visibility colourings) are also known to be NP-complete [3, 2].
Graphs of diameter two play a special role for mutual visibility [5]. In such a graph every independent set is an MV set, so [9], and the existence of graphs attaining equality other than complete bipartite graphs was recently settled by the author [4]. For graphs of diameter at most one (complete graphs) the problem is trivial. Our main result shows that diameter two is already as hard as the general case.
Theorem 1.1. The following problem is NP-complete: given a graph of diameter two, decide whether .
Since a non-complete graph has , Theorem 1.1 equivalently says that it is NP-complete to decide whether for graphs of diameter two, and computing is NP-hard on this class. Attaching a suitable ‘ladder’ to the construction extends this to every larger diameter, and in particular recovers the diameter-four case of [1].
Theorem 1.2. For every fixed integer , the following problem is NP-complete: given a graph of diameter , decide whether .
2020 Mathematics Subject Classification. 05C15, 05C12, 68Q17.
Key words and phrases. mutual-visibility set, mutual-visibility colouring, diameter two, NP-completeness, hypergraph 2-colouring.
SIDDHESH CHAUBAL
The paper is structured as follows. In Section 2 we show that, for a graph of diameter two, is equivalent to the 2-colourability of a hypergraph whose edges are the sets for non-adjacent pairs . In Section 3 we show that 2-colourability of 3-uniform hypergraphs is NP-complete, and, by a standard gadget argument, that this remains true for hypergraphs without Berge cycles of length two or three. In Section 4 we construct, from such a hypergraph , a graph of diameter two whose associated hypergraph contains every edge of exactly, while all its other edges can be made harmless; this proves Theorem 1.1. In Section 5 we attach to a ‘ladder’ of levels, which raises the diameter to exactly without changing whether ; this proves Theorem 1.2.
Suppose that has diameter two. Two adjacent vertices are joined by an edge, which is a shortest path with no internal vertex. Two non-adjacent vertices are at distance two, so the shortest -paths are the paths with , and . Consequently, is an MV set exactly when any two non-adjacent vertices of have a common neighbour not in .
Definition 2.1. Let be a graph of diameter two. The visibility hypergraph has vertex set and edge set
Lemma 2.2. Let be a graph of diameter two. Then if and only if is 2-colourable.
Proof. A partition of into at most two MV sets is the same as a colouring whose two colour classes are MV sets (one of them may be empty). By the observation above, both colour classes are MV sets if and only if any two non-adjacent vertices with the same colour have a common neighbour with the other colour, that is, if and only if no set with is monochromatic.
3. HYPERGRAPH 2-COLOURING WITHOUT SHORT CYCLES
A Berge cycle of length in a hypergraph consists of distinct vertices and distinct edges such that for all (indices modulo ). We say that a hypergraph has girth at least four if it has no Berge cycle of length two or three; equivalently, any two edges share at most one vertex, and there are no three edges and distinct vertices .
The NP-completeness of 2-colourability of hypergraphs goes back to Lovász [11]; for edges of size at most three, see also [8, SP4]. For completeness we include a short proof for 3-uniform hypergraphs.
Lemma 3.1. It is NP-complete to decide whether a 3-uniform hypergraph is 2-colourable.
Proof. Membership in NP is clear. We reduce from graph 3-colourability, which is NP-complete [8, GT4]. Given a graph , let be the 3-uniform hypergraph with vertex set and the edges
It can be constructed in polynomial time. We show that is 3-colourable if and only if is 2-colourable.
Let be a proper 3-colouring of . Colour red, and colour red if and blue otherwise. Each edge contains exactly one red vertex, namely . Each edge contains the red vertex and is not entirely red, since is impossible for an edge . So is 2-colourable.
Conversely, take a 2-colouring of ; exchanging the colours if necessary, we may assume that is red. Since is not monochromatic, some is red; choose such an and put . If and , then the edge is entirely red, a contradiction. So is a proper 3-colouring of .
We need the following variant, for hypergraphs without short cycles.
Lemma 3.2. It is NP-complete to decide whether a 3-uniform hypergraph of girth at least four is 2-colourable.
Proof. Membership in NP is clear. By a theorem of Erdős and Hajnal [7, Corollary 13.4], applied with (see also [10, 12] for constructive proofs), there is a 3-uniform hypergraph that is not 2-colourable and in which any edges cover at least vertices. In particular, it has girth at least four, since two edges sharing two vertices cover at most four vertices, and the three edges of a Berge cycle of length three cover at most six. Fix such a hypergraph, and let be an edge-minimal non-2-colourable sub-hypergraph of it, that is, is not 2-colourable but is 2-colourable for every edge of . Such an exists because the hypergraph is finite, and it still has girth at least four. Fix an edge of and let . Then:
(a) is 2-colourable, by the minimality of ;
(b) in every 2-colouring of the vertices have the same colour, since otherwise the colouring would be a 2-colouring of ; together with (a) and exchanging the colours, has 2-colourings in which are all red and 2-colourings in which they are all blue;
(c) no edge of contains two of , since such an edge would share two vertices with in .
The hypergraph is a fixed object, independent of the input.
We reduce from the problem of Lemma 3.1. Let be a 3-uniform hypergraph; we may assume that every vertex lies in some edge. For a vertex of degree in , replace by new vertices , using a different one in each of the edges of that contain ; we call the resulting edges clause edges. For every and every add a copy of in which is identified with , with , and all other vertices are new. Let be the resulting 3-uniform hypergraph. Its size is linear in the size of .
is 2-colourable if and only if is. Given a 2-colouring of , colour every with and extend the colouring to each by (b); this is a 2-colouring of . Conversely, in a 2-colouring of , property (b) applied to shows that all have the same colour; giving this colour yields a 2-colouring of , because every edge of corresponds to a clause edge of .
has girth at least four. Call the clause edges and the copies the pieces of ; every edge of lies in exactly one piece, and we identify a piece with its vertex set. Two clause edges are disjoint; a clause edge and share at most one vertex (a clause edge contains only one of ); and share exactly ; all other pairs of pieces are disjoint. In particular, two pieces share at most one vertex.
SIDDHESH CHAUBAL
Two edges in the same piece share at most one vertex, since has girth at least four, and two edges in different pieces share at most one vertex, since the pieces do. So there is no Berge cycle of length two.
Consider a Berge cycle . If all lie in one piece, then because has girth at least four (and a clause piece has only one edge). Otherwise split the cyclic sequence into maximal runs of consecutive edges lying in the same piece. Where the cycle passes from a run in a piece to the next run, in a piece , the vertex between them lies in . If there were exactly two runs, in pieces and , the two transition vertices would both lie in , which has at most one element, contradicting their distinctness. Hence there are at least three runs. Consecutive runs lie in pieces that intersect, and two clause edges never intersect, so some run lies in a copy . This run is entered and left through two distinct transition vertices, which are vertices of shared with other pieces; the only such vertices are and . By (c) no single edge of contains both, so this run has at least two edges. There are at least two other runs, with at least one edge each, so .
4. THE REDUCTION
Let be a 3-uniform hypergraph of girth at least four with vertex set . For every edge of choose one of its vertices as its centre, and write the edge as with centre . We construct a graph as follows.
-
The core vertices are the vertices of together with two new vertices .
-
For every edge of , the core vertex is joined to and to ; we call a partner pair. There are no other edges between core vertices.
-
For every pair of non-adjacent core vertices that is not a partner pair, add two new private vertices and , each adjacent to and to and to no other core vertex.
-
Any two private vertices are adjacent.
The graph has vertices and can be constructed in polynomial time. Since has girth at least four, two edges of share at most one vertex, so each pair of vertices lies in at most one edge of and each partner pair arises from exactly one edge.
Claim 1. For every edge of we have and .
Proof. Let . Two core vertices are adjacent only if they lie in a common edge of and one of them is its centre. If , then some edge of contains and , and because neither nor is the centre of ; then and share two vertices, a Berge cycle of length two. Hence .
The vertex is a common neighbour of and by construction. Let be another common neighbour. It is a core vertex, since receives no private vertices. Core edges join vertices of a common edge of , so has edges and , both different from since . If , then and share and and form a Berge cycle of length two; otherwise form a Berge cycle of length three through . Both contradict girth at least four, so .
Claim 2. Every core vertex has a private neighbour, and has diameter two.
Proof. The vertices and have no core neighbours and lie in no partner pair. Hence, for every core vertex , the pair receives private vertices, which are neighbours of both and . In particular every core vertex has a private neighbour (for , take ).
Now let be distinct non-adjacent vertices. If both are core vertices, they have a common neighbour: if is a partner pair, coming from an edge of , then is adjacent to both by construction; otherwise is adjacent to both. If is a core vertex and is a private vertex, then any private neighbour of is adjacent to , because private vertices are pairwise adjacent (it differs from because ). Two private vertices are adjacent. So any two non-adjacent vertices have a common neighbour; since is not complete (), it has diameter two.
Claim 3. is 2-colourable if and only if .
Proof. By Lemma 2.2 and Claim 2, it suffices to show that is 2-colourable if and only if is.
Suppose that has a 2-colouring. For every edge of , Claim 1 shows that is an edge of , so it is not monochromatic. Hence the restriction of the colouring to is a 2-colouring of .
Conversely, let be a 2-colouring of . Colour every with , colour and arbitrarily, every vertex red and every vertex blue. We check that no edge of is monochromatic, according to the type of the non-adjacent pair .
-
If is a partner pair from the edge , the edge of is by Claim 1, which is not monochromatic under .
-
If are core vertices forming no partner pair, the edge contains , which is red, and , which is blue.
-
If is a core vertex and a private vertex, the edge contains every private neighbour of (see the proof of Claim 2). By Claim 2, has private neighbours, and they come in pairs , so the edge contains a red and a blue vertex.
Two private vertices are adjacent, so there are no other non-adjacent pairs. Hence is 2-colourable.
Proof of Theorem 1.1. The problem is in NP: a colouring with two colours can be checked in polynomial time by checking that any two non-adjacent vertices with the same colour have a common neighbour with the other colour. By Lemma 3.2, 2-colourability of 3-uniform hypergraphs of girth at least four is NP-complete, and by Claims 2 and 3, is a polynomial-time reduction from this problem to deciding for graphs of diameter two.
5. LARGER DIAMETER
Let be an edge of a graph . We say that a graph is obtained from by attaching at the edge if is obtained from by adding new vertices and new edges, each new edge joining two new vertices or a new vertex to or .
Lemma 5.1. Let be obtained from a connected graph by attaching at an edge . Then every shortest path in between two vertices of lies in ; in particular, distances between vertices of are the same in and . Consequently, if is partitioned into two sets of , then their intersections with are sets of .
Proof. A path in between two vertices of that visits a new vertex must leave at one of and return at the other, since new vertices have no other neighbours in . Replacing the part between and , which has length at least two, by the edge gives a shorter path. Hence every shortest path between vertices of lies in , and distances between vertices of are the same in and .
For the consequence, let lie in the same set of the partition. Some shortest -path in has no internal vertex in ; it lies in and is a shortest -path there, so and are -visible in .
SIDDHESH CHAUBAL
The construction. Let be the target diameter, and put . Let be a 3-uniform hypergraph of girth at least four with at least one vertex, and let be the graph of Section 4. Let and be the private vertices of the pair (see the proof of Claim 2). They are adjacent, and they are twins: each is adjacent to , to and to all other private vertices, and to nothing else.
Let be obtained from by adding new vertices for , with the edges (), all four edges between and (), and all four edges between and ; see Figure 1. We call the -th level. The construction is polynomial. Thus is obtained from by attaching at the edge , so Lemma 5.1 applies with .

FIGURE 1. The graph , : a ladder of levels attached to at the twin private vertices and . Each level is an edge, consecutive levels are completely joined, and is completely joined to . In , the vertices and are adjacent to , and all other private vertices, which form a clique; the vertices of are at distance two from and . The colours are those used in Claim 6.
Claim 4. has diameter . Moreover, for we have and for , where if or is private, and if .
Proof. By Lemma 5.1, any two vertices of are at distance at most two in . In , the neighbours of are , and the other private vertices, while each vertex of is non-adjacent to and hence at distance two from , as has diameter two; the same holds for , since and are twins. This gives the stated values of .
Regard as level 0. Every edge of joins vertices whose levels differ by at most one, so a path from to a vertex of has at least edges before it reaches , and then enters at or . Hence , and for ; the path followed by a shortest -path attains these values. Similarly, two vertices in levels are at distance .
So every distance in is at most , with equality for and (X is non-empty because has at least one vertex). Hence has diameter .
Claim 5. If , then is 2-colourable.
Proof. By Lemma 5.1, a partition of into at most two MV sets restricts to one of , so , and is 2-colourable by Claim 3.
Claim 6. If is 2-colourable, then .
Proof. Colour as in the proof of Claim 3 (so is red and is blue), and colour every red and every blue. Let be non-adjacent vertices of the same colour. The argument below uses only that each level, the pair and each pair contain one red and one blue vertex; so by symmetry we may assume that and are red, and we find a shortest -path whose internal vertices are all blue. If exactly one of lies in a level, let it be ; distances are given by Claim 4. The possibilities for and are the following.
(1) : the colouring of is valid by Claim 3, and by Lemma 5.1 a shortest -path in is also one in .
(2) and with : the path has length .
(3) and (the only red vertex of ; here ): the path has length .
(4) and with : the path has length .
(5) and with : then . By Claim 2 it has a blue private neighbour , which is adjacent to (private vertices are pairwise adjacent, and as ). The path has length .
In each case the length equals , so the path is a shortest path, and its internal vertices are blue. Hence both colour classes are MV sets of .
Proof of Theorem 1.2. The case is Theorem 1.1. The problem is in NP for every : given a colouring with two colour classes, two vertices of the same class are -visible if and only if their distance in the subgraph induced by equals their distance in the whole graph, which can be checked by breadth-first search. For , Claims 4, 5 and 6 show that is a polynomial-time reduction from the problem of Lemma 3.2 to deciding for graphs of diameter .
Remark 5.2. Instead of , any pair of private vertices can be used, that is, can be any non-adjacent pair of core vertices that is not a partner pair. The proofs are the same, with replaced by the set of core vertices other than and .
6. CONCLUDING REMARKS
Theorem 1.2 shows that bounding the diameter does not make the problem of deciding tractable. We mention some questions that remain.
(1) For which is deciding NP-complete for graphs of diameter two?
(2) Which natural subclasses of diameter-two graphs admit a polynomial-time algorithm for deciding ?
USE OF GENERATIVE AI
During this work the author used Claude Opus 5.5 (Anthropic), which proposed the reduction and the proofs in this paper and helped prepare the manuscript. The author directed the investigation through questions that shaped its course, verified every step of each proof by hand, and takes full responsibility for the content of the publication.
SIDDHESH CHAUBAL
REFERENCES
[1] S. Babu, G. Di Stefano, A. Lakshmanan S., Mutual-visibility coloring of graphs, preprint, arXiv:2512.12251 (2025). [2] S. Babu, M. Jakovac, D. Kuziak, A. Lakshmanan S., I. G. Yero, A variety of the mutual-visibility coloring problem for graphs, preprint, arXiv:2609.31427 (2026). [3] B. Brešar, I. Peterin, B. Samadi, I. G. Yero, Independent mutual-visibility coloring and related concepts, Aequationes Math. 100 (2026), Paper No. 48. [4] S. Chaubal, Diameter-two graphs whose mutual-visibility chromatic number equals their chromatic number, preprint, arXiv:2610.39430 (2026). [5] S. Cicerone, G. Di Stefano, S. Klavžar, I. G. Yero, Mutual-visibility problems on graphs of diameter two, European J. Combin. 120 (2024), Paper No. 103995. [6] G. Di Stefano, Mutual visibility in graphs, Appl. Math. Comput. 419 (2022), Paper No. 126850. [7] P. Erdős, A. Hajnal, On chromatic number of graphs and set-systems, Acta Math. Acad. Sci. Hungar. 17 (1966), 61–99. [8] M. R. Garey, D. S. Johnson, Computers and Intractability: A Guide to the Theory of NP-Completeness, W. H. Freeman, San Francisco, 1979. [9] S. Klavžar, D. Kuziak, J. C. Valenzuela Tripodoro, I. G. Yero, Coloring the vertices of a graph with mutual-visibility property, Open Math. 23 (2025), Paper No. 20250193. [10] L. Lovász, On chromatic number of finite set-systems, Acta Math. Acad. Sci. Hungar. 19 (1968), 59–67. [11] L. Lovász, Coverings and colorings of hypergraphs, in: Proceedings of the Fourth Southeastern Conference on Combinatorics, Graph Theory, and Computing (Boca Raton, 1973), Congressus Numerantium VIII, Utilitas Math., Winnipeg, 1973, pp. 3–12. [12] J. Nešetril, V. Rödl, A short proof of the existence of highly chromatic hypergraphs without short cycles, J. Combin. Theory Ser. B 27 (1979), 225–227.
AFINIT, INDIA Email address: spchaubal@gmail.com