# A recognition algorithm for simple-triangle graphs

A simple-triangle graph is the intersection graph of triangles that are defined by a point on a horizontal line and an interval on another horizontal line. The time complexity of the recognition problem for simple-triangle graphs was a longstanding open problem, which was recently settled. This paper provides a new recognition algorithm for simple-triangle graphs to improve the time bound from O(n^2 m) to O(nm), where n, m, and m are the number of vertices, edges, and non-edges of the graph, respectively. The algorithm uses the vertex ordering characterization in our previous paper that a graph is a simple-triangle graph if and only if there is a linear ordering of the vertices containing both an alternating orientation of the graph and a transitive orientation of the complement of the graph.

## Authors

• 3 publications
• ### AOT: Pushing the Efficiency Boundary of Main-memory Triangle Listing

Triangle listing is an important topic significant in many practical app...
06/20/2020 ∙ by Michael Yu, et al. ∙ 0

• ### Proper Orientation Number of Triangle-free Bridgeless Outerplanar Graphs

An orientation of G is a digraph obtained from G by replacing each edge ...
07/15/2019 ∙ by J. Ai, et al. ∙ 0

• ### Triangle Centrality

Triangle centrality is introduced for finding important vertices in a gr...
04/30/2021 ∙ by Paul Burkhardt, et al. ∙ 0

• ### The complete set of minimal simple graphs that support unsatisfiable 2-CNFs

A propositional logic sentence in conjunctive normal form that has claus...
12/28/2018 ∙ by Vaibhav Karve, et al. ∙ 0

• ### TriPoll: Computing Surveys of Triangles in Massive-Scale Temporal Graphs with Metadata

Understanding the higher-order interactions within network data is a key...
07/26/2021 ∙ by Trevor Steil, et al. ∙ 0

• ### Preorder-Based Triangle: A Modified Version of Bilattice-Based Triangle for Belief Revision in Nonmonotonic Reasoning

Bilattice-based triangle provides an elegant algebraic structure for rea...
09/19/2016 ∙ by Kumar Sankar Ray, et al. ∙ 0

• ### On Large-Scale Graph Generation with Validation of Diverse Triangle Statistics at Edges and Vertices

Researchers developing implementations of distributed graph analytic alg...
03/24/2018 ∙ by Geoffrey Sanders, et al. ∙ 0

##### This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.

## Introduction

A graph is an intersection graph if there is a set of objects such that each vertex corresponds to an object and two vertices are adjacent if and only if the corresponding objects have a nonempty intersection. Such a set of objects is a representation of the graph. See [BLS99, Golumbic04, MM99, Spinrad03] for survey. Let and be two horizontal lines in the plane with above . Trapezoid graphs are the intersection graphs of trapezoids that are defined by an interval on and an interval on . Trapezoid graphs have been introduced in [CK87-CN, DGP88-DAM] as a generalization of both interval graphs and permutation graphs. Many recognition algorithms and structural characterizations are provided for trapezoid graphs [CC96-DAM, Cogis82b-DM, GT04, FHM94-SIAMDM, Langley95-DAM, MS94-JAL, MC11-DAM]. We obtain some interesting subclasses of trapezoid graphs by restricting the trapezoids in the representation. A trapezoid graph is a simple-triangle graph if every trapezoid in the representation is a triangle with the apex on and the base on . Similarly, a trapezoid graph is a triangle graph if every trapezoid in the representation is a triangle, but there is no restriction on which line contains the apex and the base. Simple-triangle graphs and triangle graphs have been introduced in [CK87-CN] and studied under the name of PI graphs and PI* graphs, respectively [BLS99, COS08-ENDM, CK87-CN, Spinrad03], where PI stands for Point-Interval. Moreover, a trapezoid graph is a parallelogram graph if every trapezoid is a parallelogram, and parallelogram graphs coincide with bounded tolerance graphs [BFIL95-DAM, GMT84-DAM]. These three graph classes are proper subclasses of trapezoid graphs, and they contain both interval graphs and permutation graphs as proper subclasses. The time complexity of the recognition problem of these three graph classes was a longstanding open problem [BLS99, Spinrad03], which was recently settled. While the problem is NP-complete for triangle graphs [Mertzios12-TCS] and parallelogram graphs [MSZ11-SIAMCOMP], an -time recognition algorithm has been given for simple-triangle graphs [Mertzios15-SIAMDM], where and are the number of vertices and non-edges of the graph, respectively. This algorithm reduces the recognition problem of simple-triangle graph to the linear-interval cover problem, a problem of covering an associated bipartite graph by two chain graphs satisfying additional conditions. In [Takaoka17-LNCS], we showed an alternative algorithm for the linear-interval cover problem, but this does not improve the running time. Meanwhile, we showed in [Takaoka18-DM] a vertex ordering characterization that a graph is a simple-triangle graph if and only if there is a linear ordering of the vertices containing both an alternating orientation of the graph and a transitive orientation of the complement of the graph. Using this vertex ordering characterization, we show in this paper an -time recognition algorithm for simple-triangle graphs, where is the number of edges of the graph. Our algorithm is shown in the next section, and correctness of the algorithm is proved in Section Document. We finally discuss our results and further research in Section Document.

## The recognition algorithm

### Preliminaries

#### Notation

In this paper, we will deal only with finite graphs having no loops and multiple edges. Unless stated otherwise, graphs are assumed to be undirected, but we also deal with graphs having directed edges. We write for the undirected edge joining a vertex and a vertex , and we write for the directed edge from to . For a graph , we sometimes write for the vertex set of and write for the edge set of . Let be an undirected graph. The complement of is the graph such that if and only if for any two vertices . A sequence of distinct vertices is a path from to in if . These edges are the edges on the path. The length of the path is the number of the edges on the path. A path is a cycle in if in addition . The edges and are the edges on the cycle. The length of the cycle is the number of the edges on the cycle. A chord of a path (cycle) is an edge joining two vertices that are not consecutive on the path (cycle). A path (cycle) is chordless if it contains no chords. Let be an undirected graph. An orientation of is a graph obtained from by orienting each edge in , that is, replacing each edge with either or . An oriented graph is an orientation of some graph. A partial orientation of is a graph obtained from by orienting each edge in a subset of . A partially oriented graph is a partial orientation of some graph. Notice that a (partially) oriented graph contains no pair of edges and for some vertices . We will denote a (partial) orientation of a graph only by its edge set when the vertex set is clear from the context. Let be a (partially) oriented graph. A sequence of distinct vertices is a directed path from to in if . A directed path is a directed cycle in if in addition . The edges on the path (cycle) and the length of the path (cycle) are defined analogously to the undirected case. A (partial) orientation of a graph is called acyclic if it contains no directed cycles. A linear extension (or topological sort) of an acyclic (partial) orientation is a linear ordering of the vertices such that if and only if is a predecessor of in the ordering. Let be a set of directed edges in . The reversal of is the set of directed edges obtained from by reversing all the edges in , that is, .

#### Comparability graphs

An orientation of a graph is a transitive orientation if and then . A graph is a comparability graph if it has a transitive orientation. The complement of a comparability graph is a cocomparability graph. The class of cocomparability graphs contains the class of trapezoid graphs as a proper subclass [DGP88-DAM, CK87-CN], and hence the complement of any simple-triangle graph has a transitive orientation. Note that every cocomparability graph contains no chordless cycle of length greater than or equal to 5 (see [BLS99, Gallai67] for example), and thus every chordless cycle of a cocomparability graph has length at most 4. An orientation of a graph is quasi-transitive if and then and therefore either or . In other words, an orientation of is quasi-transitive if for any path of three vertices in , either or . We can see that an orientation is transitive if and only if it is quasi-transitive and acyclic. Trivially, a graph having a transitive orientation also has a quasi-transitive orientation. The converse is also known to be true [Ghouila-Houri62, HH95-JGT], that is, if a graph has a quasi-transitive orientation that is not acyclic, then has another quasi-transitive orientation that is also acyclic. There is a well-known algorithm for recognizing comparability graphs and producing a transitive orientation of a graph, which takes time (see [Golumbic04] for example). A linear-time algorithm is also known for producing a transitive orientation of a comparability graph [MS99-DM]. To be precise, the algorithm produces a linear extension of the transitive orientation. However, even if the given graph is not a comparability graph, the linear-time algorithm may produce an orientation that is not transitive. Hence, to recognize comparability graphs, we must verify transitivity of the orientation. The best known method for verifying transitivity uses Boolean matrix multiplication to test whether , where is the adjacency matrix of the orientation (see [Spinrad03] for example). An alternative method for verifying transitivity, which takes time, is discussed in [Spinrad03, Section 11.1.4]. Let be the complement of a graph . The linear-time algorithm of [MS99-DM] also can produce a linear extension of an orientation of such that is transitive if and only if is a cocomparability graph. We show a method for verifying transitivity of in time. Recall that an orientation is transitive if and only if it is quasi-transitive and acyclic. Obviously, is acyclic. We can test whether is quasi-transitive by checking for any path of three vertices in , either or . The number of paths in of three vertices is at most , and they can be found in time. Thus we have the following. Cocomparability graphs can be recognized in time.

#### Alternately orientable graphs

An orientation of a graph is alternating if it is (quasi-)transitive on every chordless cycle of length greater than or equal to 4, that is, the directions of the edges alternate. A graph is an alternately orientable graph [Hoang87-JCTSB] if it has an alternating orientation. It is clear from the definition that alternately orientable graphs generalize comparability graphs. A polynomial-time recognition algorithm is known for alternately orientable graphs [Hoang87-JCTSB]. We say a graph is an alternately orientable cocomparability graph if it is a cocomparability graph that has an alternating orientation. Obviously, alternately orientable cocomparability graphs can be recognized in polynomial time. It is also known that every alternately orientable cocomparability graph is a trapezoid graph but the converse is not true [Felsner98-JGT]. We say an orientation is an acyclic alternating orientation if it is alternating and acyclic, and we say a graph is acyclic alternately orientable if it has an acyclic alternating orientation. We can see that an alternating orientation is acyclic if it contains no directed cycles of length 3. Recall that a graph has a quasi-transitive orientation if and only if it has an orientation that is quasi-transitive and acyclic. It was conjectured that a similar statement might hold for alternating orientation, that is, a graph is alternately orientable if and only if it has an acyclic alternating orientation [Hoang87-JCTSB]. Later, however, a counterexample was provided [Hougardy93-DM]. Thus, the class of acyclic alternately orientable graphs is a proper subclass of alternately orientable graphs. Moreover, the recognition problem is NP-complete for acyclic alternately orientable graphs. The recognition problem is NP-complete for acyclic alternately orientable graphs. We can verify in polynomial time whether an orientation is alternating [Hoang87-JCTSB]. Since testing acyclicity of an orientation takes linear time, the recognition problem is in NP. We show a polynomial-time reduction from the non-betweenness problem, which is known to be NP-complete [GM06-LNCS]. Given a finite set and a collection of ordered triples of distinct elements of , the non-betweenness problem is to decide whether there is a bijection such that for each , either or . Let be a graph such that V(G) &= { v_i : a_i ∈A } ∪{ u_i, w_i : t_i ∈C } and
E(G) &= { v_iv_j : 1 ≤i ¡ j ≤—A— } ∪{ u_hw_h, u_hv_j, w_hv_i, w_hv_k : t_h = (a_i, a_j, a_k) ∈C }. Clearly, we can construct the graph in time polynomial in and . We can also see from the construction that the set of chordless cycles contains all the chordless cycles of length grater than or equal to 4. Thus an orientation of is alternating if and only if for any three vertices with , either or . Therefore, has an acyclic alternating orientation if and only if there is a bijection such that for each , either or . Thus we have the theorem

#### The vertex ordering characterization of simple-triangle graphs

Now, we show the vertex ordering characterization of simple-triangle graphs. [[Takaoka18-DM]] A graph is a simple-triangle graph if and only if there is an (acyclic) alternating orientation of and a transitive orientation of the complement of such that is acyclic. Moreover, if is a simple-triangle graph, then for any transitive orientation of , there is an (acyclic) alternating orientation of such that is acyclic. An acyclic orientation of a complete graph is equivalent to the linear ordering of the vertices of the graph. The orientation is called an apex ordering of a simple-triangle graph since it coincides with the ordering of the apices of the triangles in the representation. Theorem The vertex ordering characterization of simple-triangle graphs implies that a simple-triangle graph is an (acyclic) alternately orientable cocomparability graph, but the converse is not known to be true [Takaoka18-DM]. We also note that Theorem The vertex ordering characterization of simple-triangle graphs is similar to a well-known fact that a graph is a permutation graph if and only if it is both a comparability graph and a cocomparability graph [PLE71-CJM].

### The recognition algorithm

Let be an alternating orientation of a graph , and let be a transitive orientation of the complement of . Suppose that is not acyclic. It is well known that an orientation of a complete graph is not acyclic if and only if it contains a directed cycle of length 3. Each directed cycle of length 3 in consists of either three edges in or two edges in with one edge in since is a transitive orientation. We will refer to a directed cycle of length 3 in as a -obstruction if and . It is clear from Theorem The vertex ordering characterization of simple-triangle graphs that if a graph is a simple-triangle graph, then there is a pair of an acyclic alternating orientation of and a transitive orientation of such that contains no -obstructions. Conversely, a graph is a simple-triangle graph if for some transitive orientation of , there is an acyclic alternating orientation of such that contains no -obstructions. We can also have the following. Let be a transitive orientation of . If has a (not necessarily acyclic) alternating orientation such that contains no -obstructions, then also has an acyclic alternating orientation of such that contains no -obstructions, that is, is a simple-triangle graph. Our recognition algorithm is due to this structural characterization, and we will prove the theorem when we show the correctness of the algorithm. Figure Document shows our algorithm to recognize simple-triangle graphs. The algorithm finds an apex ordering of the given graph if it is a simple-triangle graph or report that the graph is not a simple-triangle graph.

We remark that in Step 2 of the algorithm, we keep an edge undirected if it is not on a chordless cycle of length 4, since it is needed to do Step 3 and Step 4 correctly. If we do not need to find an apex ordering of the given graph, in Step 2 we only have to compute an alternating orientation of such that contains no -obstructions. We will prove the correctness of the algorithm in the next section. Notice that in order to prove the correctness, it suffices to show that when Step 3 is finished, is acyclic.

#### Details of the algorithm

In the rest of this section, we show that the algorithm runs in time. We assume without loss of generality that the given graph is connected and , since otherwise we apply the algorithm to each connected component. In Step 1, we use the linear-time algorithm of [MS99-DM], which produces a linear extension of a transitive orientation of the complement if the given graph is a cocomparability graph. As shown in Theorem Comparability graphs, we can verify transitivity of in time, and hence Step 1 can be performed in the same time bound. In Step 2, we construct the auxiliary graph of that is bipartite if and only if is alternately orientable. Then, we make a 2CNF formula , an instance of the 2-satisfiability problem, from . The partial orientation of can be obtained from a truth assignment of . When is not bipartite or cannot be satisfied, the algorithm reports that is not a simple-triangle graph. The vertices of the auxiliary graph

are all the ordered pairs

with . Each vertex of is adjacent to the vertex . Each vertex of is also adjacent to every vertex such that in , the vertices form a path of three vertices on a chordless cycle of length 4. We can see that is alternately orientable if and only if is bipartite, and an alternating orientation of can be obtained from one color class of . The number of vertices of is , and the number of edges of is at most since the number of paths of three vertices in is at most . Hence we can test the bipartiteness of in time. Now, we show that the auxiliary graph can be constructed from in time. The neighborhood of a vertex of is the set . We define that the upper set of is the set and the lower set of is the set . Let be an edge of . If and , then for any two vertices and , we have , that is, is a chordless cycle of length 4; otherwise either or , but if then implies , contradicting , and if then implies , contradicting . Similarly, for any two vertices and , we have that is a chordless cycle of length 4. Conversely, each chordless cycle of length 4 has two edges and such that , , , and . Therefore, we can construct the auxiliary graph by the following method. (1) For each edge , test whether and [resp. and ]. (2) If it is, then for any two vertices and [resp. and ], add to the edge joining and , the edge joining and , the edge joining and , and the edge joining and . (3) Finally, for each edge , add to the edge joining and . The first procedure takes time for each edge, and the second procedure takes time in total since the number of paths of three vertices in is at most . The third procedure takes time in total, and hence the auxiliary graph can be constructed in time. We next construct the 2CNF formula from . Recall that each vertex of is adjacent to . A connected component of consists of only two vertices and if and only if the edge of is not on a chordless cycle of length 4. We remove such components from , and let be the remaining components. To each component , we assign the Boolean variable . Since we assume that is bipartite, the vertices of each component can be partitioned into two color classes. We assign the literal to the vertices of one color class of , and we assign the literal (the negation of ) to the vertices of the other color class of . Notice that a vertex of has its literal if and only if the edge of is on a cycle of length 4. Let be the literal assigned to a vertex of . The 2CNF formula consists of all the clauses such that the vertices in form a path of three vertices with . When no literal is assigned to or , the 2CNF formula does not contain the clause. Let be a truth assignment of the variables in . Notice that in if and only if since each vertex of is adjacent to . We obtain the partial orientation of from by orienting each edge as if in . It is obvious from the construction of that a truth assignment satisfies if and only if contains no -obstructions. We can also see that the edges on every chordless cycle of length 4 is alternately oriented and the other edges remain undirected. The 2CNF formula has at most Boolean variables and at most clauses. We can also see that can be constructed in time, since all the paths of three vertices can be found in time. Since a satisfying truth assignment of a 2CNF formula can be computed in time linear to the size of (see [APT79-IPL] for example), Step 2 can be performed in time. It is easy to see that Step 3 and Step 4 can be performed in time and time, respectively. Now, we have the following. Simple-triangle graphs can be recognized in time, and an apex ordering of a simple-triangle graph can be computed in the same time bound. From Step 1 and Step 2 of the algorithm, we also have the following as a byproduct. Alternately orientable cocomparability graphs can be recognized in time, and alternating orientation of a cocomparability graph can be computed in the same time bound.

## Correctness of the algorithm

In this section, we prove correctness of our algorithm. In order to prove the correctness, it suffices to show that when Step 3 is finished, is acyclic, where is the resultant orientation of Step 3. Recall that the graph is an alternately orientable graph and the complement of is a comparability graph with a transitive orientation . Since is a cocomparability graph, the length of every chordless cycle in is at most 4. Recall also that has a partial orientation that satisfies the following three conditions: (1) contains no -obstructions, (2) the edges on every chordless cycle of length 4 are oriented so that the directions of the edges alternate, and (3) the other edges remain undirected. For a vertex of , let be the set of all the edges such that is a directed cycle in , and let be the partial orientation of obtained from by reversing the orientation of all the edges in , that is, . The outline of the proof is as follows. An alternating -cycle in with is a directed cycle of length with and for any (indices are modulo ). See Figure Document for example. We first show that

• is acyclic if and only if contains no alternating 6-cycles.

We next show the following:

• contains no alternating 6-cycles having the vertex ,

• the reversing the direction of the edges in generates no alternating 6-cycles,

• the directions of the edges still alternate in on every chordless cycle of length 4, and

• is still contains no -obstructions.

Thus continuing in this way for each vertex, we obtain the acyclic orientation such that contains no -obstructions, that is, is acyclic.

### Definitions and facts

We begin to state some definitions and facts. Let be four vertices of . If and , then , that is, is a chordless cycle of length 4. Recall that is a transitive orientation. If , then implies , contradicting . If , then implies , contradicting . Thus . Similarly, if , then implies , contradicting . If , then implies , contradicting . Thus . Suppose that contains an alternating 4-cycle with and . We have from Claim Document that is a chordless cycle of length 4. The directions of the edges on this cycle must alternate in , but , a contradiction. Thus contains no alternating 4-cycles. An alternating 4-anticycle of is a subgraph consisting of four vertices with and . We have from Claim Document that is a chordless cycle of length 4. The directions of the edges on this cycle must alternate in , but , a contradiction. Thus contains no alternating 4-anticycles. The following claim states the direction of chords of an alternating 6-cycle. If contains an alternating 6-cycle with and for any (indices are modulo 3), then . See Figure Document. If , then is an alternating 4-cycle, a contradiction. If , then implies , contradicting . Thus . We have from Claim Document that is a chordless cycle of length 4. Since the directions of the edges on this cycle alternate in , we have . By similar arguments, we also have and . Recall that for any directed edge , there are another two vertices of such that is a chordless cycle of length 4, since an edge of remains undirected if it is not on a chordless cycle of length 4. If there are four vertices with and , then there are another two vertices with and . In addition,

• and

• there is an alternating 6-cycle consisting of the vertices .

Since is oriented in , there are another two vertices with and . If , then implies , contradicting . If , then is a -obstruction, a contradiction. Thus . Similarly, if , then implies , contradicting . If , then is a -obstruction, a contradiction. Thus . If , then is a -obstruction, a contradiction. Suppose . If , then is a chordless cycle of length 4 with , contradicting the definition of . Thus . If , then implies , contradicting . If , then implies , but then is a -obstruction, a contradiction. Thus . If , then is a chordless cycle of length 4. Since , we have , but then is a -obstruction, a contradiction. Thus . If , then is a -obstruction, a contradiction. If , then implies , contradicting . Thus . If , then is a chordless cycle of length 4. Since , we have , but then is a -obstruction, a contradiction. Thus . Since is a chordless cycle of length 4 and , we have . Since is a chordless cycle of length 4 and , we also have . We can verify that for any directions are assigned to the edges , there is an alternating 6-cycle consisting of the vertices . If there is a directed cycle in , then there is an alternating 6-cycle of containing the vertices . Since is oriented in , there are another two vertices with and . We have from and . We also have from . If , then we have the claim from Claim Document since is a directed cycle of length 4 in . If , then we also have the claim from Claim Document since is a directed cycle of length 4 in . Therefore, we assume . Since is oriented in , there are another two vertices with and . We have from . We also have from and . If , then we have the claim from Claim Document since is a directed cycle of length 4 in . If , then we also have the claim from Claim Document since is a directed cycle of length 4 in . Therefore, we assume . We have from and . We also have from . Similarly, we have from . We also have from and . Therefore, the seven vertices are distinct. If , then four vertices form an alternating 4-anticycle, a contradiction. If , then is a -obstruction, a contradiction. Thus . Now, we have from Claim Document that is a chordless cycle of length 4. Since , we have . If , then implies , contradicting . If , then four vertices form an alternating 4-anticycle, a contradiction. Thus . Now, we have from Claim Document that is a chordless cycle of length 4. Since , we have . Now, we can see that is an alternating 6-cycle in . If there is a directed cycle in , then there is another vertex with and either or . We have the claim from Claims Document and Document.

### Main part of the proof

Now, we show the following series of claims, which proves the correctness of the algorithm. It is immediate from Claim Document that if contains an alternating 6-cycle, then contains a directed cycle of length 3. The following claim states that the converse is also true. (Recall that contains undirected edges. Thus may contain directed cycles of length greater than 3, and Claim Document does not imply the converse. ) If is not acyclic, then contains an alternating 6-cycle. Before proving the claim, we introduce the middle edge of a chordless cycle of length 4. Let be a cycle of length 4 in with and . We call the edge the middle edge of in . We also say an edge is a middle edge in if there is a chordless cycle of length 4 such that the edge is the middle edge of the cycle. Notice that for any edge on , there is the directed path from to in consisting of the edges in and the middle edge. For example, there is the directed path for the edge . Recall that each directed edge in is on a cycle of length 4. Thus if contains a directed cycle, then contains a directed cycle with consisting of the edges in and the middle edges in . We now show that if and are middle edges in for some (indices are modulo ), then either or . In addition, we show that if , then