Let denote an edge-weighted bipartite graph, where is the bipartition of the entire vertex set and is the edge set. Denoting by and , we let , , and . We abbreviate into for simplicity. The edge weight is given by a function . A subset of edges is called a matching if no two edges in share an endpoint in common. Denoted by , the weight of a matching is defined as the sum of edge weights over , i.e., .
A -layered drawing [2, 17, 19] of a bipartite graph is a 2D drawing of such that and are put on two horizontal lines as distinct points from left to right, respectively, and that every edge is drawn as a straight line segment between the endpoints. Two edges and make a crossing or intersect if either ( and ) or ( and ) holds.
In our research, we study the problem of computing a maximum weighted (max-weighted for short) matching under a constraint such that only a small number of edge crossings are admitted. The constraint we take up here is that each matching edge may intersect with at most other matching edges, where is a non-negative constant.
We formulate the problem in a more general setting. For , we call a crossing pair if and make a crossing. Let denote the set of all crossing pairs in . For input, we accept a subset as well as and , where is the set of crossing pairs that are admitted to make crossings. Let us call an admissible set and a crossing pair in an admissible pair. A matching is called at-most--crossings-per-edge (-CPE) if each edge in makes at most crossings along with other edges in and every crossing pair that appears in belongs to .
We formalize the max-weighted -CPE matching problem (MW--CPEMP) as follows.
For example, when , we are asked to compute a max-weighted -CPE matching such that any crossing pair may appear. When or , the problem asks for a max-weighted non-crossing matching since no crossing pair is admitted.
In the present paper, we propose polynomial time algorithms for the MW--CPEMP with . Our approach reduces the MW--CPEMP to what we call the non-contact trapezoid selection problem (NTSP). We then solve the reduced NTSP problem by an algorithm named SelectTrape, which is an extension of the Malucelli et al.’s -time algorithm for the MW-0-CPEMP . The time complexities of the proposed algorithms are for and for respectively, where .
Plant chronobiologists would like to compare gene expression dynamics at the individual level (i.e., macro level) with the single cell level (i.e., micro level) along the same time axis. However, there is a technically hard issue. Conventional microarray or RNA-sequencing can easily measure individual gene expression patterns in actual time-series but have limited spatial resolutions. On the other hand, single-cell transcriptome techniques have ultimate spatial resolution of gene expression analysis, but most techniques are requiring destruction of cells to perform single cell transcriptome and thus actual time-series analysis is impossible. Thus, to provide an analytic tool to achieve higher spatiotemporal resolution was required.
As an alternative, single cell analysis often uses pseudo time-series reconstruction for revealing cell-state transition (e.g., [16, 23]). Pseudo time reconstruction is a process that orders cells transcriptome on a hypothetical time axis, along which they show continuous changes in the transcriptome. However, ordinal scale-based pseudo time-series will not provide any time information so that it is impossible to analyze circadian rhythm, for example, in a single cell resolution.
We have hypothesized that timing of significant gene expression peak on the pseudo time-series is comparable to that on the actual time-series. In our recent work 
, we formulated the problem of estimating the actual time of cell expressions as the MW-0-CPEMP. We considered a 2-layered drawing of a complete bipartite graphsuch that is the set of individual expression records that are sorted in the actual-time order, and is the set of cell expression records that are sorted in a hypothetical order. We weighted each edge
by a heuristic method that evaluates howand are likely to match. Solving the MW-0-CPEMP on , we estimated the actual time of a gene expression by the time of the individual expression to which is matched. We used the non-crossing constraint because we would like to preserve the vertex orders.
We observed that the model can be a useful tool for actual-time estimation, compared with conventional actual-time estimation methods. In pursuit of alternative models, we study the MW--CPEMP for a constant .
2.2 Related Work
and in natural language processing.
Knauer et al.  studied the problem of finding a subgraph that has few edge crossings; given a graph (not necessarily bipartite) and its geometric drawing (i.e., every vertex is specified by a 2D point, all edges are drawn as straight line segments, and no two edges overlap or intersect at a vertex), we are asked to find a subgraph of a certain class that makes the minimum number of edge crossings. They showed that, for spanning trees, - paths, cycles, matchings of a fixed size, and 1- or 2-factors, it is NP-hard to approximate the minimum number of edge crossings within a factor of for any , where denotes the number of edge crossings in the given graph. They also presented fixed-parameter algorithms to decide whether there is a non-crossing subgraph of one of the above graph classes, where is used as the parameter.
The non-crossing (or crossing-free) constraint has been considered for some problems of finding an “optimal” subgraph. It is Malucelli et al.  who first studied the algorithmic aspect of the MW-0-CPEMP explicitly. For the edge-unweighted case, they provided a polynomial-time algorithm that runs in time or in time, where denotes the cardinality of a maximum 0-CPE matching. They also extended the algorithm to the edge-weighted case, which yields an time algorithm. A bipartite graph is convex if, for every , implies for all . For the MW-0-CPEMP in edge-unweighted convex bipartite graphs, Chen et al.  presented an algorithm whose running time is . Carlsson et al.  considered the Euclidean non-crossing bipartite matching problem, where each vertex is represented by a 2D point. The objective is to find a non-crossing perfect matching whose longest edge is minimized. They showed that the problem is NP-hard in general, but that it is polynomially-solvable in some special cases. More recently, Altinel et al.  showed that the minimum cost non-crossing flow problem on a layered network is NP-hard. Ruangwises and Itoh  studied the stable marriage problem under the non-crossing constraint, showing that there exists a weakly stable non-crossing matching for any instance.
The conflict pair constraint (or negative disjunctive constraint) is a generalization of the non-crossing constraint. Represented by a conflict graph , this constraint prohibits a solution from including two edges such that . The minimum cost perfect matching problem with conflict pair constraints is strong NP-hard for a general graph even if the conflict graph is a collection of single edges  and is NP-hard even for that consists of 4-cycles ; it turns out that the problem is NP-hard for a bipartite graph. For this type of constraint, there are also studies on the transportation problem [20, 21], the minimum spanning tree problem [7, 25, 15], and the max-flow problem .
3 Non-contact Trapezoid Selection Problem
To solve the MW--CPEMP, we reduce the problem to what we call the non-contact trapezoid selection problem (NTSP). In this section, we define the NTSP and propose an efficient algorithm for it. The algorithm is an extension of the Malucelli et al.’s algorithm  for the MW-0-CPEMP.
3.1 Problem Description
Suppose two distinct horizontal lines on the 2D plane. Let and denote vertex sets. We put on the upper line from left to right, and on the lower line from left to right. We are given a collection of weighted trapezoids such that each is given its weight, denoted by , and its two upper corners are among , whereas its two lower corners are among . We denote by (resp., ) the index (resp., ) of the upper-left corner (resp., upper-right corner ). Similarly, we denote by (resp., ) the index (resp., ) of the lower-left corner (resp., lower-right corner ). We admit to be a triangle or a line segment. Then and hold.
Given , the NTSP asks for a max-weighted subcollection such that any do not contact each other. Specifically, for any with and , it should hold that and .
3.2 Partial Order Based Algorithm
We can solve the NTSP by using the notion of partial order. Let us introduce a binary relation on ; For , we write if and . One easily sees that is a (or an irreflexive) partial order on , and thus is a partially ordered set (poset). We say that and are comparable if either or holds. For a subcollection , the poset (or ) is called a chain if every are comparable. Obviously is a feasible solution of the NTSP iff it is a chain.
We represent the poset by a directed acyclic graph (DAG). We denote the DAG by , where is the dummy node and is the arc set such that
For an arc , we define the distance to be . Any feasible solution of the NTSP is represented by a path from . Then we can solve the NTSP by solving the longest path problem on . The time complexity of this algorithm is because we can construct and solve the longest path problem in time .
3.3 An Efficient Algorithm SelectTrape
We propose a faster algorithm whose time complexity is . The proposed algorithm is based on the Malucelli et al.’s algorithm  for the MW-0-CPEMP. The MW-0-CPEMP is regarded as a special case of the NTSP such that every trapezoid is a line segment, that is, and . We extend the Malucelli et al.’s algorithm based on this observation.
For two integers with , let us denote and . We define and . Similarly, for integers with , we define a subset and . We say that a trapezoid is contained in if all corners are contained in the vertex subset, that is, and .
For , we denote by the max-weight of a feasible solution that has as the rightmost trapezoid (i.e., no in the solution satisfies ). For , we denote by the max-weight of a feasible solution such that the trapezoids are contained in and the lower-right corner of the rightmost trapezoid is exactly . For convenience, we let for all . The following lemmas are obvious by the definitions.
Suppose that is given. For , we have
Suppose that is given. For , we have
In Algorithm 1, we show an algorithm SelectTrape that computes the optimal weight of a given NTSP instance. The algorithm repeats the outer for-loop for . We do not store for all , but only for the current . It is stored as . When every is a line segment (i.e., and ), the algorithm works exactly in the same way as the Malucelli et al.’s algorithm.
Given an instance of the NTSP, the algorithm SelectTrape in Algorithm 1 computes the optimal weight in time and in space, where .
Proof: We show that holds at the beginning of the outer for-loop with respect to (i.e., line 1). When , we have by line 1. In line 1, we see that is computed correctly for with , due to (by induction) and Lemma 1. The second inner for-loop (i.e., line 1 to 1) computes the maximum among and for all with , and substitutes the maximum for , which is by Lemma 2. Upon completion of the algorithm, we have , which is the optimal value.
We analyze the computational complexity. Each trapezoid is searched as in the first inner for-loop exactly once, and as in the second inner for-loop exactly once. We can access with in line 1 (and with in line 1) in time by executing the bucket sort on beforehand. We use priority search tree  to store for , by which we can take the maximum in line 1 in time. We see that the algorithm runs in time. We use space to store for and for .
Using the algorithm, we can construct an optimal solution as follows.
For , let denote a max-weighted feasible solution such that all trapezoids in are contained in and that the lower-right corner of the rightmost one, say , is (i.e., ). We compute such of for every and maintain it as . The can be obtained as follows. We initialize for all . In line 1, if holds for the current , then we update .
For , let denote a max-weighted feasible solution such that is the rightmost trapezoid, and denote the trapezoid that is to the immediate left of in . We maintain the index as . To obtain , we first initialize for all and update in line 1, where is a maximizer of .
Let denote a maximizer of . Then is the rightmost trapezoid in the optimal solution. Setting and , while , we repeat , and . The obtained is the optimal solution. The procedure takes extra time.
4 Algorithm for the MW--Cpemp
In this section, we reduce the MW--CPEMP to the NTSP, which yields polynomial-time algorithms for the cases of and 2. Throughout this section, we assume that an instance of the MW--CPEMP is given for a non-negative constant . We also assume that is expressed by a list of crossing pairs.
Before proceeding, let us mention that the problem is solvable in -time as follows, where and is introduced to ignore polynomial factors; For each , let . In other words, is the set of edges that appear in . We check whether is a -CPE matching, which can be done in polynomial time. If it is the case, we compute a max-weighted non-crossing matching, say , on the subgraph that is obtained by removing and the extreme points from . The can be computed in polynomial time by using the Malucelli et al’s algorithm . The max-weighted -CPE matching over is an optimal solution.
For , we define to be the smallest index among the vertices in . For convenience, we let be zero when . That is,
Similarly, we define to be the largest index among the vertices in , and for convenience, it is set to if . That is,
Observe that, when , and represent the indices of the leftmost and rightmost vertices in , respectively. We define and in the analogous way.
For an edge subset , we define to be the set of extreme points of edges in . For simplicity, We write by . The notations , and are analogous. When is a singleton, that is, for some edge , we write as . In this case, it holds that and . We write an inequality as . Using this notation, and intersect if ( and ) or ( and ).
Recall that denotes the set of all possible crossing pairs in . Observe that each is a matching that consists of two intersecting edges. We may write in
as an ordered pairwhen we assume (and thus ). For a matching , we define to be a set of crossing pairs that appear in , that is,
A matching is at-most--crossings-per-edge (-CPE) if holds and each appears in at most crossing pairs in . Hence, is 0-CPE iff .
Let denote the family of all matchings in . We regard any as a trapezoid that has with as the upper-left corner, with as the upper-right corner, with as the lower-left corner, and with as the lower-right corner, and that has the weight . Then is a poset, where is the partial order on a trapezoid collection that we introduced in Section 3.2.
For a -layered bipartite graph , let . For any , exactly one of the following holds:
and are comparable.
Proof: When , (ii) holds. Suppose that . If and intersect, then we have . Otherwise, either or should hold as they do not share endpoints in common.
We introduce an auxiliary graph, which we denote by . We call an edge in the underlying graph a node when we use it in the context of . For , we denote by the subgraph induced by . Let denote the family of connected components in .
For a -layered bipartite graph , let . Then is a chain.
Proof: We show that any are comparable. The and are node sets of connected components of . For any and , and are not adjacent. Then holds. By Lemma 3, and are comparable. We assume that without loss of generality. Suppose that there is such that . Since is connected, there is a path between and . The path should contain an edge that intersects with in . Then , which contradicts that and are not adjacent in . We see that holds for any and and thus holds.
Let denote the family of all -CPE matchings. For a -CPE matching , it holds that and the degree of any node in is at most . We call connected if is connected. By Lemma 4, any is partitioned into connected -CPE matchings.
If we are given a family of all connected -CPE matchings (which are regarded as trapezoids), then we can find a max-weighted -CPE matching by solving the corresponding NTSP. The time complexity of this algorithm is by Theorem 1, where denotes the time for constructing . Then, if and are polynomially bounded, the total running time of the algorithm is also polynomially bounded.
Let us consider how to construct . For , the degree of any node in is at most . Then, when , we have , that is, the collection of isolated nodes in . Then holds. When , we have , and thus holds. For , the following theorems are immediate.
Theorem 2 (Malucelli et al. )
Given an instance of the MW--CPEMP, we can find a max-weighted -CPE matching in time and in space.
Given an instance of the MW--CPEMP, we can find a max-weighted -CPE matching in time and in space.
4.3 Trapezoid Collection for
For a connected 2-CPE matching , the auxiliary graph is an isolated point, an edge, a cycle or a path, and should hold. The next lemma tells that, when it is a cycle, the length (which is ) is at most four. We call a cycle an -cycle if the length is .
For a -layered bipartite graph and an admissible set , let be a -CPE matching. If is a cycle, then is at most four.
Proof: Each edge in intersects with exactly two other edges in . Hence . Let . Without loss of generality, we suppose that holds for all , that and are two edges that intersect with , and that holds.
As shown in Figure 1 (a), if and intersect, then we see that any of intersects with two others. Since is a cycle, holds. Otherwise (i.e., if and do not intersect), as shown in Figure 1 (b), we have and . Since is a cycle, the edge intersects with another edge in , say . From the definition of , we have . Since and should not intersect, holds. Since and intersect, holds. We see that intersects with and , and intersects with and . Any of intersects with two others, and thus we have .
|(a) 3-cycle||(b) 4-cycle|
For a -layered bipartite graph and an admissible set , we can enumerate all - and -cycles in time and in space.
Proof: First, we construct an intersection matrix such that each row/column corresponds to an edge, and that each entry takes 1 (resp., 0) if the corresponding edge pair belongs to (resp., does not belong to ). We can construct in time and store it in space.
We can enumerate all 4-cycles in time as follows; for each , let and , where we assume without loss of generality. We check whether is a matching such that and . If yes, then is a 4-cycle (Figure 1 (b)). The check can be done in time since whether or not can be identified in time by using . Enumeration of 3-cycles is analogous.
There may exist an exponentially large number of paths in . However, for our purpose, it is sufficient to take into account only paths; Let be a 2-CPE matching such that is a path. There are two nodes whose degrees are one. This means that and appear in exactly one admissible pair in . Suppose that holds without loss of generality. We call with (resp., ) the leftmost (resp., rightmost) admissible pair of . For , we call a 2-CPE matching an -path if is a path and and are the leftmost and rightmost admissible pairs of , respectively. Among all -paths, we have only to take a max-weighted one into account because all -paths form the same trapezoid whose corners are , , , and , where , , , and . We define the size of an -path to be , that is, the number of edges in the matching . In Figure 2 (a) and (b), we show a 2-CPE matching that is an -path for and . The size of is eight. We also show the path in the auxiliary graph in Figure 3.
|(a) Upper -path||(b) Lower -path|
For , we denote by the max-weight of an -path. We also denote by (resp., ) the max-weight of an
-path such that the size is odd (resp., even). We let, , and be when no corresponding path exists. Clearly we have
If , then the path size is two and holds. If , then the path size is three and holds. If , then the path size is no less than four.
A max-weighted even-sized -path.
We study how to obtain a max-weighted even-sized -path for given . We design an algorithm that computes and constructs the path. This strategy is then extended to the odd-size case.
For , let and . We say that an ordered pair is a link if one of the followings holds:
, , , and .