Partial and Simultaneous Transitive Orientations via Modular Decompositions

A natural generalization of the recognition problem for a geometric graph class is the problem of extending a representation of a subgraph to a representation of the whole graph. A related problem is to find representations for multiple input graphs that coincide on subgraphs shared by the input graphs. A common restriction is the sunflower case where the shared graph is the same for each pair of input graphs. These problems translate to the setting of comparability graphs where the representations correspond to transitive orientations of their edges. We use modular decompositions to improve the runtime for the orientation extension problem and the sunflower orientation problem to linear time. We apply these results to improve the runtime for the partial representation problem and the sunflower case of the simultaneous representation problem for permutation graphs to linear time. We also give the first efficient algorithms for these problems on circular permutation graphs.


Introduction
Representations and drawings of graphs have been considered since graphs have been studied [29].A geometric intersection representation of a graph G = (V, E) with regards to a class of geometric objects C, is a map R : V → C that assigns objects of C to the vertices of G such that G contains an edge uv if and only if the intersection R(u) ∩ R(v) is non-empty.In this way, the class C gives rise to a class of graphs, namely the graphs that admit such a representation.As an example, consider permutation diagrams where C consists of segments connecting two parallel lines 1 , 2 , see Figure 1b, which defines the class Perm of permutation graphs.Similarly, the class CPerm of circular permutation graphs is obtained by replacing 1 , 2 with concentric circles and the geometric objects with curves from 1 to 2 that pairwise intersect at most once; see Figure 1c.A key problem in this context is the recognition problem, which asks whether a given graph admits such a representation for a fixed class C. Klavík et al. introduced the partial representation extension problem (RepExt(C)) for intersection graphs where a representation R is given for a subset of vertices W ⊆ V and the question is whether R can be extended to a representation R of G, in the sense that R| W = R [29].They showed that RepExt can be solved in linear time for interval graphs.The problem has further been studied for proper/unit interval graphs [27], function and permutation graphs (Perm) [26], circle graphs [11], chordal graphs [28], and trapezoid graphs [30].Related extension problems have also been considered, e.g., for planar topological [1,25] and straight-line [34] drawings, for 1-planar drawings [14], for contact representations [10], and for rectangular duals [12].
A related problem is the simultaneous representation problem (SimRep(C)) where input graphs G 1 . . ., G r that may share subgraphs are given and the question is whether they have representations R 1 , . . ., R r such that for i, j ∈ {1, . . ., r} the shared graph H = G i ∩ G j has the same representation in R i and R j , i.e., R i | V (H) = R j | V (H) .If more than two input graphs are allowed, usually the sunflower case (SimRep (C)) is considered, where the shared graph H = G i ∩ G j is the same for any i = j ∈ {1, . . ., r}.I.e., here the question is whether H has a representation that can be simultaneously extended to G 1 , . . ., G r .Simultaneous representations were first studied in the context of planar drawings [5,9], where the goal is to embed each input graph without edge crossings while shared subgraphs have the same induced embedding.Unsurprisingly, many variants are NP-complete [18,37,2,15].Motivated by applications in visualization of temporal relationships, and for overlapping social networks or schedules, DNA fragments of similar organisms and adjacent layers on a computer chip, Jampani and Lubiw introduced the problem SimRep for intersection graphs [24].They provided polynomial-time algorithms for two chordal graphs and for SimRep (Perm).They also showed that in general SimRep is NP-complete for three or more chordal graphs.The problem was also studied for interval graphs [23,4,6], proper/unit interval graphs [36], circular-arc graphs [6] and circle graphs [11].
Many of the considered graph classes are related to the class Comp of comparability graphs [20].An orientation O of a graph G = (V, E) assigns to each edge of G a direction.The orientation O is transitive if uv, vw ∈ O implies uw ∈ O.A comparability graph is a graph for which there is a transitive orientation.A partial orientation is an orientation of a (not necessariliy induced) subgraph of G. Similar to RepExt, SimRep and SimRep, the problems OrientExt, SimOrient and SimOrient for comparability graphs ask for a transitive orientation of a graph that extends a given partial orientation and for transitive orientations that coincide on the shared graph, respectively.The key ingredient for the O(n 3 ) algorithm solving RepExt(Perm) by Klavík et al. [26] is a polynomial-time solution for OrientExt based on the transitive orientation algorithm by Gilmore and Hoffman [19].Likewise, the O(n 3 ) algorithm solving SimRep (Perm) by Jampani and Lubiw [24] is based on a polynomial-time algorithm for SimOrient based on the transitive orientation algorithm by Golumbic [20].

RepExt SimRep Comp
O((n + m)∆) [26] O(nm) [24] Perm O(n 3 ) [26] O(n 3 ) [24] CPerm open open Table 1 Known runtimes on the left and new runtimes on the right.For SimRep we set n =  for RepExt(CPerm) and SimRep (CPerm) in Section 6.Table 1 gives an overview of the state of the art and our results.In Section 7 we show that the simultaneous orientation problem and the simultaneous representation problem for permutation graphs are both NP-complete in the non-sunflower case.

Modular Decompositions
Let G = (V, E) be an undirected graph.We write G[U ] for the subgraph induced by a vertex set U ⊆ V .For a rooted tree T and a node µ of T , we write T [µ] for the subtree of T with root µ and L(µ) for the leaf-set of T [µ].
A module of G is a non-empty set of vertices M ⊆ V such that every vertex u ∈ V \M is either adjacent to all vertices in M or to none of them.The singleton subsets and V itself are called the trivial modules.A module M V is maximal, if there exists no module M such that M M V .If G has at least three vertices and no non-trivial modules, then it is called prime.We call a rooted tree T with root ρ and L(ρ) = V a (general) modular decomposition for G if for every node µ of T the set L(µ) is a module; see Figure 2. Observe that for any two nodes µ 1 , µ 2 ∈ T such that neither of them is an ancestor of the other, G contains either all edges with one endpoint in L(µ 1 ) and one endpoint in L(µ 2 ) or none of them.For two vertices u, v ∈ V we denote the lowest common ancestor of their corresponding leaves in T by lca T (u, v).For a set of leaves L, we denote the lowest common ancestor by lca T (L).
With each inner node µ of T we associate a quotient graph G[µ] that is obtained from G[L(µ)] by contracting L(ν) into a single vertex for each child ν of µ; see Figure 2. In the rest of this paper we identify the vertices of G[µ] with the corresponding children of µ.Every edge uv ∈ E is represented by exactly one edge rep T (uv) in one of the quotient graphs of T , namely in the quotient graph G[µ] of the lowest common ancestor µ of u and v.More precisely, if ν and λ are the children of µ with u ∈ L(ν) and v ∈ L(λ), then rep T (uv) = νλ.For an oriented edge uv, rep T (uv) is also oriented towards its endpoint ν with v ∈ L(ν).If T is clear from the context, the subscript can be omitted.Let µ be a node in T .For a vertex u ∈ L(µ) we denote the child λ of µ with u ∈ L(λ) by rep µ (u).
A node µ in a modular decomposition T is called empty, complete or prime if the quotient graph G[µ] is empty, complete or prime, respectively.By K(T ), P (T ) we denote the set of all complete and prime nodes in T , respectively.For every graph G there exists a uniquely defined modular decomposition, that we call the canonical modular decomposition of G, introduced by Gallai [17], such that each quotient graph is either prime, complete or empty and, additionally, no two adjacent nodes are both complete or are both empty; see Figure 2. Note that in the literature, these are referred to as modular decompositions, whereas we use that term for general modular decompositions.For a prime node µ in the canonical modular decomposition of G, for every child ν of µ, L(ν) is a maximal module in G[L(µ)] and for every maximal module M in G[L(µ)] there exists a child ν of µ with L(ν) = M .
McConnell and Spinrad showed that the canonical modular decomposition can be computed in O(|V | + |E|) time [31].Let µ be a node in a modular decomposition for G.A µ-set U is a subset of L(µ) that contains for each child λ of µ at most one leaf in L(λ).If U contains for every child λ of µ a vertex in L(λ), we call it maximal.Lemma 1.Let T be a modular decomposition of a graph G.After a linear-time preprocessing we can assume that each node of T is annotated with its quotient graph.Moreover, the following queries can be answered in O(1) time: 1) Given a non-root node ν of T , find the vertex of the quotient graph of ν's parent that corresponds to ν.

2) Given a vertex v in a quotient graph G[µ]
, find the child of µ that corresponds to v. Proof.We focus on constructing the quotient graphs.The queries can be answered by suitably storing pointers during the construction.For every node µ in T we initiate the quotient graph with one vertex for each child of µ and equip the children of µ and their corresponding vertices with pointers so that queries 1) and 2) can be answered in O(1) time.
Next, we compute the edges of the quotient graphs.The difficulty here is to find for each edge uv in a quotient graph G[µ] the children λ u , λ v of µ with u ∈ L(λ u ) and v ∈ L(λ v ).For each node µ of T we compute a list L µ that contains all edges uv of G with lca T (u, v) = µ.Namely, we use the lowest-common-ancestor data structure for static trees of Harel and Tarjan [22], to compute lca T (u, v) for each edge uv and add uv to L lca(u,v) .Afterwards, we perform a bottom-up traversal of the inner nodes of T that maintains for each leaf v of T the processed root r(v) = µ, where µ is the highest already-processed node of T with v ∈ L(µ).
Initially, we set r(v) = v for all leaves of T , and we mark all leaves as processed.When processing a node µ, we determine the edges of G[µ] as follows.We traverse the list L µ and for each edge uv ∈ L µ , we determine the children r(u) and r(v) of µ.From this, we determine the corresponding vertices of G[µ] and add an edge with a pointer to uv between them.This may create multi-edges.We find those by sorting the incidence list of each vertex by the number of the other incident node in linear time using radix sort [13] and an arbitrary enumeration of V (G[µ]).We then replace all parallel edges between two vertices with a single edge and annotate it with all pointers of the merged edges.For each pointer from an edge e in G[µ] to a represented edge uv, we then annotate uv with a pointer to e.
Afterwards, we update r(v) for all v ∈ L(µ) to µ and mark µ as processed.To maintain the processed roots of all leaves, we employ a union-find data structure, which initially contains one singleton set for each leaf and when a node µ has been processed, we equip it with a maximal µ-set containing an arbitrarily chosen vertex from every set associated with a child of µ and afterwards unite the sets associated with its children.Since the union-find tree is known in advance (it corresponds to T ), the union-find operations can be performed in amortized O(1) time [16].
We observe that the total size of all lists L µ is O(m) and moreover T has at most 2n − 1 nodes.Therefore the whole preprocessing runs in linear time.
Let µ be a node in a modular decomposition T of G and let µ 1 µ 2 be an edge in We obtain an orientation of G from an orientation T [G] of the quotient graphs of T as follows.Every undirected edge uv in E with rep(uv) = µ 1 µ 2 ∈ T [G], is directed from u to v. We say that T represents an orientation O of G, if there exists an orientation T [G] of the quotient graphs of T that gives us O.We denote the set of all transitive orientations of G represented by T by to(T ).We get an orientation of the quotient graphs of T from an orientation of G, if for each oriented edge µ 1 µ 2 , all edges represented by µ 1 µ 2 are oriented from L(µ 1 ) to L(µ 2 ).Let T now be the canonical modular decomposition of G. Then T represents exactly the transitive orientations of G [17].It follows that G is a comparability graph if and only if T can be oriented transitively.
If G is a comparability graph, every prime quotient graph G[µ] = (V µ , E µ ) has exactly two transitive orientations, one the reverse of the other [20], and with the algorithm by McConnell and Spinrad [31]

Transitive Orientation Extension
The partial orientation extension problem for comparability graphs OrientExt is to decide for a comparability graph G with a partial orientation W , i.e. an orientation of some of its edges, whether there exists a transitive orientation O of G with W ⊆ O.The notion of partial orientations and extensions extends to modular decompositions.We get a partial orientation of the quotient graphs of T from W such that exactly the edges that represent at least one edge in W are oriented and all edges in W that are represented by the same oriented edge µ 1 µ 2 , are directed from L(µ 1 ) to L(µ 2 ).
Lemma 2. Let T be the canonical modular decomposition of a comparability graph G and let W be a partial orientation of G that gives us a partial orientation P of the quotient graphs of T .Then W extends to a transitive orientation of G if and only if P extends to a transitive orientation of the quotient graphs of T .
Proof.Let O be a transitive orientation of G that extends W .Let µ 1 µ 2 be an oriented edge in P .Then µ 1 µ 2 represents an oriented edge uv in W . Then uv is an oriented edge in O and µ 1 µ 2 is in the transitive orientation T [G] of the quotient graphs of T we get from O. Hence, T [G] extends P .
Conversely, let T [G] be a transitive orientation of the quotient graphs of T that extends P .Let uv be an oriented edge in W . Then uv is represented by an oriented edge µ 1 µ 2 in P .
Then µ 1 µ 2 is an oriented edge in T [G] and uv is in the transitive orientation O of G we get from T [G].Hence,O extends W .
To solve OrientExt efficiently we confirm that the partial orientation actually gives us a partial orientation P of the quotient graphs of the canonical modular decomposition T .Otherwise we can reject.By Lemma 2 we now just need to check for each node µ of T whether P can be extended to G [µ].To this end, we use that µ is empty, complete or prime.Since transitive orientations of cliques are total orders and prime graphs have at most two transitive orientations, the existence of an extension can easily be decided in each case.Theorem 3. OrientExt can be solved in linear time.
Proof.Let W be the given partial orientation of a comparability graph G = (V, E).After the linear-time preprocessing of Lemma 1, we can compute the partial orientation P of the quotient graphs of T we get from W in linear time by determining rep(uv) for every edge uv ∈ W .If P does not exist, then there is an edge µ 1 µ 2 in a quotient graph that represents an edge e 1 ∈ W oriented from L(µ 1 ) to L(µ 2 ) and an edge e 2 ∈ W oriented from L(µ 2 ) to L(µ 1 ).Then W can not be extended to a transitive orientation of G since in any orientation represented by T the edges e 1 , e 2 are both oriented in the same direction between L(µ 1 ) and L(µ 2 ).Hence, we can reject in this case.
Otherwise, to solve OrientExt for G, it suffices to solve OrientExt for every quotient graph in the canonical modular decomposition T of G with the partial orientation from P by Lemma 2. Let µ be a node in T .We distinguish cases based on the type of µ.If µ is empty, nothing needs to be done.If µ is complete, the problem of extending the partial orientation of G[µ] is equivalent to the problem of finding a total order of the nodes of G[µ] that respects P .This can be done via topological sorting in linear time.If µ is prime, G[µ] has exactly two transitive orientations, where one is the reverse of the other.Therefore we check in linear time whether one of these orientations of G[µ] is an extension of the partial orientation of G [µ]. Otherwise, no transitive extension exists.
Since we can compute T in O(|V | + |E|) time, in total we can decide whether the partial orientation W is extendible in the same time.we get a corresponding transitive orientation of G by the extension of P and can also be computed in the same time.

Sunflower Orientations
The idea to solve SimOrient is to obtain for each input graph G i a restricted modular decomposition of the shared graph H that represents exactly those transitive orientations of H that can be extended to G i .The restricted modular decompositions can be expressed by constraints for the canonical modular decomposition of H.These constraints are then combined to represent all transitive orientations of H that can be extended to each input graph G i .With this the solution is straightforward.
Let H be a comparability graph.Then we define a restricted modular decomposition (T, D) of H to be a tuple where T is a modular decomposition of H where every node is labeled as complete, empty or prime, such that for every node µ labeled as complete or empty, H[µ] is complete or empty, respectively, and D is a function that assigns to each prime labeled node µ a transitive orientation D µ , called default orientation.In the following, when referring to the type of a node µ in a restricted modular decomposition, we mean the type that µ is labeled with.A transitive orientation of (T, D), is a transitive orientation of the quotient graphs of T where every prime node µ has orientation D µ or its reversal D −1 µ .Let to(T, D) denote the set of transitive orientations of H we get from transitive orientations of (T, D).We say (T, D) represents these transitive orientations.Note that for the canonical modular decomposition B of H we have to(T, D) ⊆ to(B).
Let G be a comparability graph with an induced subgraph H.A modular decomposition T of G gives us a restricted modular decomposition (T | H , D) of H as follows; see Figure 3.We obtain T | H from T by (i) removing all leaves that do not correspond to a vertex of H and then (ii) iteratively contracting all inner nodes of degree at most 2. With a bottom-up traversal we can compute T | H in time linear in the size of T .A node µ in T | H stems from lca T (L(µ)).Every node µ ∈ T | H that stems from a prime node µ ∈ T we label as prime and set D µ to a transitive orientation of G[µ ] restricted to the edges of H.The remaining nodes are labeled according to the type of their quotient graph.Note that

is empty, H[µ] and the corresponding transitive orientation are also empty. If G[µ ] is complete, then H[µ] is also complete and any transitive orientation of H[µ] can be extended to a transitive orientation of G[µ ]. If G[µ ] is prime, by construction H[µ]
is also labeled as prime with a default orientation D µ given by a transitive orientation

Thus T H [H] can be mapped to T and be extended to a transitive orientation T [G] of the quotient graphs of T . Then T [G] gives us a transitive orientation O G of G since T represents exactly the transitive orientations of G. Let O H be O G restricted to H. Then by construction O H equals the orientation of H we get from T H [H]. Thus T H [H] gives us a transitive orientation of H.
Consider the canonical modular decompositions T 1 , . . ., T r of the input graphs G 1 , . . ., G r , and let (T 1 | H , D 1 ), . . ., (T r | H , D r ) be the corresponding restricted modular decompositions.Then we are interested in the intersection to(G 1 , . . ., G r ) = r i=1 to(T i | H , D i ) since it contains all transitive orientations of H that can be extended to all input graphs.However, the trees T 1 | H , . . ., T r | H have different shapes, which makes it difficult to compute a representation of to(G 1 , . . ., G r ) directly.Instead, we describe to(T 1 | H , D 1 ), . . ., to(T r | H , D r ) (whose intersection is simple to compute) with constraints on the canonical modular decomposition B of H.
Let (T, D) be a restricted modular decomposition of H and let B be the canonical modular decomposition of H.We collect constraints on the orientations of individual nodes µ of B that are imposed by to(T, D).Afterwards we show that the established constraints are sufficient to describe to(T, D).If µ is empty, then H[µ] is empty and has a unique transitive orientation, which requires no constraints.The other types of µ are discussed in the following two sections.

Constraints for Prime Nodes
In this section we observe that prime nodes in B correspond to prime nodes in (T, D) and that the dependencies between their orientations can be described with 2-SAT formulas.Recall that the transitive orientation of a prime comparability graph is unique up to reversal.We consider each prime node µ ∈ B equipped with a transitive orientation D µ , also called a default orientation.All default orientations for B can be computed in linear time [31].

and for any edge uv with rep
Proof.We first show that every µ-set is also a µ -set.Assume there is a As a direct consequence of µ-sets being µ -sets, we also have for any edge uv with rep B (uv We express the choice of a transitive orientation for a prime node µ by a Boolean variable x µ that is true for the default orientation and false for the reversed orientation.
According to Lemma 6 we set ψ µ to be Note that for a prime node µ ∈ T there may exist more than one prime node µ in B such that µ = lca T (L(µ)), and we may hence have multiple prime nodes that are synchronized by these constraints.We describe these dependencies with the formula ψ = µ∈P (B) ψ µ .With the above meaning of variables, any choice of orientations for the prime nodes of B that can be induced by T necessarily satisfies ψ.With Lemma 1 we can compute ψ efficiently.µ and add the clause x µ ↔ x µ or x µ ↔ x µ , respectively.Doing this for every prime node in total takes time linear in the size of T .

Constraints for Complete Nodes
Next we consider the case where µ is complete.The edges represented in H[µ] may be represented by edges in more than one quotient graph in T , each of which can be complete or prime.Depending on the type of the involved quotient graphs in T we get new constraints for the orientation of H [µ].
Note that choosing a transitive orientation of H[µ] is equivalent to choosing a linear order of the vertices of H[µ].As we will see, each node ν of T that represents an edge of H[µ] imposes a consecutivity constraint on a subset of the vertices of H [µ]. Therefore, the possible orders can be represented by a PQ-tree that allows us to represent all permissible permutations of the elements of a set U in which certain subsets S ⊆ U appear consecutively.
PQ-trees were first introduced by Booth and Lueker [7,8].A PQ-tree T over a finite set U is a rooted tree whose leaves are the elements of U and whose internal nodes are labeled as Por Q-nodes.A P -node is depicted as a circle, a Q-node as a rectangle; see Figure 4. Two PQ-trees T and T are equivalent, if T can be transformed into T by arbitrarily permuting the children of arbitrarily many P -nodes and reversing the order of arbitrarily many Q-nodes; see Figure 4a.A transformation that transforms T into an equivalent tree T is called an equivalence transformation.The frontier fr(T ) of a PQ-tree T is the order of its leaves from left to right.The tree T represents the frontiers of all equivalent P Q-trees.The PQ-tree that does not have any nodes is called the null tree.
Let T 1 , T 2 be two PQ-trees over a set U .Their intersection T = T 1 ∩ T 2 is a PQ-tree that represents exactly the linear orders of U represented by both T 1 and T 2 .It can be computed in O(|U |) time [7].For every Q-node q in T 1 node q = lca T (L(q)) is also a Q-node.We say that q contains q forwards, if T 1 [q] can be transformed by an equivalence transformation that does not reverse q into a PQ-tree T such that fr(T [q]) contains fr(T [q ]); see Figure 4b.Else q contains q backwards.Similarly every Q-node in T 2 is contained in exactly one Q-node in T (either forwards or backwards).Haeupler et al. [21] showed that one can modify Booth's algorithm such that given two PQ-trees T 1 , T 2 it not only outputs T 1 ∩ T 2 but also for every Q-node in T 1 , T 2 which Q-node in T contains it and in which direction.Lemma 8. Let T 1 , . . ., T k be PQ-trees over a set U .Then we can compute their intersection T = k i=1 T i and determine for every Q-node q in T 1 , . . ., T k the Q-node in T that contains q and in which direction in O(k Proof.Let S 1 = T 1 and for every j ∈ {2, . . ., k} let S j := S j−1 ∩ T i .To compute T = S k we stepwise compute S j = S j−1 ∩ T j for every j.During the computation of T we construct a DAG D whose vertices are the Q-nodes of T 1 , . . ., T k and S 2 , . . ., S k .Initially D contains no edges.For every j we add a directed edge from every Q-node q in T j and S j−1 to the Q-node q in S j that contains q.We label the edge with 1 if q contains q forwards, and with -1 otherwise.By the result of Haeupler et al. this can be done in O(k • |U |) time [21].Note that by construction every vertex has at most one outgoing edge and for every Q-node q in T 1 , . . ., T k there is a unique path to the Q-node q in S k that contains it.The product of the edge labels along this path is 1 and -1 if q contains q forwards and backwards, respectively.
To determine for every Q-node q in T 1 , . . ., T k which Q-node in T contains it and in which direction, we start at the sinks in D and backward propagate for every vertex in D the information which unique sink q can be reached from it and what is the product of edge labels along the path to q .This needs O(k Let µ = lca T (L(µ)) for the rest of this section and let U ⊆ V be a maximal µ-set.We call a node of T active if it is either a leaf in U or if at least two of its subtrees contain leaves in U .Denote by A the set of active nodes in T and observe that A can be turned into a tree S µ by connecting each node ν ∈ A \ {µ } to its lowest active ancestor; see Figure 5.Let now B[H] be an orientation of the quotient graphs of B induced by an orientation T [G] ∈ to(T, D) and consider a node ν = µ of S µ .Let X = U ∩ L(ν ) and let Y = U \ L(ν ).Since U is a µ-set of a complete node, any pair of vertices in X × Y is adjacent.Moreover, for each y ∈ Y , the edges from y to X are all oriented towards X, or they are all oriented towards y, since every node of T that determines the orientation of such an edge contains all vertices of X in a single child.This implies that in the order of the µ-set given by the order of H[µ], the set L(ν ) is consecutive.Moreover, if ν is prime, its default orientation D ν induces a total order on the active children of ν that is fixed up to reversal.Hence we turn S µ into a PQ-tree by first turning all complete nodes into P-nodes and all prime nodes into Q-nodes with the children ordered according to the linear order determined by the default orientation which we call the initial order of the Q-node.Finally, we replace each leaf v ∈ U by the corresponding vertex rep µ (v) of H[µ]; see Figure 5.As argued above, the linear order of H[µ] is necessarily represented by S µ .
We show that tree S µ is independent from the choice of the maximal µ-set U .We use that any node of T has a laminar relation to the children of µ.Proof.Let ν be a non-leaf node in T that is active with regard to V 1 .Then there exist two vertices ) and let u 2 , v 2 be the vertices in We prove the following: ).Then we have u 2 ∈ L(ν ) and u 2 ∈ L(µ 1 ).By Lemma 9 we get u 1 ∈ L(µ 1 ) ⊆ L(ν ) ∩ L(µ), i.e., ν = ν 1 and similarly ν = ν 2 in contradiction to ν 1 = ν 2 .
For Statement iii note that u 1 v 1 and u 2 v 2 are indeed represented in ν by Statement ii and they are both represented by It follows that the active inner nodes are the same for U 1 , U 2 and after replacing the leaves with the children of µ we obtain the same trees.Statement iii then provides that the ordering of the children of Q-nodes is also the same and S 1 µ , S 2 µ are indeed the same PQ-tree.
By construction, each Q-node q of S µ stems from a prime node ν in T , and the orientation of T [ν ] determines the orientation of q, namely q is reversed if and only if T [ν ] is oriented as D −1 ν .Since a single prime node ν of T may give rise to Q-nodes in several PQ-trees S µ , we need to ensure that the orientations of these Q-nodes are either all consistent with the default orientation of T [ν ] or they are all consistent with its reversal.To model this, we introduce a Boolean variable x q for each Q-node q in one of the PQ-trees with the interpretation that x q = true if and only if q has its initial order.We require x q to be equal to the variable that orients the prime node corresponding to q.More precisely, for every prime node ν in T [µ ] that gives rise to q we add the constraint (x ν ↔ x q ) to χ µ , where the variable x ν is the variable that encodes the orientation of the prime node ν .We construct a Boolean formula by setting χ = µ∈K(B) χ µ .
Lemma 11.We can compute all PQ-trees S µ and the formula χ in O(n + m) time.
Proof.As a preprocessing we run a DFS on T starting at the root and store for every node ν its discovery-time ν.d, i.e., the timestamp when ν is first discovered, and its finishtime ν.f , i.e., the timestamp after all its neighbors have been examined.We also employ the preprocessing from Lemma 1.We construct all PQ-trees and χ with the following steps.1.Take a maximal µ-set U µ for every µ ∈ K(B). 2. For every µ ∈ K(B) compute the set of active nodes and for every active node compute its parent in S µ .3. For every µ ∈ K(B) determine for each inner node of S µ whether it is a P-or a Q-node.
If it is a Q-node, determine the linear order of its children, and construct the formula χ µ .
Step 1 can be done in O(n) time by Lemma 1.
For Step 2, note that each active node is a least common ancestor of two leaves in U µ .While it is easy to get all active nodes as least common ancestors, getting the edges of S µ requires more work.Observe that the DFS on T visits the nodes of S µ in the same order as a DFS on S µ .Consider S µ embedded such that the children of each node are ordered from left to right by their discovery-times.This also orders the leaves from left to right by their discovery-times.Let λ be an inner node of S µ .Let λ 1 , λ 2 be two neighboring children of λ with λ 1 to the left of λ 2 .Then λ is the least common ancestor of the rightmost leaf in L(λ 1 ) and the leftmost leaf in L(λ 2 ).Hence, each node of S µ is a least common ancestor for a consecutive pair of leaves.
We add for every node u in a set U µ a tuple (µ, u.d) to an initially empty list L. We then sort the tuples in L in linear time using radix sort [13].In the sorted list, for every µ ∈ K(B) all tuples (µ, u.d) are consecutive and the consecutive sublist is sorted by discovery time.
For µ ∈ K(B) let L µ be a list containing the vertices in U µ ordered by their discovery time which we get directly from the consecutive sublist of L containing the tuples corresponding to µ.For every pair u, v ∈ U µ adjacent in L µ we compute λ = lca T (u, v) using the lowestcommon-ancestor data structure for static trees by Harel and Tarjan [22] and insert λ into L µ between u and v.For a vertex u ∈ U µ its parent in S µ is the neighbor in L µ that has a lower position in T .Note that u is a descendent in T of all its neighbors in L µ .Hence if u has two neighbors in L µ one of them is a descendent of the other.Thus the parent of u in S µ is the neighbor with the higher discovery time.Now we remove all vertices in U µ and possible duplicates of the remaining nodes from L µ .Note that still every λ is a descendent in T of its neighbors in L µ .Hence we iteratively choose a node λ in L µ whose discovery time is higher than the discovery time of its neighbors, compute its parent in S µ by comparing the discovery times of its neighbors with each other and remove λ from L µ .
In Step 3, we turn each active node that stems from a complete node into a P-node and each active node that stems from a prime node into a Q-node.For a Q-node q that stems from a prime node ν, we determine the linear order of its children as follows.Take the set X of vertices of H[ν] that correspond to children of µ in S µ , determine the orientation of the complete graph on X induced by D ν and sort it topologically.In total this take O(n + m) time for all active nodes in all PQ-trees.Using the information computed up to this point, it is straightforward to output the formula χ.
Finally, we combine the constraints from the complete nodes with the constraints from the prime nodes by setting ϕ T = ψ ∧ χ.The formula ϕ T allows us to describe a restricted set of transitive orientations of G.We define S T = {S µ | µ ∈ K(B)}.The canonical modular decomposition (B, S T , ϕ T ) of H where every complete node is labeled with the corresponding PQ-tree together with ϕ T we call a constrained modular decomposition.
We say that a transitive orientation O of H induces a variable assignment satisfying ϕ T if it induces an assignments of the variables corresponding to prime nodes in B and Q-nodes such that ϕ T is satisfied for an appropriate assignment for the variables corresponding to prime nodes in T .Let to(B, S T , ϕ T ) denote the set containing all transitive orientations O ∈ to(B) where for every complete node µ ∈ B the order O ↓µ corresponds to a total order represented by S µ and that induces a variable assignment that satisfies ϕ T .

Correctness
We now show that to(B, S T , ϕ T ) = to(T, D).To this end we use that Lemma 5 allows to find for an edge uv that is represented in a prime node µ of B the prime node µ = lca T (L(µ)) of T where it is represented.This allows us to establish the identity of certain nodes.The following lemma does something similar for complete nodes.Assume that µ 1 is prime.Then by Lemma 5, ω is prime which is a contradiction to the assumption that ω is complete.Hence µ 1 must be complete but as B is the modular decomposition of H, no two adjacent nodes in B are complete.Thus µ is not an ancestor of ν and analogously we get that ν is not an ancestor of µ.
It remains to consider the case that ν = λ = µ.Let λ 1 be the child of λ such that L(µ) ⊆ L(λ 1 ) and let λ 2 be the child of λ such that L(ν) ⊆ L(λ 2 ).Again λ has to be complete since otherwise by Lemma 5 ω would be prime which is a contradiction.By Lemma 9 we have that L(λ 1 ) ∪ L(λ 2 ) ⊆ L(ω ).
Assume that λ 1 is prime.Then by Lemma 5, ω is prime which leads to a contradiction.Hence λ 1 must be complete but again as B is the modular decomposition of H, no two adjacent nodes in B are complete.Theorem 13.Let B be the canonical modular decomposition for a graph H and let T be a restricted modular decomposition for H. Then to(B, S T , ϕ T ) = to(T, D) and to(B, S T , ϕ T ) can be computed in time that is linear in the size of H.

Proof. Let O H ∈ to(T, D) and let B[H] be the orientation of the quotient graphs of B
inducing O H . Then we have already seen that it is necessary that every complete node µ in B is oriented according to a total order represented by S µ and that O H induces a variable assignment that satisfies ϕ T .Hence O H ∈ to(B, S T , ϕ T ). Conversely Note that if ω is prime, then the first case implies the second one.Let µ = lca B (u, v) and ν = lca B (w, x).We distinguish cases based on the types of µ and ν.Let µ = lca T (L(µ)), ν = lca T (L(ν)) and let B[H] be the orientation of the quotient graphs of B that induces O H . Without loss of generality, assume rep B (uv) ∈ D µ and rep B (wx) ∈ D ν .Case 1: µ and ν are both prime.By Lemma 5 we have that µ = ω = ν is prime.By construction, ϕ T enforces that uv, wx are either represented in D ω or in D −1 ω .Hence, this case does not occur.Case 2: µ is prime and ν is complete.By Lemma 5 we have that µ = ω is prime.Let U be a ν-set containing w and x.Since rep T (wx) ∈ H[ω ], node ω is active with respect to U .Hence the PQ-tree S ν contains a Q-node q that stems from ω .
By construction ϕ T contains the constraints (x ω ↔ x q ) and (x ω ↔ x µ ) but B[H] induces x µ = true, x q = false.Hence the variable assignment induced by B[H] does not satisfy ϕ T and thus O H / ∈ to(B, S T , ϕ T ).Case 3: µ is complete and ν is prime.Similar to Case 2. Case 4: µ, ν are both complete.Here we further distinguish two subcases depending on the type of ω .First assume that ω is prime.Let V 1 be a µ-set containing u, v and let V 2 be a ν-set containing w, x.Since rep T (uv) and rep T (wx) are edges in H[ω ], node ω is active with respect to both V 1 , V 2 .Hence S µ , S ν contain Q-nodes q 1 , q 2 stemming from ω .By construction ϕ T contains the constraints (x ω ↔ x q1 ) and (x ω ↔ x q2 ), but B[H] induces x q1 = true, x q2 = false.Hence the variable assignment induced by O H does not satisfy ϕ T and thus O H / ∈ to(B, S T , ϕ T ).It remains to consider the case that ω is complete.By Lemma 12 we have µ = ν.Since ω is not prime, we must have rep T (uv) = rep T (xw) by assumption.Let U be a µ-set.Since rep T (uv) = rep T (xw) ∈ H[ω ], node ω is active with respect to U and rep ω (u) = rep ω (x), rep ω (v) = rep ω (w).Hence S µ contains a P-node that stems from ω and demands a total order of the children of µ where rep µ (u), rep µ (x) are either both smaller than both rep µ (v), rep µ (w), or rep µ (u), rep µ (x) are both greater than both rep µ (v), rep µ (w).Since B[H] induces rep µ (u) < rep µ (v) but rep µ (x) > rep µ (w), H[µ] is not oriented according to a total order represented by S µ and thus O H / ∈ to(B, S T , ϕ T ).By Lemmas 7 and 11 the formula ϕ T = ψ ∧ χ and S T can be computed in linear time.
Let T be a modular decomposition of a graph G with an induced subgraph H. Let B be the canonical modular decomposition of H and let T | H be the restricted modular decomposition for H we get from T .From Lemma 4 and Theorem 13 we directly get the following corollary.

Corollary 14. The set to(B, S T | H , ϕ T | H ) contains exactly those transitive orientations of H that can be extended to a transitive orientation of G.
Let (B, S 1 , ϕ 1 ), . . ., (B, S r , ϕ r ) be constrained modular decompositions for H.
The intersection (B, S, ϕ) of (B, S 1 , ϕ 1 ), . . ., (B, S r , ϕ r ) is the constrained modular decomposition of H where every complete node µ is labeled with the PQ-tree S µ equipped with the 2-Sat-formula ϕ = ( r i=1 ϕ i ) ∧ ϕ where ϕ synchronizes the Q-nodes in the S µ 's with the Q-nodes in the S i µ 's as follows.Recall that for every Q-node q in a tree S i µ there exists a unique Q-node q in S µ that contains q; either forward or backward.For every i ∈ {1, . . ., r}, every µ ∈ K(B) and every Q-node q in S i µ we determine the Q-node q in S µ that contains q and add the clause (x q ↔ x q ) if q has its forward orientation in q and (x q ↔ x q ) otherwise.

Proof.
Let O H ∈ r i=1 to(B, S i , ϕ i ) and let B[H] be the orientation of the quotient graphs of B that induces O H . Then for every i ∈ {1, . . ., r} the variable assignment induced by O H satisfies ϕ i and for every complete node µ in B, the total order O H↓µ is represented by S i µ , hence it is also represented by S µ .Let i ∈ {1, . . ., r} and let q be a Q-node in S i µ and let q be the Q-node in S µ containing q. Without loss of generality assume q contains q forwards and B[H] induces x q = true with respect to (B, S i , ϕ i ).Then B[H] induces x q = true with respect to (B, S, ϕ) and ϕ contains the clause (x q ↔ x q ) for x q .Hence ϕ is satisfied in any extension of an assignment of variables corresponding to Q-nodes in S µ , S induces assignments of the variables corresponding to the prime nodes in B and to the Q-nodes in S.These induced variable assignments can be extended to a solution of ϕ.Let i ∈ {1, . . ., r} and let q be a Q-node in S i µ such that q is the Q-node in S µ containing q. Without loss of generality assume q contains q forwards and B[H] induces x q = true with respect to (B, S, ϕ).Then ϕ contains the clause (x q ↔ x q ) and hence x q = true in any solution of ϕ that is an extension of an assignment of variables corresponding to Q-nodes in S µ induced by B[H].Since for every complete node µ in B, the total order O H↓µ is also represented by S i µ , B[H] also induces assignments of the variables corresponding to Q-nodes in S i µ .Since q contains q forwards B[H] must induce x q = true as well with respect to (B, S i , ϕ i ).Hence the variable assignment induced by B[H] and S i µ satisfies ϕ i and thus  If S does not contain the null tree and ϕ has a solution, we get simultaneous transitive orientations of G 1 , . . ., G r in linear time by proceeding as follows.We orient every complete quotient graph of B according to a total order induced by the corresponding PQ-tree where every Q-node is oriented according to the solution of ϕ.For a prime quotient graph H[µ] we choose D µ if in the chosen solution of ϕ we have x µ = true and D −1 µ otherwise.Together, all these orientations of quotient graphs of B induce a transitive orientation on H and by applying the linear-time algorithm from Section 3 to solve OrientExt we can extend it to a transitive orientation of G i for every i ∈ {1, . . ., r}.

Permutation Graphs
We give algorithms that solve RepExt(Perm) and SimRep (Perm) in linear time using modular decomposition and the results from Sections 3 and 4. To do so, we need the following definitions and observations.Let G = (V, E) be a permutation graph and let D be a representation of G.We denote the upper horizontal line of D by L 1 and the lower line by L 2 .
Proposition 17 ([32]).Let G = (V, E) be a permutation graph and let T be the canonical modular decomposition of G. Then for every representation D of G and for every µ ∈ T , the vertices in L(µ) appear consecutively along both L 1 and L 2 .
Let G be a permutation graph and let T be the canonical modular decomposition of G.For every permutation diagram we store two doubly-linked lists containing the order of labels along the two horizontal lines, respectively.Then the replacements described above take linear time in total.
Conversely, assume that a permutation diagram D for G is given as two double linked lists l 1 (D) and l 2 (D) containing the order of labels along the two horizontal lines, respectively.We traverse T bottom-up and consider all leaves as initially visited.Let l 1 and l 2 be two double linked lists and initially l 1 = l 1 (D) and l 2 = l 2 (D).When visiting a non-leaf node µ ∈ T we compute the two double linked lists l 1 (µ) and l 2 (µ) representing its permutation diagram as follows.As an invariant we claim that at any time l 1 and l 2 are sublists of l 1 (D) and l 2 (D) and represent the permutation diagram of a subgraph of G. Further l 1 and l 2 contain for every visited child ν of an unvisited node exactly one entry corresponding to a leaf in L(ν).Clearly the invariant holds at the beginning of the traversal.Now assume we visit a non-leaf node µ and the invariant holds.Let l 1 (µ) and l 2 (µ) be the sublist of l 1 and l 2 consisting of all entries corresponding to leaves in L(µ), respectively.The invariant together with Proposition 17 gives us that when visiting a node µ, l 1 (µ) and l 2 (µ) are consecutive sublists of l 1 and l 2 .To compute l 1 (µ) and l 2 (µ) we start at an arbitrary child ν of µ in l 1 and l 2 and search for the right and left end of l 1 (µ) and l 2 (µ), i.e. on both sides we search for the first entry that does not correspond to a child of µ.Finally we remove all list entries corresponding to a leaf in L(µ) that is not in L(ν) in l 1 and l 2 .After this step the invariant still holds.By definition of the quotient graphs and since they contain exactly one representative per child of µ, l 1 (µ) and l 2 (µ) represent the permutation diagram for G [µ].In total these computations take linear time since for every µ ∈ T the number of visited list entries is in O(deg(µ)).

Extending Partial Representations
For solving RepExt(Perm) efficiently, we exploit that a given partial representation D of a permutation graph G is extendible if and only if, for every prime node µ in the canonical modular decomposition of G, the partial representation of G[µ] induced by D is extendible.Since G[µ] has only a constant number of representations this can be checked in linear time.
In the following, let G = (V, E) be a permutation graph and let D be a corresponding partial representation of a subgraph H = (V , E ) of G. Furthermore, let T be the canonical modular decomposition for G and let µ be a node in T .Let U µ ⊆ V be a (not necessarily maximal) µ-set containing as many vertices in V as possible.Let D µ be the partial representation of G[µ] we get from D by removing all line segments corresponding to vertices not in U µ and replacing every label u by the label rep µ (u).Let U µ be a maximal µ-set with U µ ⊆ U µ .

Lemma 19. Let D be a partial representation of G. Then D can be extended to a representation D of G if and only if for every inner node µ in T , D µ can be extended to a representation D µ of G[µ].
Proof.Assume that D can be extended to a representation D of G. Then for every inner node µ in T , D restricted to U µ where every label u is replaced by the label rep µ (u) is an extension of Conversely assume that for every inner node µ in T , D µ can be extended to a representation D µ of G [µ].By Theorem 18 we get a permutation diagram D representing G from the D µ s.We show that D extends D .
Let L 1 and L 2 denote the upper and the bottom line of D, respectively.Now for every pair u, v ∈ V let µ = lca T (u, v).By Proposition 17 L(µ) appears consecutively along L 1 and L 2 .Hence independently of the choice of U µ , in D µ rep(u) and rep(v) appear in the same order as the labels corresponding to u and v in D along both horizontal lines.Thus D restricted to V coincides with D .

Theorem 20. RepExt(Perm) can be solved in linear time.
Proof.Let G = (V, E) be a permutation graph with n vertices and m edges and let D be a permutation diagram of an induced subgraph H = (V , E ) of G.We compute the canonical modular decomposition T of G in O(n + m) time [31].By Lemma 19, it suffices to check whether D µ can be extended to a representation of G[µ] for every µ ∈ T .
If G[µ] is empty or complete, we can easily extend and G[µ] has exactly two transitive orientations where one is the reverse of the other.Hence there exist only four permutation diagrams representing G[µ] [20].Note that given an arbitrary permutation diagram D µ for G[µ], we get the other three representations by either reversing the order along both horizontal lines, switching L 1 and L 2 , or applying both.Hence we can compute all four representations in linear time and check whether one of them contains D µ .
In the positive case, by Theorem 18 we get a representation D of G that extends D from the representations of the quotient graphs in linear time.

Simultaneous Representations
Recall that a graph G is a permutation graph if and only if G is a comparability and a co-comparability graph.To solve SimRep (Perm) efficiently, we build on the following characterization due to Jampani and Lubiw.Proposition 21 ([24]).Sunflower permutation graphs are simultaneous permutation graphs if and only if they are simultaneous comparability graphs and simultaneous co-comparability graphs.
Let G 1 , . . ., G r be sunflower permutation graphs.It follows from Proposition 21 that we can solve SimRep (Perm) by applying the algorithm to solve SimOrient from Section 4 to G 1 , . . ., G r and their complements G 1 , . . ., G r .Since the algorithm from Section 4 needs time linear in the size of the input graphs and G may have a quadratic number of edges, this approach takes quadratic time in total.This already improves the cubic runtime of the algorithm presented by Jampani and Lubiw [24].
We show that it is possible to use the algorithm from Section 4 to solve also SimOrient for co-comparability graphs and thus SimRep (Perm) in linear time.Let G be a permutation graph with induced subgraph H. Recall that a graph G and its complement have the same canonical modular decomposition, they only differ in the type of the nodes.For a node µ with G[µ] prime also G[µ] is prime; if G[µ] is complete or empty, G[µ] is empty or complete, respectively [17].
Let B be the canonical modular decomposition of H and let T be the canonical modular decomposition of G restricted to H.The goal is to compute constrained modular decompositions (B, S 1 , ϕ 1 ), . . ., (B, S r , ϕ r ) such that for every i ∈ {1, . . ., r} (B, S i , ϕ i ) contains exactly those transitive orientations of H that can be extended to a transitive orientation of G i , and (B, S, ϕ) with to(B, S, ϕ) = r i=1 to(B, S i , ϕ i ).In linear time we cannot explicitly compute G and the corresponding quotient graphs.Hence we cannot store a default orientation for the prime quotient graphs H [µ]. We can, however, compute a default permutation diagram D µ representing H[µ] from its default orientation O µ in linear time [31].We apply the algorithm from Section 4. The 2-Sat-formula ψ describing the dependencies between the orientations of the prime nodes can be computed in O(|V (H)| + |E(H)|) time since when it is required to check whether an oriented edge uv is contained in the default orientation of a prime quotient graph H[µ], we do this in constant time by checking for the non-edge uv in H[L(µ)] whether rep µ (u) < µ rep µ (v).We can determine one non-edge for each prime quotient graph of B in O(|E(H)|) time in total.Note that one non-edge per prime quotient graph suffices to answer the queries.Further we have to compute the PQ-trees for the complete nodes in T and χ.Note that the only step in the computation of the PQ-trees that takes potentially quadratic time for H is the computation of the order of the children for the Q-nodes.But since every prime node is labeled with a default representation, we can compute the PQ- Proof.Let ϕ be the 2-Sat formula we get for H and let ϕ be the formula from H. Further let S and S be the set of intersected PQ-trees we get for G 1 , . . ., G r and G 1 , . . ., G r , respectively.Then G 1 , . . ., G r are simultaneous permutation graphs if and only if ϕ and ϕ are satisfiable and neither S nor S contain the null tree.This can be checked in linear time.
In the positive case we proceed as follows.More precisely, Step 2 works as follows.For complete or empty nodes µ we construct the representation by choosing a linear order of their children represented by the corresponding PQ-tree where every Q-node is oriented according to a solution of ϕ or ϕ, for the upper line.If H[µ] is empty, we choose the same order for the bottom line, if H[µ] is complete, the bottom line is labeled with the reversed order.
For a prime quotient graph µ we distinguish four cases.Let x µ be the variable encoding the orientation of H[µ] and let y µ be the variable encoding the orientation of H[µ].If x µ = true, y µ = true we choose the default representation D µ , if x µ = true, y µ = false we reverse the orders along both horizontal lines of D µ , if x µ = false, y µ = true we switch the orders along the horizontal lines of D µ and if x µ = false, y µ = false we reverse the orders along both horizontal lines of D µ and switch them.

Circular permutation graphs
In this section we give efficient algorithms for solving RepExt (CPerm) and SimRep (CPerm) based on the linear time algorithms for solving RepExt (Perm) and SimRep (Perm) and the switch operation.Let G = (V, E) be a circular permutation graph.Switching a vertex v in G, i.e., connecting it to all vertices it was not adjacent to in G and removing all edges to its former neighbors, gives us the graph The graph we obtain by switching all neighbors of a vertex v we denote by G N (v) .
Let C be a circular permutation diagram representing a permutation graph G = (V, E) and let v ∈ V be a vertex in G.The chord v in C can be switched to the chord v , if v has the same endpoints as v, but intersects exactly the chords v does not intersect in C. Hence, this modified circular permutation diagram C is a representation of G v [35].Here it suffices to know that there exists a v that v can be switched to, hence, we use the term switching chord v, without further specifying v .

Extending Partial Representations
In this section we show that RepExt(CPerm) can be solved via a linear-time Turing reduction to RepExt(Perm) using the switch operation.Case 2: there exists no vertex u in G that has a neighbor in every connected component of H but is not adjacent to every vertex in H. Then we remove all vertices from G that are adjacent to every other vertex in H.If G is empty afterwards, we can choose an arbitrary gap between two adjacent blocks and open C p there.Else we iteratively merge for each remaining vertex u all connected components of H that contain a vertex adjacent to u.Since G is connected we end up with either one or two blocks which gives us only one or two positions to open C p , respectively.We check whether one of them leads to an extendible permutation diagram.

The Simultaneous Representation Problem
In this section we show that SimRep (CPerm) can be solved via a quadratic-time Turing reduction to SimRep (Perm) using the switch operation.Here we need to switch the neighborhood of a vertex v shared by all input graphs.Hence in contrast to the reduction in Section 6.1, where we switched the neighborhood of a vertex of minimum degree, the graph G N (v) may have quadratic size.Proof.Recall that G 1 , G 2 , . . ., G r are indeed permutation graphs [35].Let G 1 , G 2 , . . ., G r be simultaneous circular permutation graphs.Then there exist circular permutation diagrams C 1 , C 2 , . . ., C r such that for every 1 ≤ i ≤ r, C i represents G i and all C i s coincide restricted to the vertices of H.We get a circular permutation diagram C i representing G i by switching all chords corresponding to neighbors of vertex v in C i .Since the order of the vertices along the inner and outer circle is not affected by the switch operation, we know that all C i s coincide restricted to the vertices of H. Recall that after switching all neighbors of chord v in a circular permutation diagram, no chord intersects v any more and hence we obtain a permutation diagram D i representing G i by opening C i along the chord v. Then the D i s also coincide on the vertices of H and hence G 1 , G 2 , . . ., G r are simultaneous permutation graphs.
Conversely let G 1 , G 2 , . . ., G r be simultaneous permutation graphs.Then there exist permutation diagrams D 1 , D 2 , . . ., D r such that for every 1 ∈ {1, . . ., r}, D i represents G i and all D i s coincide on the vertices of H. Recall that we can transform every linear permutation diagram D i into a circular permutation diagram C i representing G i .Note that the C i s also coincide on the vertices of H. Now we obtain a circular permutation diagram C i representing G i by switching all chords that correspond to vertices adjacent to v. The C i s still coincide on the vertices of H since the switch operation does not change the order of the vertices along the outer or the inner circle of a circular permutation diagram and chords corresponding to vertices in H are either switched in every C i or in none of them.Proof.Let G 1 , . . ., G r be sunflower circular permutation graphs.Let v be a vertex in H and let G i be the graph we obtain by switching all neighbors of vertex v in G i for i ∈ {1, . . ., r}.By Lemma 24 to solve SimRep(CPerm) for G 1 , G 2 , . . ., G r it suffices to solve SimRep(Perm) for G 1 , G 2 , . . ., G r .Computing G 1 , G 2 , . . ., G r takes quadratic time.In Section 5.2 we have seen that SimRep(perm) can be solved in linear time for sunflower permutation graphs G 1 , . . ., G r , hence in total we need quadratic time to solve SimRep (CPerm).If G 1 , G 2 , . . ., G r are simultaneous circular permutation graphs we get corresponding simultaneous representations by transforming simultaneous linear permutation diagrams representing G 1 , G 2 , . . ., G r into circular permutation diagrams and switching all chords corresponding to a neighbor of vertex v in H.This takes quadratic time in total.

Simultaneous Orientations and Representations for General Comparability Permutation Graphs
We show that the simultaneous orientation problem for comparability graphs and the simultaneous representation problem for permutation graphs are NP-complete in the nonsunflower case.
Theorem 26.SimOrient for k comparability graphs where k is part of the input is NP-complete.

Proof. Clearly the problem is in NP.
To show the NP-hardness, we give a reduction from the known NP-complete problem TotalOrdering [33], which is defined as follows.Given a finite set S and a finite set T of triples of elements in S, decide whether there exists a total ordering < of S such that for all triples (x, y, z) ∈ T either x < y < z or x > y > z.Let H T be an instance of TotalOrdering with s = |S| and t = |T |.We number the triples in T with 1, . . ., t and denote the ith triple by (x i , y i , z i ).We construct an instance H S of SimOrient, consisting of undirected graphs G 0 , . . ., G t as follows.
G 0 := (S, E 0 ) is the complete graph with one vertex for each element in S. G i := (V i , E i ) for 1 ≤ i ≤ t is the graph with vertex set V i = {x i , y i , z i , a i , b i }, where a i , b i / ∈ S are new vertices, and edges E i = {x i a i , x i y i , x i z i , y i z i , z i b i }; see Figure 8.
For every 1 ≤ i ≤ t, the graph G i has exactly two transitive orientations, namely { − − → x i a i , − − → x i y i , − − → x i z i , − − → y i z i , − − → b i z i } and its reversal.We now have to show that H T has a solution if and only if G 0 , . . ., G t are simultaneous comparability graphs.
First, assume that G 0 , . . ., G t are simultaneous comparability graphs.Hence there exist orientations T 0 , . . ., T t such that for every 0 ≤ i ≤ t, T i is an orientation of G i and for every j, k ∈ {0, . . .t} every edge in E j ∩ E k is oriented in the same way in both T j and T k .Then the orientation of the complete graph G 0 implies a total order on the elements of T , where u < v if and only if the edge uv is oriented from u to v. By construction, there are only two valid transitive orientations for G i .The one given above implies x i < y i < z i and for the reverse orientation we get z i < y i < x i .Hence the received total order satisfies that for every triple (x, y, z) ∈ T we have either x < y < z or x > y > z.
Conversely, assume that H T has a solution.Then there exists a total order < such that for all triples (x, y, z) ∈ T either x < y < z or x > y > z holds.We get a transitive orientation T i of G i for 1 ≤ i ≤ t by orienting all edges between the vertices x i , y i and z i towards the greater element according to the order <.If x i is the smallest element of the triple, then we choose − − → x i a i and − − → b i z i , else z i is the smallest element and we choose − − → a i x i and − − → z i b i .Finally, we orient the edges in G 0 also towards the greater element according to <.This gives us orientations T 0 , . . ., T t of G 0 , . . ., G t with the property that for every j, k ∈ {0, . . .t} every edge in E j ∩ E k is oriented in the same way in both T j and T k .Hence G 0 , . . ., G t are simultaneous comparability graphs.
Hence the instance H T of TotalOrdering has a solution if and only if the instance H S is a yes-instance of SimOrient.Since H S can be constructed from H T in polynomial time, it follows that SimOrient is NP-complete.
Theorem 27.SimRep(Perm) for k permutation graphs where k is not fixed is NP-complete.
Proof.Clearly the problem is in NP.
To show the NP-hardness, we use the same reduction as in the proof of Theorem 26.Let H T be the corresponding instance of TotalOrdering.Note that G 0 , . . ., G t are permutation graphs and thus G 0 , . . ., G t are comparability graphs..We already know that H T has a solution if and only if G 0 , . . ., G t are simultaneous comparability graphs.Hence it remains to show that G 0 , . . ., G t are simultaneous co-comparability graphs if H T has a solution.Note that E(G 0 ) = ∅ and for every 1 ≤ i ≤ t for every edge uv ∈ E(G i ) at least one of the endpoints u and v is in {a i , b i }.Hence, G 0 , . . ., G t pairwise do not share any edges and thus they are also simultaneous comparability graphs.

Conclusion
We showed that the orientation extension problem and the simultaneous orientation problem for sunflower comparability graphs can be solved in linear time using the concept of modular decompositions.Further we were able to use these algorithms to solve the partial representation problem for permutation and circular permutation graphs and the simultaneous representation problem for sunflower permutation graphs also in linear time.For the simultaneous representation problem for circular permutation graphs we gave a quadratictime algorithm.The non-sunflower case of the simultaneous orientation problem and the simultaneous representation problem turned out to be NP-complete.
It remains an open problem whether the simultaneous representation problem for sunflower circular permutation graphs can be solved in subquadratic time.Furthermore it would be interesting to examine whether the concept of modular decomposition is also applicable to solve the partial representation and the simultaneous representation problem for further graph classes, e.g.trapezoid graphs.There may also be other related problems that can be solved for comparability, permutation and circular permutation graphs with the concept of modular decompositions.

Figure 1
Figure 1 (a) a graph G with (b) a permutation diagram and (c) a circular permutation diagram.

3 )
Given an edge e of G, determine rep(e), the quotient graph that contains rep(e), and which endpoint of rep(e) corresponds to which endpoint of e.Additionally, given a node µ in T one can find a maximal µ-set U in O(|U |) time.
we can compute one of them in O(|V µ | + |E µ |) time.Hence the time to compute the canonical modular decomposition in which every prime node is labeled with a corresponding transitive orientation is O(|V | + |E|).

Figure 3
Figure 3 (a) A graph G with an induced subgraph H (blue square vertices).(b) A modular decomposition T of G with a transitive orientation.(c) The restricted modular decomposition (T |H , D) of H derived from the transitive orientation in (b).Note that H[µ] is a clique but µ is labeled prime.

Lemma 6 .
and thus prime.Since U is also a µ -set and the subgraph of H[µ ] induced by the vertices representing U is isomorphic to H[U ], µ is neither empty, nor complete and thus prime.For a modular decomposition T of H with a node λ and O ∈ to(T ) let O ↓λ denote the orientation of the quotient graph H[λ] we get from O. Note that for a transitive orientation D λ of H[λ] and a λ-set U each orientation O ∈ to(T ) with O ↓λ = D λ gives us the same orientation on H[U ].We say that D λ induces this orientation on H[U ].Let µ ∈ B be prime, let µ = lca T (L(µ)) and let U be a maximal µ-set (and by Lemma 5 a µ -set).We set D δ µ = D µ if D µ , D µ induce the same transitive orientation on the prime graph H[U ] and we set D δ µ = D −1 µ if the induced orientations are the reversal of each other.Note that D δ µ does not depend on the choice of U .From the definition of D δ µ and the observation that O ↓µ , O ↓µ are both determined by O restricted to H[U ] we directly get the following lemma.For O ∈ to(T, D) we have
|U |) time since the D has O(k • |U |) vertices and edges.

Figure 6 Lemma 9 .
Figure 6 (a) A subtree of B with root µ.(b) A subtree of T with root ν .

rTheorem 16 .
i=1 n i , m = r i=1 m i .Since every S i µ for a node µ ∈ K(B) has one leaf per child of µ, by Lemma 8 their intersection S µ can be computed in O(r • | deg(µ)|) time.Hence in total we need µ∈K(B) O(r • | deg(µ)|) = O(n) time to compute S. For every i, by Theorem 13, we can compute ϕ i in O(n i + m i ) time.By Lemma 8 we can also find out in O(n) time which Q-nodes are merged and in which direction and hence the construction of ϕ in total takes O(n + m) time.Now consider the case where (B, S 1 , ϕ 1 ), . . ., (B, S r , ϕ r ) are the constrained modular decompositions we get from the restricted modular decompositions T 1 | H , . . ., T r | H .By Lemma 12 and Theorem 13 we have to(B, S, ϕ) = r i=1 to(B, S i , ϕ i ) = r i=1 to(T i , D) and by Lemma 4 G 1 , . . ., G r are simultaneous comparability graphs if and only if ϕ is satisfiable and S does not contain the null tree.SimOrient can be solved in linear time.
We use Proposition 17 to show that for node µ ∈ T we can compute a permutation diagram of G[L(µ)] by iteratively replacing a line segment representing a descendent ν of µ in T by a permutation diagram of G[ν].Theorem 18.Let G be a permutation graph and let T be the canonical modular decomposition of G.There is a bijection φ between the permutation diagrams of G and the choice of a permutation diagram D µ for each quotient graph µ ∈ T .Both φ and φ −1 can be computed in O(n) time.Proof.To compute a permutation diagram of G from {D µ | µ ∈ T } we traverse T bottom-up and compute for every µ ∈ T a permutation diagram representing G[L(µ)] as follows.For every child ν of µ replace the line segment representing ν in D µ by the permutation diagram of G[L(ν)].

Theorem 22 .
trees and χ in O(|V (H)|) time instead of O(|V (H)|) + |E(H)|) time, since we get the order of the children of a Q-node directly from the corresponding permutation diagram.SimRep (Perm) can be solved in linear time.

Figure 7 Theorem 23 .
Figure 7The circular permutation representation C of a graph with four connected components.The red line segments mark the positions where C can be opened.

Figure 8
Figure 8 The (permutation) graph Gi corresponding to the i − th triple (xi, yi, zi) of a Total-Ordering instance with corresponding permutation diagram.
H contains two directed edges uv, wx with rep T (uv) and rep T (wx) in the same quotient graph H[ω ], such that rep T (uv) = rep T (xw), or ω is prime and rep T , let O H ∈ to(B, S T , ϕ T ) and assume O H / ∈ to(T, D).Then O H is either not represented by T or does not induce D. I.e., O Hence O H induces a variable assignment that satisfies ϕ and thus O H ∈ to(B, S, ϕ).Conversely let O H ∈ to(B, S, ϕ) and let B[H] be the orientation of the quotient graphs of B that induces O H . Then for every complete node µ ∈ B, the total order O H↓µ is represented by S and thus by S i µ for i ∈ {1, . . ., r}.Further B[H] We solve SimOrient as follows.1. Compute the canonical modular decomposition T i for every G i and the canonical modular decomposition B of H in O(n + m) time by McConnell and Spinrad [31].2. Compute T i | H for every i in O(n) time in total.3. Compute (B, S i , ϕ i ) for every i, in O(n + m) time in total by Theorem 13. 4. Compute (B, S, ϕ) in linear time by Lemma 12. 5. Check whether S contains the null tree and whether ϕ is satisfiable in linear time.We execute Step 5 as follows.For i ∈ {1, . . ., r}, ϕ i contains one variable and one constraint per prime node in B, one variable per prime node in T i | H and one variable and one constraint per Q-node in S i µ .Since S i µ has O(n i ) nodes, it contains O(n i ) Q-nodes.Hence in total every ϕ i contains O(n i ) variables and clauses.Note that ϕ contains one clause per Q-node in the PQ-trees in S. Hence ϕ contains O(n) clauses and variables and thus the 2-SAT formula ϕ can be solved in O(n) time by Aspvall et al. [3].

1 .
For every quotient graph in B compute the permutation diagram induced by the solutions of ϕ and ϕ. 2. Compute a permutation diagram D H representing H from the representations of the quotient graphs (see Theorem 18). 3.For every input graph G i use the algorithm from Section 5.1 to extend D H to a representation of G i .

Lemma 24 .
Let G 1 , G 2 , . . ., G r be sunflower circular permutation graphs sharing an induced subgraph H. Let v be a vertex in H and let G i be the graph we obtain by switching all neighbors of vertex v in G i for i ∈ {1, . . ., r}.Then G 1 , G 2 , . . ., G r are simultaneous circular permutation graphs if and only if G 1 , G 2 , . . ., G r are simultaneous permutation graphs.