{'fraction_non_alphanumeric': 0.02910994048026271, 'fraction_numerical': 0.008312239173565028, 'mean_word_length': 4.4492078285181735, 'pattern_counts': {'":': 0, '<': 2, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
What Makes the Recognition Problem Hard for Classes Related to Segment and String graphs?

We explore what could make recognition of particular intersection-defined classes hard. We focus mainly on unit grid intersection graphs (UGIGs), i.e., intersection graphs of unit-length axis-aligned segments and grid intersection graphs (GIGs, which are defined like UGIGs without unit-length restriction) and string graphs, intersection graphs of arc-connected curves in a plane. We show that the explored graph classes are NP-hard to recognized even when restricted on graphs with arbitrarily large girth, i.e., length of a shortest cycle. As well, we show that the recognition of these classes remains hard even for graphs with restricted degree (4, 5 and 8 depending on a particular class). For UGIGs we present structural results on the size of a possible representation, too.


Introduction
This article is a full version of an extended abstract [11]. Here, we provide mainly the details of the constructions promised there. Geometric intersection graphs are graphs with a geometric representation where each vertex is represented by a geometric object and the adjacency of a pair of vertices corresponds to the fact that the objects have a nonempty intersection. They are a practically important part of graph theory as some generally hard problems become efficiently solvable on some intersection classes (e.g., [1]). These efficient algorithms usually require an intersection representation instead of a graph, which motivates the recognition problem, i.e., the question of whether a given graph has a desired intersection representation.
Our attention focuses on unit grid intersection graphs, called UGIG, i.e., intersection graphs of unitlength axis-aligned non-overlapping line segments in the plane. Our results have influence even on other graph-classes, namely on grid intersection graphs that we denote as GIG defined similarly to UGIG, just without the restriction to unit length [3,6,13]. Grid intersection graphs have been studied also as PURE-2-DIR or B0-VPG. Obviously UGIGs form a subclass of GIGs. GIGs can be generalized to segment graphs, intersection graphs of straight-line segments in the plane. The topological versions of segment graphs are pseudosegment graphs where pseudosegments do not have to be straight, they just have to keep the topological properties of segments [4]. Even this class can be generalized to the class of string graphs, intersection graphs of arc-connected curves in the plane [7]. Many geometric intersection graph classes were defined in last years. Although it would be worth to mention more graph classes (like, e.g., polygoncircle graphs, graphs of interval filaments, circle graphs and many other), we are focusing already on relatively many classes. Therefore, we try to avoid introducing classes related to our results only losely where it is possible.
As there exist many classes of intersection graphs, it is useful to avoid exploring each class separately. For optimization problems, typically an efficient algorithm for a superclass yields an algorithm for subclasses. For the recognition problem this is not true. Due to this fact, sandwiching was introduced [10]. It is an approach close to approximability/inapproximability. A class B is sandwiched between classes A and C, if A ⊆ B ⊆ C. Given a reduction that produces either graphs from A or not even graphs from C, this reduction shows hardness for all classes sandwiched between A and C.
About the recognition of the mentioned classes, many results are known. The recognition problem of string graphs is NP-complete even for graphs without triangles [12,8], for segment and pseudosegment graphs the problem is known to be NP-hard even for graphs with arbitrarily large girth [10], it is not known whether the problem is in NP and Cartesian coordinates of endpoints of particular segments in a representation cannot be used as a polynomial certificate of representability [9]. It is known that GIGs are NP-complete to get recognized [7]; the same article shows that any class between 3-DIR (intersection graphs of straight line segments each using one of three permitted directions) and STRING (intersection graphs of arc-connected curves in a plane) is NP-hard to recognize.
Because for many intersection-defined classes the recognition problem is hard, we are trying to explore the reasons. The idea behind graphs without triangles or with high girth is that it is some form of density (of edges) that makes the recognition hard. This holds, e.g., for polygon-circle graphs, not, e.g., segment graphs [10]. As the "density" tries to restrict the number of edges, we tried to restrict the classes further to get polynomially recognizable classes, namely by bounding the maximum degree (as it efficiently bounds the number of edges in the graph). However, instead of finding polynomially recognizable classes, we show that all explored classes are rather resistant to this criterion.

The Results
Our main result whose proof we sketch in the following section is: Theorem 1. Between the following three pairs of graph-classes no polynomially recognizable class can be sandwiched even when restricted on graphs with arbitrarily large girth and yet on graphs with the maximum degree (at most) 5, 4 and 8, respectively: • UGIG and pseudosegment graphs, • GIG and segment graphs, • GIG and string graphs.
Conversely, we may state an observation that these graph classes are polynomially (or even trivially) recognizable for graphs with maximum degree 2, as such graphs consist of disjoint union of paths, cycles and isolated vertices. All such graphs either have the appropriate representation (by a class containing at least 3-DIR, i.e., class representable by segments in 3 directions), or, for UGIG, it might be necessary to verify whether the graph is bipartite. Provided that the input graph is bipartite for UGIGs, the recognition algorithm may just answer "yes". Note that between UGIG and GIG a sophisticated (hard) class can be established, e.g., length of an odd cycle can encode a program for universal Turing machine and the class contains just cycles encoding the Halting problem making such class algorithmically not recognizable. So, for classes sandwiched between UGIG and 3-DIR we must be careful even for graphs with maximum degree 2.
Our results answer a question of Kratochvíl and Pergel [10] whether string graphs with sufficiently large girth can be recognized in a polynomial time. Our construction shows not only that large girth does not help. Moreover, we show that even graphs with relatively low maximum degree are hard to get recognized.
In the rest of this section we show upper and lower bound on the size of a UGIG representation: Proposition 1. Any unit grid intersection graph on n vertices can be represented in a grid (n+1)×(n+1) with all coordinates being multiples of 1 n . Moreover, we can find such a representation that with respect to each axis no two segments have the same non-integral part of the coordinate.
Note that the lower bound for the granularity (multiples of 1 n ) is tight because of K 1,n−1 which requires this precision for the (distinct) coordinates, as all n − 1 segments of one part need to intersect (not just touch) the same segment of the other part and it is prohibited that two segments start on the same coordinate.
Proof: Without loss of generality, in the sequel we will describe the procedure for the x-axis. Projecting this arbitrary representation of G on the x-axis, we obtain a sequence of intervals (corresponding to the vertices in H) and points (corresponding to the vertices in V ). By eventually employing small perturbations, it can be assumed that the projected elements are all in general position: no interval is degenerated, no two endpoints coincide (here we treat the projection points stemming from V as endpoints).
To simplify the following sweeping-argument, we extend individual points to unit-segments (in an arbitrary fixed way along the x axis). Thus we obtain an arrangement of unit segments. We build the canonical representation by performing a sweep from left to right and employing the following steps: • For the left-most segment we assign to the right endpoint the coordinate 0 (hence the left endpoint now has coordinate −1). This segment is now the reference from which the rest of the construction will follow.
• We process the segments in their left to right ordering where each newly added segment has its left endpoint assigned to the next free 'slot': namely, the smallest multiple of 1 n that is free, such that the overlapping (or disjointness) conditions to the previously assigned segments are not violated. This is illustrated in Figure 1. Note that due to the chosen granularity it is always possible to find such a free slot. In the worst case, i.e. the segment to be added is disjoint to all the previous ones, the needed increment for the left coordinate is 1 + 1 n . This leads to an upper bound of n + 1 large bounding size per coordinate (which the initially mentioned example fulfills, note however, this is not an optimal representation).
• In the next step, the projection on the y − coordinate is processed analogously.
• After the double sweep, all relevant coordinates being known, one can draw the final configuration.
Note that the above procedure does not change the relative position of the endpoints and projected segments, hence not contradicting the adjacency and non-adjacency conditions.
. . . In the sequel, we define the boundary size as the semiperimeter of the bounding rectangle and prove that: Theorem 2. For all n ≥ 2, a UGIG representation of T n needs a boundary size of at least n.
We proceed inductively: The base case n = 2 is clear, as at least one unit is needed in both the horizontal and the vertical direction.
For the induction step, we apply the pigeonhole principle several times. Out of the 16n + 1 children of the root, at least 8n + 1 have their children either all above the root, or all below. Without loss of generality, we assume the latter is the case. Out of these 8n + 1 nodes, either at least 4n + 1 have children with an endpoint to the left of the root, or 4n + 1 have children to the right of the root. W.l.o.g. we consider the latter case. Restricting our analysis to these 4n + 1 nodes and their successors, we see that the paths of length two descending from the root form a nested structure, similar to the one in Figure 3. Consider the second lowest lying child of the root and let l be its descendant. We distinguish two cases: • At least one of the attached T n s does not go above l. Then, from the induction hypothesis, we need a boundary size of at least n for the copy of T n and an extra unit in the vertical direction that lies above l. Hence, in total, a rectangle of semiperimeter at least n + 1 is necessary.
• All attached T n s go above l. This can only happen via a vertical segment to the right or to the left of l. We apply the pigeonhole principle again, to conclude there exist 2n + 1 root children whose descending T n s reach above l from the right (the other case is analogous).
Lemma 1. Let u 1 , . . . u 2n+1 be the top-down ordering of the descendants of the above 2n + 1vertices and P 1 , . . . P 2n+1 the corresponding paths that go above l. Then y min (horizontal(P 2k )) < y min (P 2k−1 ) and y min (P 2k+1 ) < y min (P 2k ) − 1 for all k ≥ 1 (here y min (P i ) denotes the smallest y coordinate of the path P i ).
Proof: Note that at every even step, a horizontal segment is added strictly below the current lowest vertical one.
The second statement follows from the fact that the currently lowest horizontal segment can only be passed by a path from left to right, if this path has a vertical segment lying strictly below, otherwise the unit segment condition would be violated. The previous step ensures the depth increasing by 1.
As a corollary of Proposition 1, Theorem 1 and a trivial observation, classes UGIG and GIG are NPcomplete to recognize even with arbitrarily large girth.

The Reductions
First, we sketch the proof of Theorem 1, next we provide the details of the construction. We reduce planar 3-connected 3-SAT(4) shown to be NP-complete [8]. This is a special version of 3-SAT where each variable occurs at most 4 times and the incidence graph (of the formula) is planar and 3-connected (3-connectivity implies a unique planar embedding up to the outer face). The incidence graph is bipartite with one part formed by variables, the other by clauses and an edge means a presence of a variable in a clause. We follow the ideas of [10,5], i.e., for a planar embedding of the incidence graph, vertex representatives get represented by variable-gadgets or truth-splitters, clause representatives we replace by clause gadgets and the edges (of the incidence graph) we replace by pairs of paths whose left-right orientation represent the truth-assignment.
Variable-gadgets must keep the occurrences synchronized, clause-gadgets must be representable exactly for 7 satisfiable assignments. For the 1st case, as a variable gadget we take two vertices connected by an edge and each pair representing an occurrence stems from them to incur the situation of Figure 5. A clause-gadget is depicted in Figure 4, dashed curves depict arbitrarily long paths. For the 2nd case we use the same clause-gadget, but to decrease the maximum degree in the variable-gadget, we stick the 1st and the 2nd occurrence together and we represent the 3rd and 4th by the truth-splitter as depicted in Figure 6 without vertex c. For the 3rd case, we use the truth-splitter in Figure 6 (including vertex c) and a clause-gadget from Figure 10.  Fig. 5: The two distinct representations of the four occurrences incident to a variable gadget. The left pair is a pseudosegment representation, the right one a UGIG representation. In each pair, the left corresponds to the FALSE assignment, the right one to the value TRUE   The gadgets We first describe the clause gadget, which is the same as in [10]. We show it on the right in Figure 4. In the Figure 4 (right side), straight segments represent one edge, dashed lines depict arbitrarily long paths whose length depends on the required girth. Furthermore, any two paths that are not explicitely listed as sharing a vertex do not intersect.
The three pairs of adjacent vertices inside the gadget correspond to the three variables of the clause, and the pairs of paths incident to them correspond to the occurrence gadgets, which we describe in more detail below. To explain the construction in Figure 4, we denote the variables as 1st, 2nd and 3rd in clockwise order, with the 1st variable being represented by the topmost adjacent pair of vertices.
We color these six vertices red and blue, as follows: • Each adjacent pair consists of a blue and a red vertex.
• For the third pair, the vertex incident to the path connected to the cycle is colored red if and only if the corresponding variable does not appear negated in the clause.
• For the second pair, the opposite is the case. To obtain the circular orientation of the variables in the clause gadget, consider the unique planar embedding of B(F), and pick the circular ordering of the edges connecting the clause vertex to its three variable vertices. Moreover, to adjust for the desired girth, the lengths of the paths inside the gadget, as well as the length of the cycle between two different pairs, can be chosen arbitrarily long. We further adjust the path lengths to ensure the clause subgraph is bipartite and that the red vertices belong to the same partition.
The variable gadget is simple: it consists of two adjacent vertices, which we denote by a 1 and a 2 in the sequel.
The occurrence gadget consists of a pair of non-intersecting paths connecting the pair of vertices of the variable gadget to the corresponding pair of vertices in the clause gadget. To determine the exact adjacencies, we assume the variable gadget of x 1 has all four occurrences (less then three is impossible, due to B(F) being 3-connected). Let now C 1 , C 2 , C 3 , C 4 denote the clockwise circular order of the clauses that contain x 1 as a variable. Then, we connect a 1 to the red vertices of C 1 and C 3 and to the blue vertices of C 2 and C 4 . Analogously, we connect a 2 to the blue vertices of C 1 and C 3 and to the red vertices of C 2 and C 4 . As in the case of the clause gadget, these paths can be chosen long enough to ensure G(F) has the desired girth and is bipartite. Note that since the plane embedding is rigid, the lengths of the edges of B(F) are fixed. Therefore, in G(F), the lengths of the occurrence paths are chosen proportional to the length of the corresponding embedded edge of B(F). Notation 1. In the sequel, we refer to paths connecting a red vertex in a clause gadget to a vertex in a variable gadget as to red paths; moreover, we use the same description for paths connecting two red vertices. The definition of blue paths is analogous.
In the case only three clauses contain x 1 as a variable, we introduce a dummy occurrence. The dummy occurrence consists of a pair of paths that start from the vertices a 1 and a 2 of the variable gadget and are connected to two other occurrence gadgets via another path, as in the Figure 7. This latter path ensures that due to 3-connectivity in every plane pseudosegment representation of G(F), the dummy occurrence is "fixed" between the two other occurrences to which it is connected. Variable assignments and the UGIG representability of G(F) After having described the gadgets and thus the structure of G(F), we proceed to show that: Observation 2. All intersections between occurrence paths belonging to different clauses can be avoided. Indeed, if such intersections are unavoidable, they remain so even after contracting the representation of G(F) back to the one of B(F). However, the hypothesis states that the latter is plane. Hence, given a variable-consistent clockwise ordering of the paths in an occurrence, a pseudosegment representation is impossible if and only if there exists a clause gadget which becomes impossible to represent. Observation 3. We can assume without loss of generality that all literals are positive. Indeed, any UGIG representation of a clause gadget containing a negated literal is equivalent to an UGIG representation of the same clause gadget with all literals positive, but opposite variable assignment for all originally negative ones. This corresponds in practice to swapping the blue and red colors in the corresponding pair of crossing segments (and occurrence paths, respectively).
" ⇒: " Assume F is satisfiable and fix a variable assignment that evaluates to TRUE. For each variable gadget, choose the ordering of the paths in the occurrence pairs such that the red path is clockwise before the blue path if and only if the value of the variable is assigned to true. First, note that the variable and occurrence gadgets admit unit grid intersection representations in all cases. Together with first two observations above, it follows that all we need to check now is that the clause gadgets also admit unit grid intersection representations compatible with the representations of the occurrence gadgets. That is to say, the three pairs of occurrence paths leave it in a consistent order to that prescribed by their entering the variable gadgets.
For each clause, there exist seven combinations of variable assignments that satisfy it. Each such variable assignment corresponds to an ordering of the red and blue occurrence paths, within each of the three pairs. By our construction and using Observation 3, a literal evaluates to true if and only if the red occurrence path appears at the left of the blue path. The Figure 8 shows how it is possible to create a unit grid representation in the seven cases when the clause gadget evaluates to true, and none of the variables is negated.
" ⇐: " Assume F is not satisfiable, but G(F) admits a pseudosegment representation. From Observation 1 it follows that for each variable gadget, either all the red occurrences are clockwise before the corresponding blue ones, or all clockwise after. In this representation, there necessarily exists a clause where all the blue paths are represented clockwise before the paired red ones (after swapping colors for the negated literals, cf. Observation 3). Indeed, if this is not the case, then, by assigning the values of variables like in the proof of the forward direction, we obtain a truth assignment for F that makes it satisfiable, a contradiction.
Consider now the clause C where for all three variables the blue paths must occur clockwise before the red paths, as sketched in Figure 9. Recall that in this representation we assign to each literal a pair of intersecting pseudosegments. Starting from the top and proceeding clockwise, we denote these literals by L 1 , L 2 , L 3 , such that the two anchoring paths start from the red pseudosegment of L 3 and the blue one of L 2 . In the sequel, we will abuse the notation and denote by L i both the literal and the corresponding pair of pseudosegments.
First, we consider the red-blue intersecting pair that corresponds to L 3 . The proper intersection of two pseudosegments creates four half-pseudosegments sharing the intersection point as an endpoint. We label these half-segments clockwise by I, II, III, IV, such that in this representation the blue occurrence is incident in IV. Then, the path connecting the red pseudosegment to the cycle must be incident to III: incidence to I implies, if the path order is preserved, that the blue segment becomes isolated from those belonging to the other two crossing pairs, a contradiction. For the same reason, the red occurrence path is incident in I. Symmetrically, we can label the segment halves for the crossing pair of L 2 such that the path connecting the pair to the cycle is incident in III, the red occurrence in II and the blue occurrence in I .   I  II   III  IV   I  IV   III  II   I   II   III IV L1 L2 L3 Fig. 9: The placement of the occurrence and anchoring paths with respect to the half-segments of the crossings in an unsatisfied clause gadget Now, in order to connect the red pseudosegment of L 2 with the blue one of L 3 , this path needs to start in II of L 2 and end in IV of L 3 , since the red II of L 3 and blue IV of L 2 have no visibility. Then, the path connecting the blue pseudosegment of L 3 to the red one of L 2 must have III-III as start and ending points, since the only other option, I-I, isolates the blue L 3 and red L 2 pseudosegment from the crossing pair of L 1 , a contradiction. The paths are also represented in Figure 9 above. We now need to add four more connecting paths, ending up in one of the following cases: • If the L 1 − L 3 red path starts in the I half-segment of L 1 and ends in the I half-segment of L 3 , then the L 1 blue pseudosegment is isolated from L 2 .
• If the L 1 − L 2 red path starts in the I half-segment of L 1 and ends in the IV half-segment of L 3 , then the L 2 blue pseudosegment is isolated from L 3 .
• If the L 1 − L 3 red path goes from III to I and the L 1 − L 2 red path from III to IV, then the L 2 blue pseudosegment is isolated from L 1 .
We can therefore conclude that whenever F is not satisfiable, G(F) does not admit a pseudosegment representation.
For the degree in the construction, we can see that the highest degree occurs in the variable gadget where we need vertices of degree 5. In the next section we briefly mention how to get rid of this problem.

GIG
We use suitable parts of the previous construction, i.e., we just change the variable gadget (for a gadget with lower degree). In order to represent occurrences of a variable (that are consistent with the truthassignment) we pick the occurrence gadgets or 1st and 2rd occurrence (pairs of paths) and stick them together. We label the occurrences so that the remaining is the 3rd, if there remain two (3rd and 4th), the 3rd is above paths representing 1st and 2nd while the 4th is below. If we stick the paths (representing 1st and 2nd occurrence) like shown in Figure 6, right picture without vertex c. In this way we keep them synchronized. The depicted construction enforces the 3rd occurrence (steming upwards from this pattern) to be synchronized with the 1st occurrence. For the 4th occurrence we perform the same split from the 2nd occurrence. Vertex c is so called degradation gadget that is used in the next section. This construction uses only vertices of maximum degree 4.
This implies the 2nd result, i.e.: Theorem 4. Between class of grid intersection graphs and pseudosegment graphs no polynomially recognizable class can be sandwiched even if we restrict on graphs with arbitrarily large girth and maximum degree at most 4.

String graphs
Theorem 5. Between class of grid intersection graphs and string graphs no polynomially recognizable class can be sandwiched even if we restrict on graphs with arbitrarily large girth and maximum degree at most 8.
Proof: Figure 6 shows GIG representation of the variable gadget and of truth-splitter. Occurence gadgets (pairs of paths) are represented in the same way as for UGIGs, so the only problem is to show the representability of clause gadget for satisfiable assignments and irepresentability for unsatisfiable assignment. The former is just an exercise either on homeomorphism if we try to stretch and align representation in Figure 10, or we may extend Figure 8. The remaining part is to explain why non-representable version of the clause gadget admits not even a string representation. In the text, we promise that strings depicted on the left picture in Figure 10 by straight green segments cannot make use of further (mutual) intersections. First observation is that due to the design of the gadget, they cannot be represented outside the dashed black boxes (drawn suggestively around their intersection-point). Each green segment intersects the box in two points (i.e., it intersects two curves representing its boundary). When we try to find a path (for a possible string) that would connect these two points, we realize that these two points are separated by a Jordan curve (formed by curves that must not be intersected with the green string) and therefore the green string has to pass through the box. That is why our drawing with the intersection of green segments inside the black dashed box is not misleading. When we pick any pair of these green segments and try to make the appropriate curves to intersect outside the black dashed square, again, we find a Jordan circle that cannot be crossed by either (green) curve and therefore they cannot mutually intersect outside the black dashed box (drawn on the picture around their intersection). That is why we turn up in a similar situation as is depicted in Figure 9; in fact, around the intersections of red and blue curves, there is the representation of the black (dashed) box and this box must not be accessed by any path present in the segment version of the gadget. Therefore, the paths connecting red and blue vertices (in Figure 9) can use just four "half-strings" (that mutually do not intersect) and because of the same reason as in the case of pseudosegments they cannot be represented.
Maximum degree in the construction is 8.

Conclusion and Open Problems
We have defined a new measure that can influence the hardness of the recognition problem for graph classes whose recognition is generally hard and we tried to get as tight results for particular graph classes as possible. For several classes, we have almost succeeded, usually 1 or 2 values are unclear. This fact motivates the open problems: What is the complexity of recognizing for string graphs, segment graphs and GIGs (and preferably all classes between them) when we restrict our attention to graphs with maximum degree 3? How does the answer change when we restrict only to graphs with large girth (note that our reductions are meeting both criteria simultaneously)? We may also ask, what is the complexity of recognizing UGIGs with maximum degree 3 or 4 (both are open so far, our reduction works for degree at least 5). Further we may ask the same problem for string graphs with arbitrarily large girth and maximum degrees from 3 to 7.
For what graph classes does this new measure help more and which classes remain hard even with low degrees? What happens, e.g., with polygon-circle graphs (that can be polynomially recognized when restricted on graphs with girth at least 6) where the reduction requires vertices of high degree? It seems [2] that even any class between UGIGs and pseudosegment graphs remains NP-hard to get recognized even if the underlying graphs is almost planar (i.e., after removal of just one vertex it becomes planar) even for graphs with arbitrary girth (like our construction does). However, that construction requires one vertex to have a degree linearly large. What happens if we require all degrees to be bounded by a constant?
What restrictions do we have to apply for classes between GIGs and pseudosegments to make them polynomially recognizable?