Representing Graphs via Pattern Avoiding Words

The notion of a word-representable graph has been studied in a series of papers in the literature. A graph $G=(V,E)$ is word-representable if there exists a word $w$ over the alphabet $V$ such that letters $x$ and $y$ alternate in $w$ if and only if $xy$ is an edge in $E$. If $V =\{1, \ldots, n\}$, this is equivalent to saying that $G$ is word-representable if for all $x,y \in \{1, \ldots, n\}$, $xy \in E$ if and only if the subword $w_{\{x,y\}}$ of $w$ consisting of all occurrences of $x$ or $y$ in $w$ has no consecutive occurrence of the pattern 11. In this paper, we introduce the study of $u$-representable graphs for any word $u \in \{1,2\}^*$. A graph $G$ is $u$-representable if and only if there is a labeled version of $G$, $G=(\{1, \ldots, n\}, E)$, and a word $w \in \{1, \ldots, n\}^*$ such that for all $x,y \in \{1, \ldots, n\}$, $xy \in E$ if and only if $w_{\{x,y\}}$ has no consecutive occurrence of the pattern $u$. Thus, word-representable graphs are just $11$-representable graphs. We show that for any $k \geq 3$, every finite graph $G$ is $1^k$-representable. This contrasts with the fact that not all graphs are 11-representable graphs. The main focus of the paper is the study of $12$-representable graphs. In particular, we classify the $12$-representable trees. We show that any $12$-representable graph is a comparability graph and the class of $12$-representable graphs include the classes of co-interval graphs and permutation graphs. We also state a number of facts on $12$-representation of induced subgraphs of a grid graph.


Introduction
The notion of a word-representable graph was first defined in [11]. A graph G = (V, E) is word-representable if there exists a word w over the alphabet V such that letters x and y alternate in w if and only if xy is an edge in E. For example, the cycle graph on four vertices labeled by 1, 2, 3 and 4 in clockwise direction can be represented by the word 14213243. Word-representable graphs have been studied in a series of papers [1]- [7], [9], [11]- [13], and they will be the main subject of an up-coming book [10].
The first examples of graphs that are not word-representable were given in [11]. In fact, V. Limouzy [private communication, 2014] noticed that it is NP-hard to determine whether a given graph is wordrepresentable, see [10] for the details. In [14] it was proved that any comparability graph G is not just word-representable, but it is permutationally word-representable. That is, for the graph G, there exists a word w with the necessary letter alternation properties such that w is obtained by concatenating a number of permutations.
The key observation that motivated this paper was the fact that the study of word-representable graphs is naturally connected with the study of patterns in words. That is, let P = {1, 2, . . .} be the set of positive integers and P * be the set of all words over P. If n ∈ P, then we let [n] = {1, . . . , n} and [n] * denote the set of all words over [n]. Given a word w = w 1 . . . w n in P * , we let A(w) be the set of letters occurring in w. For example, if w = 4513113458, then A(w) = {1, 3, 4, 5, 8}. If B ⊆ A(w), then we let w B be the word that results from w by removing all the letters in A(w) \ B. For example, if w = 4513113458, then w {1,3,5} = 5131135. If u ∈ P * , we let red(u) be the word that is obtained from u by replacing each occurrence of the i-th smallest letter that occurs in w by i. For example, if u = 347439, then red(u) = 123214.
Given a word u = u 1 . . . u j ∈ P * such that red(u) = u, we say that a word w = w 1 . . . w n ∈ P * has a u-match starting at position i if red(w i w i+1 . . . w i+j−1 ) = u. Then we can rephrase the definition of word-representable graphs by saying that a graph G is wordrepresentable if and only if there is a labeling G = ([n], E), and a word w ∈ [n] * such that for all x, y ∈ [n], xy ∈ E if and only if w {x,y} has no 11-matches. This led us to the following defintion. Given a word u ∈ [2] * such that red(u) = u, we say that a graph G is u-representable if and only if there is a labeling G = ([n], E), and a word w ∈ [n] * such that for all x, y ∈ [n], xy ∈ E if and only if w {x,y} has no u-matches. In this case we say that w u-represents G = ([n], E).
This definition leads to a number of natural questions. For example, how much of the theory of 11-representable graphs carries over to urepresentable graphs? Can we classify the u-representable graphs for small words u such as u = 111, u = 1111, u = 12, or u = 121? If a graph G = ([n], E) is u-representable, can we always find a word w which is a shuffle of a finite set of permutations representing some labeled version of G?
Given how involved the theory of word-representable graphs is, our first surprise was the fact that every graph is 111-representable. Indeed, we will show that for every k ≥ 3, every graph is 1 k -representable. Thus, we decided to explore the next simplest case, which is the class of 12-representable graphs.
It turns out that there is a rich theory behind the class of 12representable graphs. For example, we will show that not every graph is 12-representable. In particular, the cycles C n for n ≥ 5 are not 12representable. We will also show that there are non-12-representable trees, which contrasts with the fact that every tree is 11-representable. In fact, we will give a complete classification of the 12-representable trees. We say that a tree T = (V, E) is a double caterpillar if and only if all vertices are within distance 2 of a central path. We will prove that a tree T is 12-representable if and only if T is a double caterpillar.
Further, we will show that the class of 12-representable graphs is properly included in the class of comparability graphs, and it properly includes the classes of co-interval graphs and permutation graphs as shown in Figure 1. It turns out that the notion of 12-representable graphs is a natural generalization of the notion of permutation graphs. Figure 1 also gives examples of graphs inside/outside the involved graph classes. For instance, even cycles of length at least 6, being comparability graphs, are not 12-representable (see Theorem 8 in Section 3); also, odd wheels on six or more vertices are not 11-representable [11].
A fundamental difference between word-representable graphs and urepresentable graphs is the following. For word-representable graphs, it is not so important whether we deal with labeled or unlabeled graphs: two isomorphic graphs are both either word-representable or not. On the other hand, for certain u, a given graph G may have two different labeled versions G 1 = ([n], E 1 ) and G 2 = ([n], E 2 ) such that there is a word w which u-represents G 1 but there is no word w which urepresents G 2 . In fact, we will see the phenomenon in the case where u = 12. This is why we say an unlabelled graph is u-representable if it admits labeling G = ([n], E) such that there is word w which u-represents G.  This paper is organized as follows. In Section 2, we give all necessary definitions and show that any graph is 1 k -representable if k ≥ 3. Some basic properties of 12-representable graphs are established in Section 3. In Section 4, we shall prove that a tree T is 12-representable if and only if T is a double caterpillar. In Section 5, we compare the class of 12representable graphs to other graph classes thus explaining Figure 1. In Section 6, we provide a discussion of 12-representability of induced subgraphs of a grid graph. Finally, in Section 7, we introduce a number of new ways to define representability of simple graphs, directed graphs, and hypergraphs via words subject to certain pattern avoidance conditions. We also define several analogues of Wilf-equivalencies in Section 7, which are yet to be studied.

Preliminaries
A simple graph G = (V, E) consists of a set of vertices V and a set of edges E of the form xy where x, y ∈ V and x = y. All graphs considered in this paper are simple and finite. Sometimes V will be a finite subset of P. In this case we say that the graph is labeled. For an unlabeled graph we define its labeling as an assignment to its vertices some elements of P (labels).
If G = (V, E) is a labeled graph (i. e. V ⊂ P) and |V | = n, then the reduction of G, denoted red(G), is a relabeling G = ({1, . . . , n}, E ) such that the label on the i-th smallest vertex of V is replaced by i.
Let G = (V, E) be a graph and v ∈ V . Then we say that the graph G = (V , E ) is obtained by adding a copy v of the vertex v if where v a ∈ E * if and only if va ∈ E and E * does not contain edges not involving v .
Given a word w = w 1 . . . w k ∈ P * and x, y ∈ A(w), we say that x and y alternate in w if w {x,y} is either of the form xyxyxy . . . of even or odd length or yxyx . . . of even or odd length. Let G = (V, E) be a labeled graph. Then we say that G is word-representable if there exists a word w ∈ V * such that for all x, y ∈ V , xy is an edge in E if and only if x and y alternate in w. In such a situation, we say that w word-represents G and w is called a word-representant of G.
We say that H = (V , E ) is an induced subgraph of G = (V, E) if V ⊆ V and for all x, y ∈ V , xy ∈ E if and only if xy ∈ E. Then we have the following observation establishing the hereditary nature of the notion of graph word-representability.
Indeed, it is easy to see that if w represents G = (V, E), then w V represents H = (V , E ).
In this paper, we introduce two generalizations of the notion of a word-representable graph -see Definitions 1 and 5. In Section 7, we will discuss several other natural notions of representing simple graphs, directed graphs, and hypergraphs by words subject to certain pattern avoidance conditions. The key to our main generalization is to re-frame the notion of word-representable graphs in the language of patterns in words. Note that x and y alternate in a word w ∈ P * if and only if w {x,y} has no 11-match. Thus, a graph G = ([n], E) is word-representable if and only if there is a word w ∈ [n] * such that for all x, y ∈ [n], xy is an edge in E if and only if w {x,y} has no 11-match. This leads us to our main definition. Definition 1. Let u = u 1 . . . u j be a word in {1, 2} * such that red(u) = u. Then we say that a labeled graph G = ([n], E) is u-representable if there is a word w ∈ P * such that for all x, y ∈ [n], xy ∈ E if and only if w {x,y} has no u-match. We say that an unlabeled graph H is u-representable if there exits a labeling of H, H = ([n], E ), such that H is u-representable. In such a situation, we say that H realizes the u-representability of H.
Thus, by Definition 1, G is word-representable if and only if G is 11-representable. Note that replacing "word-representable graphs" by "u-representable graphs" in Observation 1, we would obtain a true statement establishing the hereditary nature of u-representable graphs.
The theory of word-representable graphs is rather involved, and thus the following theorem, where 1 k denotes k 1s, came as a surprise to us.
Proof. Fix any k ≥ 3. Clearly, if G is the complete graph K n on vertex set [n], then G is 1 k -representable by any permutation of [n], in particular, w = 12 . . . n 1 k -represents K n .
We proceed by induction on the number of edges in a graph with the base case being the complete graph. Our goal is to show that if G is 1 k -representable, then the graph G obtained from G by removing any edge ij is also 1 k -representable.
Suppose that w 1 k -represents G = ([n], E) and let p(w) denote the initial permutation of w. That is, p(w) is obtained from w by removing all but the leftmost occurrence of each letter. For example, p(31443266275887) = 31426758. Further, let π be any permutation of [n]\{i, j}. Then we claim that the word Indeed, the vertices i and j are not connected any more because w {i,j} contains i k . Also, no new edge can be created because of the presence of w as a subword. Thus, we only need to show that each edge ms represented by w is still represented by w if s = j or m = i.
If s = j and m = i, then either In each case, it is easy to see that w {s,i} has no 1 k -match so that w 1 k -represents the edge is.
If m = i and s = j, then either In each case, it is easy to see that w {m,j} has no 1 k -match so that w 1 k -represents the edge mj.
Finally suppose m, s ∈ {i, j} and m occurs before s in π. . Then either .. In each case, it is easy to see that w {m,s} has no 1 k -match so that w 1 k represents the edge ms.
We note that there are some natural symmetries among u-representable graphs. That is, suppose that u = u 1 . . . u j ∈ P * and red(u) = u. Let the reverse of u be the word u r = u j u j−1 . . . u 1 . Then for any word w ∈ P * , it is easy to see that w has a u-match if and only if w r has a u r -match. This justifies the following observation.
For any word w = w 1 . . . w k ∈ P * whose largest letter is n, we let xy ∈ E if and only if n + 1 − x and n + 1 − y are adjacent in G. One can think of the supplement of the graph G = (V, E) as a relabeling where one replaces each label x by the label n + 1 − x.
It is easy to see that if w witnesses that G = ([n], E) is u-representable, then w c witnesses that G is u c -representable. This justifies the following observation.
We can combine Observations 2 and 3 to prove the following fact about 12-representable graphs. Suppose that w 12-represents G. Then w r 21-represents G and, hence, (w r ) c 12-represents G. It follows that if a vertex v has label 1 (resp., n) in some labeling realizing the 12representability of an unlabeled graph G, then there is another labeling realizing the 12-representability of G such that the vertex v has label n (resp., 1).

12-representable graphs
In this section we begin the study of 12-representable graphs. Our first topic of study is the length of a word w than can 12represent a graph. Recall that G = ([n], E) is a permutation graph if and only if there is a permutation σ of [n] such that for all 1 ≤ i < j ≤ n, ij is in E if and only if j occurs before i in σ. However, this means that σ 12-represents G. Thus we have the following simple fact. Proposition 1. A graph G can be 12-represented by a permutation if and only if G is a permutation graph.
It follows that all graphs on at most four vertices are 12-representable (since C 5 is the minimum graph that is not a permutation graph). We will study the place of 12-representable graphs among the other graph classes in Section 5.
Next we show that any 12-representable graph can be 12-represented by a word having at most two copies of each letter.
Theorem 2. Let G = (V, E) be a labeled representable graph. Then there exists a word-representant w in which each letter occurs at most twice.
Proof. Let w represent G and suppose that a letter j occurs in w more than twice. Then let w = AjBjC, where A and C do not contain any copies of j. Note that ij ∈ E if and only if (i < j and all copies of i are in C) or (i > j and all copies of i are in A). So, any copies of the letter j in B do not affect on the neighborhood of the vertex j in G and therefore they can be omitted. Doing the same with all other letters occurring in w more than twice, one obtain a required word w representing G.
Note that replacing "at most" by "exactly" in the statement of Theorem 2, we obtain a true statement. This is based on the fact that replacing a letter x in a word 12-representing a graph by any number of copies of x, we obtain a word 12-representing the same graph.
Then the graph H obtained by adding to G a copy of v is also 12representable.
Proof. Let i be the label of v. First, increase by 1 all labels j > i, keeping all other labels the same. Add a copy of v and label it i + 1 to obtain a labeling of H. Now, in a word w 12-representing G replace each letter j > i by j + 1 and substitute each occurrence of i by i(i + 1) to obtain a word w . Clearly, ia is an edge in H if and only if (i + 1)a is an edge in H, and i and i + 1 are not adjacent in H. All edges not involving v and its copy are the same in G and H. Thus, w 12represents H.
Next, we shall consider labeled graphs I 3 , J 4 and Q 4 presented in Figure 2. These graphs will play a key role in determining which graphs are 12-representable.
Proof. First, suppose that G has a subgraph H such that red(H) = I 3 . Thus H must be of the form H = ({i, j, k}, {ij, jk}) where i < j < k. Now, for a contradiction, suppose that w = w 1 . . . w n 12represents G. Let w m be the left-most occurrence of j in w. Then since ij ∈ E, no i occurs in w 1 . . . w m−1 , and since jk ∈ E, no k occurs in w m+1 . . . w n . But then, clearly, w {i,k} has no 12-match, which contradict the condition that ik ∈ E.
Next, suppose that G has a subgraph H such that red(H) = J 4 or red(H) = Q 4 . Thus, H must be of the form H = ({i, j, k, }, {ik, j }) where max{i, j} < min{k, }. Again, for a contradiction, suppose that w = w 1 . . . w n 12-represents G. Let w t be the right-most occurrence of k in w. Then since ik ∈ E, no i occurs in w 1 . . . w t−1 , and since jk ∈ E, it must be the case that j occurs in w 1 . . . w t−1 . Let w s be the left-most occurrence of j in w. Then s < t. But since j ∈ E, no occurs in w s+1 . . . w n . Next, let w r be the right-most occurrence of in w. Then r < s. But this would imply that i ∈ E which is a contradiction.
An immediate corollary to Lemma 4 is that in a 12-representable labeled graph, the labels must alternate in size through any induced path in the graph.
Let us say that a labeled graph G = (V, E), where V ⊂ P, has a bad path if G has an induced path P whose endpoints are labeled by two smallest elements in P .
Lemma 5. Let G = ([n], E) be a labeled graph. Then if G has a bad path P of length at least 3, then G is not 12-representable.
Proof. Let P = x 0 x 1 . . . x s and max{x 0 , x s } < min{x 1 , x 2 , . . . , x s−1 }. If s ≥ 4 then the reduction of the subgraph induced by {x 0 , x 1 , x s−1 , x s } is J 4 or Q 4 . If s = 3 then without loss of generality x 1 < x 2 , and the reduction of the subgraph induced by {x 0 , x 1 , x 2 } is I 3 . In both cases G is not 12-representable by Lemma 4.
We note that Lemma 5 does not say that paths are not 12-representable, it only states the certain properties of its labeling. In fact, all paths are 12-representable since they are caterpillars, and all caterpillars are permutation graphs [16]. Lemma 6. Let G = (V G , E G ) and H = (V H , E H ) be 12-representable graphs. Assume that there are labelings of G and H such that x ∈ V G and y ∈ V H receive the smallest or the highest labels. Then the graph G ∪ H ∪ {xy} obtained from disjoint copies of G and H by adding the edge xy, is 12-representable.
Proof. Suppose, without loss of generality, that in our labelings V G = {1, 2, . . . , k} and V H = {k + 1, k + 2, . . . , }. Moreover, by Lemma 3 we can assume that x is labeled by k and y is labeled by k + 1. Denote by w G and w H the words 12-representing G and H, respectively. Let w G be the word obtained from w G by replacing each occurrence of k by k + 1, and w H be the word obtained from w H by replacing each occurrence of k + 1 by k. It is easy to see that the word w = w G w H represents the graph G ∪ H ∪ {xy}.
Given two subsets of positive integers A and B, we write A < B if every element of A is less than every element of B, i. e. x < y whenever x ∈ A and y ∈ B. A subset U ⊂ V is a cutset if G \ U is disconnected.
Proof. Let H = red(G 1 ∪ G 2 ). Then 1 ∈ V 1 . Denote by k > 1 the smallest element in V 2 . Assume that the property V 1 < V 2 does not hold. Then V 1 contains labels that are greater than k. Denote by C 1 (resp., C 2 ) the set of all vertices in V 1 whose labels are less (resp., greater) than k. Since G 1 is connected, there is an edge ab such that a ∈ C 1 and b ∈ C 2 . Denote by a neighbor of k in G 2 . Then the reduction of the subgraph induced by {a, b, k, } is either J 4 or Q 4 , and so G is not representable by Lemma 4, a contradiction. Hence, The following theorem provides examples of non-12-representable graphs. Note that we have shown that C 3 and C 4 are 12-representable. It turns out that they are the only 12-representable cycles.
Theorem 8. C n is not 12-representable for any n ≥ 5.
Proof. Suppose for a contradiction that C n is 12-representable where n ≥ 5. Let 1, x 1 , . . . , x n−1 be the labels of vertices as we proceed around the cycle in a clockwise order. Then since no subgraph of C n can reduce to I 3 by Lemma 4, the sequence 1, x 1 , x 2 , . . . , x n−1 , 1 must be an updown sequence, i. e. 1 < x 1 > x 2 < x 3 > x 4 < · · · x n−2 < x n−1 > 1. This is clearly impossible if n is odd. Now assume that n is even. But then consider the position of 2 in the sequence 1, x 1 , x 2 , . . . , x n−1 , 1. Clearly 2 cannot be equal to x 1 or x n . But this means that one of the two paths that connect 1 to 2 around the cycle would be a bad path of length at least 3 which is impossible by Lemma 5.

Characterization of 12-representable trees
A caterpillar is a tree in which all the vertices are within distance 1 of a central path. In this paper, we need the notion of a double caterpillar defined as follows.

Definition 2.
A double caterpillar T is a tree in which all the vertices are within distance 2 of a central path. Such a path is called a double caterpillar's spine if it is obtained by first removing all leaves from T and then removing all leaves from the obtained tree.
A star or star tree is the complete bipartite graph K 1,n . Here we allow n ≥ 0, where n = 0 corresponds to the graph K 1 (an isolated vertex). The centrum of a star is the all-adjacent vertex in it. Suppose that a vertex v in a tree T is adjacent to vertices v 1 , v 2 , . . . , v k . Removing v we obtain a forest T \v whose ith component T i is determined by the tree having v i as a vertex. We say that the ith component of the forest is good if it is a star with centrum at the vertex v i . Lemma 9. If a tree T is 12-representable then for any vertex v, at most two components T i of the forest T \v are not good.
Proof. Note that all trivial (one-vertex) components of T \v are good by the definition. Let T 1 , T 2 , . . . , T k be non-trivial components of T \v. By Lemma 7 we can assume that the labels of these components satisfy the property T 1 < T 2 < · · · < T k . Now, suppose that there are three components of the forest T \v which are not good. Without loss of generality, we can assume that these components are T 1 , T 2 and T 3 . Further, assume that the vertices v, v 1 , v 2 and v 3 receive labels r, m 1 < m 2 < m 3 , respectively, in some labeling T realizing representability of T . Since T 2 is not good, it contains two vertices y 1 , y 2 such that y 1 m 2 , y 1 y 2 ∈ E and y 2 m 1 ∈ E.
Note that a similar statement is true for T 1 and T 3 . The structure of these components is schematically shown in Figure 3.
Note that if m 1 < r < m 3 then we obtain a contradiction with Lemma 4 since the reduction of {v, v 1 , v 3 } induces I 3 . We can now assume that r < m 1 , since for the case r > m 3 we can take the supplement of T and apply the observation about 12representable graphs given at the end of Section 2. Since T 1 < T 2 < T 3 we have r < min{y 1 , y 2 } < max{y 1 , y 2 } < m 3 , and therefore the subgraph induced by the vertices {r, y 1 , y 2 , m 3 } reduces to a copy of Q 4 , which is impossible by Lemma 4.
Note that a tree T \v can have two components which are not good (see, for example, Figure 4), and thus Lemma 9 cannot be enhanced. Proof. Necessity. Suppose that a tree T is not a double caterpillar. Further, suppose that P = v 1 v 2 . . . v k is a longest path in T . Since all trees of diameter 5 are double caterpillars, P has at least six edges, and thus k ≥ 7. By our assumption, T has a vertex v at distance 3 from P . Suppose that v i is the closest to v vertex on the path P . Since P is of maximum length, we have i ∈ {4, 5, . . . , k − 3}. But then in the forest T \v i at least three components which are not good, namely those containing v, v 1 and v k . Thus by Lemma 9, T is not 12-representable.  Sufficiency. By Lemma 3, we can assume that no leaf has a sibling.
To show that any such double caterpillar is 12-representable, we will use induction on the length of double caterpillar's spine, and prove the statement for uniform double caterpillars DC(P 2n ) with even spines P 2n = v 1 v 2 . . . v 2n presented schematically in Figure 5; then any other double caterpillar will be 12-representable due to Lemma 3 and Observation 1.
We will prove even a stronger statement, namely that there is a labeling of DC(P 2n ) in which the label of v 1 is 1 and that of v 2n is the maximum label 2n(k+1). The base of the induction is given by labeling DC(P 2 ) presented in Figure 6, and the following 12-representant: 24365 . . . (2k + 2)(2k + 1)(2k + 4)(2k + 6) . . . (4k + 2)(4k + 4)135 . . . (2k + 1)(2k + 4)(2k + 3)(2k + 6)(2k + 5) . . . (4k + 2)(4k + 1)(4k + 3) stated on two lines. It is straightforward to check that this word has the right alternating properties. Now, suppose that we are given a double caterpillar DC(P 2n ). Choose any 1 ≤ r ≤ n−1 and remove the edge v 2r v 2r+1 on DC(P 2n )'s spine. We get two double caterpillars with even spines DC(P 2r ) and DC(P 2(n−r) ) on s = 2r(k + 1) and t = 2(n − r)(k + 1) vertices respectively. We can now apply the induction hypothesis to DC(P 2r ) and DC(P 2(n−r) ), i. e. consider the labeling of DC(P 2r ) where v 1 has the smallest label 1 and v 2r has the largest label s, and the labeling of DC(P 2(n−r) ) where v 2r+1 has the smallest label s + 1 and v 2n has the largest label s + t. Now apply Lemma 6 to connect these graphs by the edge v 2r v 2r+1 thus obtaining a labeling realizing 12-representability of DC(P 2n ) in such a way that v 1 has the smallest label 1 and v 2n has the largest label s + t = 2n(k + 1) (recall that in the proof of Lemma 6 no vertices except for the endpoints of the inserted edge changed their labels). Note that the labeling presented in the proof of Theorem 10 is not the only possible labeling for double caterpillars. For example, the tree presented in Figure 7 has the spine 1,9,8,15, while the maximum label is 16.

12-representable graphs and known classes of graphs
The goal of this section is to justify Figure 1. Let us recall the definitions and known properties of some graph classes. A comparability graph is an undirected graph that connects pairs of elements that are comparable to each other in a partial order (a poset). Comparability graphs are also known as transitively orientable graphs or partially orderable graphs. A transitive orientation of a graph is an acyclic orientation that has a property that if a → b and b → c are arcs then we must have the arc a → c. A graph G is a co-comparability graph if its complement G c is a comparability graph. It is known [4] that a graph G is a permutation graph if and only if both G and its complement G c are comparability graphs. An interval graph is the intersection graph of a family of intervals on the real line. It has one vertex for each interval in the family, and an edge between every pair of vertices corresponding to intervals that intersect. A graph G is cointerval if its complement G c is an interval graph. A graph is chordal if it has no induced cycle on at least 4 vertices. It is a well known fact [5] that a graph is an interval graph if and only if it is chordal and a co-comparability graph.
As it is mentioned in the introduction, any comparability graph is word-representable [14], and any odd cycle of length 5 or more, being a non-comparability graph, is word-representable [10]. Moreover, odd wheels on six or more vertices are non-word-representable [11], and the set of 1 k -representable graphs, for any k ≥ 3, coincides with the set of all graphs by Theorem 1. Our next result shows that any 12representable graph is necessarily a comparability graph.
Theorem 11. If G is a 12-representable graph, then G is a comparability graph.
Proof. By Lemma 4, any induced path P of length 3 is such that red(P ) = I 3 . We now direct edges in G so that if ab is an edge and a < b then the arc a → b goes from a to b. This orientation is obviously acyclic. We claim that this orientation is, in fact, transitive, which completes the proof of our theorem. Indeed, if the directed copy of G contains a directed path P of length 3, say a → b → c, then we must have the arc a → c in the graph or otherwise red( P ) = I 3 .
Theorem 12. If G is a co-interval graph, then G is 12-representable.
Proof. Suppose that G is a co-interval graph on n vertices. It is a well-known easy fact that for any interval graph, there is its interval representation such that the endpoints of intervals are all distinct. Consider such an interval representation of the complement graph G c .
Next, put to an interval in this representation a label n − i + 1 if the left endpoint of this interval is the ith one from left to right among all left endpoints. Such a labeling induces a labeling of G. We refer to Figure 8 for an example of a co-interval graph C and its labeling based on the endpoints of the intervals.
Next, form a word w corresponding to labeled intervals by going through all interval endpoints (both left and right endpoints) from left to right and recording their labels in the order we meet them. For example, for the labeled interval representation in Figure 8, the word w is 76755434261213. Optionally, all occurrences of ii, like 55 in the last word, can be replaced by a single i. We claim that the word w 12-represents G. Indeed, let i < j. If ith and jth intervals overlap, then w {i,j} = jiji or w {i,j} = jiij; anyway, i and j are not adjacent. Otherwise, by the choice of the labeling, the ith interval lies directly to the right from the jth one, and thus w {i,j} = jjii, i. e. ij is an edge.
To conclude our description of Figure 1, we would like to justify that the Venn diagram presented by us is proper, namely that there are strict inclusions of sets and also there is no inclusion of the class of co-interval graphs into the class of permutations graphs, and vice versa, and these classes do overlap. Note that it remains to explain the set inclusions only inside the class of 12-representable graphs since the rest of the diagram has been already explained above.
B=" B c =" Clearly, complete graphs are both co-interval graphs (for the set of non-intersecting intervals) and permutation graphs (for the identity permutation). In Figure 9, there are two graphs, A and B, and their complements A c and B c . The graph A is a permutation graph (for 2143) but not a co-interval graph, because its complement is not chordal. The graph B is 12-representable by Theorem 10, while it is neither a permutation graph nor a co-interval graph since B c is neither a comparability graph [16] (note that B = T 2 in their notation) nor a chordal graph (adbc in an induced C 4 ).
Finally, for the sake of completeness, let us provide an example of a co-interval graph that is not a permutation graph. Consider the graph G n whose vertices are defined by all intervals of non-zero length with left endpoints in the set {0, 1, . . . , n} and right endpoints in the set {1 − , 2 − , . . . , n − }, where ∈ (0, 1). Further, two vertices are connected in G n by an edge if and only if the intervals corresponding to them do not overlap. By definition, G n is a co-interval graph. It is therefore a comparability graph corresponding to the following poset P on V (G n ): I < J if and only if the interval I lies entirely to the left of the interval J. We claim that G n is not a permutation graph if n is large enough. This follows from two known facts. First [2], a graph G is a permutation graph if and only if it is the comparability graph of a poset that has dimension at most 2. On the other hand, the Example 8.1.4 in [15] shows that the dimension of the poset P grows arbitrary large while increasing n. Therefore, for large enough n, the graph G n becomes a non-permutation graph.

Grid graphs
In this section, we consider certain induced subgraphs of a grid graph or polyominoes. Examples of a grid graph and some of its possible induced subgraphs are given in Figure 10, where the notions of "corner graphs" and "skew ladder graphs" were invented by us. Clearly, grid graphs with holes or grid graphs containing a 3 × 3 grid subgraph are not 12-representable because of large induced cycles (cycles of length at least 8) contained in them, which are not possible in 12-representable graphs by Theorem 8.
The situation with ladder graphs, corner graphs and skew ladder graphs is different. These graphs turn out to be 12-representable. Note that such a representability for ladder graphs follows from representability of any of the other two classes of graphs.
It would be interesting to know whether or not induced subgraphs of a grid graph have a nice 12-representation classification, which we leave as an open problem along with the larger problem of finding a classification of 12-representable graphs.

Other notions of word-representable graphs
As it is mentioned in Section 2, apart from our main generalization, given in Definition 1, of the notion of a word-representable graph, we have another generalization given in Definition 5 below. In this section, we also state some other ways to define the notion of a (directed) graph representable by words. Our definitions can be generalized to the case of hypergraphs by simply allowing words defining edges/non-edges be over alphabets containing more than two letters. However, the focus of this paper was studying 12-representable graphs, so we leave all the notions introduced below for a later day to study.
Given a word u = u 1 . . . u j ∈ P * such that red(u) = u, and a word w = w 1 . . . w n ∈ P * , we say that the pattern u occurs in w if there exist 1 ≤ i 1 < · · · < i j ≤ n such that red(w i 1 . . . w i j ) = u, and that w avoids u if u does not occur in w.
Given a word v = v 1 . . . v j ∈ P * and a word w = w 1 . . . w n ∈ P * , we say that v exactly occurs in w if there exist 1 ≤ i 1 < · · · < i j ≤ n such that w i 1 . . . w i j = v and that w exactly avoids v if v does not exactly occur in w. We say that w has an exact v-match starting at position i if w i w i+1 . . . w i+j−1 = v.
Similar definitions can be made for set of words. That is, let Γ be a set of words in P * such that red(u) = u for all u ∈ Γ. Then we say that Γ occurs in w = w 1 . . . w n ∈ P * if there exist 1 ≤ i 1 < · · · < i j ≤ n such that red(w i 1 . . . w i j ) ∈ Γ, and that w avoids Γ if Γ does not occur in w. We say that w has a Γ-match starting at position i if red(w i w i+1 . . . w i+j−1 ) ∈ Γ. Similarly, if ∆ is any set of words in P * , we say that ∆ exactly occurs in w = w 1 . . . w n ∈ P * if there exist 1 ≤ i 1 < · · · < i j ≤ n such that w i 1 . . . w i j ∈ ∆, and that w exactly avoids ∆ if ∆ does not occur in w. We say that w has an exact ∆-match starting at position i if w i w i+1 . . . w i+j−1 ∈ ∆.
The study of pattern avoidance and pattern containment in words and permutations is a fast growing area (see [8] for a comprehensive introduction to the field).
We defined the notion of a u-representable graph in Definition 1. More generally, we can make the same definition for sets of words.
Definition 3. Let Γ be a set of words in {1, 2} * such that red(u) = u for all u ∈ Γ. Then we say that a graph G = (V, E), where V ⊂ P, is Γ-representable if there exists a word w ∈ P * such that A(w) = V and for all x, y ∈ V , xy ∈ E if and only if w {x,y} has a Γ-match.
Definition 4. Let Γ be a set of words in {1, 2} * such that red(u) = u for all u ∈ Γ. Then we say that a graph G = (V, E), where V ⊂ P, is Γ-occurrence representable if there exists a word w ∈ P * such that A(w) = V and for all x, y ∈ V , xy ∈ E if and only if Γ occurs in w {x,y} .
In the case where Γ = {u} consists of a single word, we simply say that a graph G is u-occurrence representable if G is Γ-occurrence representable. For example, the 11-occurrence representable graphs are very simple. That is, if a word w = w 1 . . . w n 11-occurrence represents a graph G = (V, E), then any vertex x such that w has two or more occurrences of x, cannot be connected to any other vertex y since 11 will always occur in w {x,y} . Let I = {x ∈ V : x occurs more than once in w} and J = {y ∈ V : y occurs exactly once in w}. Then it is easy to see that the elements of J must form a clique in G, while the elements of I form an independent set. Thus, if G is 11-occurrence representable, then G consists of a clique together with a set of isolated vertices. Clearly, all such graphs are 11-occurrence representable, which gives a characterisation of 11-occurrence representable graphs.
Another simple observation is that the sets of 12-representable graphs and 12-occurrences representable graphs coincide, since a word contains a 12-match if and only if it contains a 12-occurrence.
Similarly, we have the following analogues of our definition for exact matchings and exact occurrences.
Definition 5. Let ∆ be a set of words in P * . Then we say that a graph G = (V, E), where V ⊂ P, is exact-∆-representable if there is a word w ∈ P * such that A(w) = V and for all x, y ∈ V , xy ∈ E if and only if w {x,y} has an exact ∆-match. Definition 6. Let ∆ be a set of words in P * . Then we say that a graph G = (V, E), where V ⊂ P, is exact-∆-occurrence representable if there is a word w ∈ P * such that A(w) = V and for all x, y ∈ V , xy ∈ E if and only if ∆ exactly occurs in w {x,y} .