2. Description of the Algorithm for Case II
We list the stages of this algorithm, which are then explained in sequence and in detail below, in this section (see also
Table 1).
Stage 0: Transform initial given graphs a and b into the new graph, denoted by a + b below.
Stage 1.: Cut out conventional edges in a + b.
Stage 2.0: Solve the integer linear programming problem which outputs the set of disjoint elements (each of them consisting of pairs, triples, or quadruples of chains of the current graph) with the largest aggregate quality.
Stage 2.1: For each element in this set, perform the interaction between its chains; the interaction is uniquely determined by the element and combines the chains of the element into a single chain.
Stage 3: Circularize chains of sizes strictly larger than 0 into cycles, and then break all cycles into many cycles of size 2; then, remove all singular vertices and loops.
Now, we pass to a detailed description of each stage.
Stage 0: An initial pair of graphs
a and
b is transformed in linear time into a new («breakpoint») graph
a + b such that the original problem is equivalent to the problem of reducing
a + b to the simplest form, referred to as final. A
final form is a graph consisting of cycles of length 2 (one edge of each cycle is labeled by
a, and the other, by
b) and isolated conventional vertices; the definition of «conventional» is given below. The proof of the equivalence of these two problems literally repeats the proof of Corollary 5 in [
7]; that proof used the equality of costs of DCJ operations only, which is assumed in Theorem 1. In [
7], there was also given a linear time algorithm that transforms a solution of the second problem into a solution of the first (and vice versa).
The definition of the graph
a + b is given in [
7]; in other variants, it was known from earlier works, for instance, from [
8,
9]. We recall the definition from [
7], which describes vertices and edges of
a + b. Vertices in
a + b are all endpoints of edges that occur in both
a and
b (they are denoted by
ni, where
n is the edge name,
i = 1 for a tail of an edge, and
i = 2 for its head) and also vertices uniquely corresponding to every maximal connected segment of edges («block») in either
a\
b or
b\
a, which we label by
a or
b, respectively. Vertices of the first type are referred to as
conventional, and those of the second type are referred to as
singular. Edges in
a + b connect vertices whenever the latter are joined in
a or in
b or if an extremity of a block is joined with a vertex in
a or in
b; edges are labeled by
a or
b, respectively. Edges of the first type are said to be
conventional, and those of the second type are said to be
singular. If a singular endpoint in
a + b is of degree 1, then both the edge and the endpoint itself are said to be
hanging.
An operation
o’ over
a + b is defined through an operation
o over
a by commutativity:
o’(
a + b) =
o(
a) +
b. Thus, over a breakpoint graph, the five operations listed below are allowed, which are shown in Figure 5 in [
2]. In fact, the number of operations is six, since the fifth one, removal of a singular vertex, divides into removal of an
a-singular vertex, which corresponds to deleting a block in
a, and removal of a
b-singular vertex, which is inverse to inserting a block in
b.
Double intermerging (DM): deletion of two edges with the same label and joining the four thus formed endpoints by two new edges with this label. If the operation involves a loop, then its vertex is regarded as having two endpoints. If two adjacent singular vertices are formed, then the edge connecting them is deleted and they are merged into a single vertex.
Sesquialteral intermerging (SM): deletion of an edge and adding an edge with the same label connecting one of the thus formed free ends with a free end of an edge with an alternative label, or with a hanging or singular isolated vertex with the same label (with possible merging of adjacent singular vertices).
Single merging (OM): adding an a-edge between free vertices such that each of them is either a conventional vertex incident to a b-edge or an isolated vertex, a-hanging or a-isolated, with possible merging of adjacent singular vertices. A similar definition is given with b instead of a.
Cut (Cut): deletion of any edge.
The above-listed operations are referred to as DCJ (or sometimes standard) operations. A supplementary operation is removal (Rem) of a singular vertex. Namely, if it is of degree 2, it is removed and the edges incident to it are joined into an edge with the same label; if it is hanging, it is removed together with the edge incident to it; if it isolated or has a loop, the vertex and the loop are removed.
Each standard operation is assigned with its original cost w; removal of an a-singular vertex has original cost wa = wd, and removal of a b-singular vertex has original cost wb = wi.
An inclusion-maximal connected fragment of conventional edges is called a segment; depending on its length, it can be either even or odd.
The size of a component in a + b is the number of conventional edges plus half the number of singular nonhanging edges in it. For conventional isolated vertices and loops, the size is defined to be 0, and, for singular isolated vertices, the size is defined to be −1.
Our algorithm successively generates graphs G starting from a + b; all these G are of the form c + d for their initial graphs c and d; all these G together form a sequence that begins with a + b and ends with a graph of a final form. Now, we pass to the description of the Algorithm, which consists of three consecutive stages.
Stage 1: From all components other than cycles of size 2,
cut out conventional edges, i.e., apply a DM to a pair of edges adjacent to the edge to be cut out, or similarly apply an SM or OM if one or two of the adjacent edges do not exist. Such a derived operation is called
cutting out (conventional edges) (
Figure 1).
A chain of an odd (even) size is called
odd (
even); 0 is an even number, and −1 is odd. The definition of a
type of a chain plays a crucial role. First, assume that a chain
does not contain conventional edges. Then, 1
a is an odd chain with one hanging
b-edge; 2
a* is an odd chain with two hanging
b-edges; 2
a’ is a
b-singular isolated vertex; 2
a denotes type 2
a* or 2
a’. Type 3
a* is an odd chain without hanging edges, with two extremal
a-edges, and having a
b-singular vertex; 3
a’ is a chain
aa; 3
a denotes type 3
a* or 3
a’. Type 1
a* is an even chain with one hanging
a-edge that has a
b-singular vertex; 1
a’ is a hanging
a-edge; 1
a denotes type 1
a* or 1
a’. Similar definitions are given with
b instead of
a. Type 2* is an even chain with two hanging edges nonincident to each other; 2
’ is two hanging edges incident to a common conventional vertex; 2 denotes type 2* or 2
’. Type 3 is an even chain without hanging edges but having singular vertices; 0 is a chain without singular vertices. The chain types were presented in Figure 6 in [
2]. The type of a chain
with conventional edges is defined as the type of a chain obtained by cutting them out; it does not depend on the order of cuttings (see Lemma 6 in [
7]).
A hanging extremity of a chain not of type 0 is an extremity with an adjacent hanging edge or odd segment. After cutting out this segment, a hanging edge appears. A chain 2a (or 2b, 3a, 3b) is a chain of type 2a’ (respectively, 2b’, 3a’, 3b’) if and only if it contains b-singular vertices only (a-singular only, a-singular only, b-singular only). A chain of type 2 is a chain of type 2’ if and only if it contains a conventional vertex with only a-singular vertices on one side and only b-singular vertices on the other.
An
interaction in
G is a chain of operations successively applied to
G. In
Section 3, we introduce a key notion of
P(
s), the
quality of an interaction
s. We also give there a convenient formula for computing it; see Equation (1b), which is consistent with Equation (1a). A term equality 1
a + 1
b = 1
*b means that an interaction is applied to two chains of types 1
a and 1
b and outputs a chain of type 1
*b. The same applies for other term equalities that are defined with the help of type designations, the + sign, and parentheses. Each interaction below corresponds to its term equality, which can be regarded as a designation (name) of this interaction. In square brackets, we give the interaction quality.
Stage 2: 2-interactions are SM applied to two different chains with the following term equalities (a cut chain is always given the first; on the right-hand side, we do not present conventional isolated vertices): 1a + 1b = 1*b [wa + wb], 3a* + 2b* = 1a [wb], 3a* + 2b’ = 1a [wa], 3a’ + 2b* = 1a [wa], 3a’ + 2b’ = 1’a [wa], 3b + 2a = 1b [wb], 3 + 2 = 1*b [wa + wb − 1], (1a + 2b*) + 3=1*b [wa + 2wb − 1], (1a + 2b’) + 3 = 1*b [2wa + wb − 1], (1b + 2a) + 3=1*b [wa + 2wb − 1], (3a* + 1b) + 2 = 1*b [wa + 2wb − 1], (3a’ + 1b) + 2=1*b [2wa + wb − 1], (3b + 1a) + 2=1*b [wa + 2wb − 1], 1a + 2=2a* [wa + wb − 1], 1b + 2 = 2b* [wa + wb − 1], 3 + 1a = 3a* [wa + wb − 1], 3 + 1b = 3b* [wa + wb − 1], (3b + 1a) + (1a + 2b*) = 1*b [wa + 3wb − 1], (3b + 1a) + (1a + 2b’) = 1*b [2wa + 2wb − 1], (3a* + 1b) + (1b + 2a) = 1*b [wa + 3wb − 1], (3a’ + 1b) + (1b + 2a) = 1*b [2wa + 2wb − 1], 1a + (1a + 2b*) = 2a* [wa + 2wb − 1], 1a + (1a + 2b’) = 2a* [2wa + wb − 1], 1b + (1b + 2a) = 2b* [wa + 2wb − 1], (3b + 1a) + 1a = 3a* [wa + 2wb − 1], (3a* + 1b) + 1b = 3b* [wa + 2wb − 1], (3a’ + 1b) + 1b = 3b* [2wa + wb − 1], 1a + 2b* = 2 [wb], 1a + 2b’ = 2 [wa], 1b + 2a = 2 [wb], 3a* + 1b = 3 [wb], 3a’ + 1b = 3 [wa], 3b + 1a = 3 [wb], 3 + ((3 + 2b*) + 2a) = 1*b [wa + 3wb − 2], 3 + ((3 + 2b’) + 2a) = 1*b [2wa + 2wb − 2], (3a* + (3b + 2)) + 2 = 1*b [wa + 3wb − 2], (3a’ + (3b + 2)) + 2 = 1*b [2wa + 2wb − 2], (3a* + 2) + 2 = 2a* [wa + 2wb − 2], (3a’ + 2) + 2 = 2a* [2wa + wb − 2], (3b + 2) + 2 = 2b* [wa + 2wb − 2], 3 + (3 + 2a) = 3a* [wa + 2wb − 2], 3 + (3 + 2b*) = 3b* [wa + 2wb − 2], 3 + (3 + 2b’) = 3b* [2wa + wb − 2], (3 + 2b*) + 2a = 2* [2wb − 1], (3 + 2b’) + 2a = 2* [wa + wb − 1], 3a* + (3b + 2) = 3 [2wb − 1], 3a’ + (3b + 2) = 3 [wa + wb − 1], and OM with the equalities 1a + 1a = 3a* [wa + wb − 1], 1b + 1b = 3b* [wa + wb − 1].
Two additional
2-interactions are SM with the equalities 3
a* + 3
b = 3 [
wb −
wa] and 2
a + 2
b* = 2
*+ 1
’a [
wb −
wa] (see
Figure 2). Lemma 1 below demonstrates that the
quality of a 2-interaction depends only on types of chains on the left-hand side of a term equality.
Unlike the algorithms in [
2,
7], where interactions are performed in the same order as they are listed, now, the order of interactions is described in the following nontrivial way:
Notice 1. Denote the graph obtained after Stage 1 by G’. For each of the above-listed 2-interactions s, we call its element an unordered pair, triple, or quadruple (depending on the number of arguments in the composition of s, which we also denote by s) of chains in G’ that have the same types as the types of arguments in s. The pairs, triples, and quadruples of such types themselves will be referred to as a polytypes; a type of a chain in a polytype may occur several times. For instance, for the interaction f = (1a + 1b = 1*b), its element is any pair of chains of types 1a and 1b, and its polytype is the pair {1a,1b} of these types. To each element, precisely one 2-interaction corresponds, which is specified by its polytype. The quality of an element is defined to be the quality of this 2-interaction. By a domain, we call any set of elements (usually, from different interactions) where the elements are disjoint. The quality of a domain M is the aggregate quality of its elements. A domain with the maximum quality is called maximal.
Thus, Stage 2 consists of applying, simultaneously and independently of each other, 2-interactions corresponding to some maximal domain M for G’ to elements of M.
Let us find a maximal domain M for G’. To this end, we use integer linear programming (ILP) with at most 51 variables and at most 10 nontrivial (i.e., not of the form x ≥ 0) constraints. Namely, to each 2-interaction s we assign a nonnegative integer-valued variable xs whose value must be equal to the number of elements of this 2-interaction in the sought-for domain M. This condition on the vector {xs} is expressed by the following linear relations: for every type t of a chain occurring in G’ and corresponding to an argument of one of the 2-interactions, we impose the constraint , where cts is the number of occurrences t in the arguments of any 2-interaction s (cts can be 0, 1, or 2), and lt is the number of chains of type t in G’. Maximize the target function , where P(s) is the quality of a 2-interaction s and the summation is over all 2-interactions. A solution to this ILP problem gives a maximal domain M.
Define
autonomous reduction as the following sequence of operations: cut out all conventional edges. Circularize chains of sizes strictly larger than 0 into cycles using an OM or SM operation (after SM, there remains one extremal vertex or one extremal edge) (see
Figure 3a). When circularizing a chain of type 2*, choose a variant with joining two
b-singular vertices; after circularizing a chain of type 3
a* or 3
b*, cut out the arising conventional edge. Then, break all cycles into cycles of size 2 using a DM operation, which cuts out a cycle of size 2 with an
a-singular vertex from a cycle (see
Figure 3b). Remove all singular vertices and loops. The
autonomous cost A(
G) of a graph
G is defined as the total cost of the sequence of operations in the autonomous reduction of
G (see Lemma 1 below).
Stage 3: Perform autonomous reduction of the remaining components to a final form.
End of the Algorithm description.
It follows from the proof presented in
Section 3 that, for the graph
G’’ obtained after Stage 2, there exists no interaction with a strictly positive quality, which is by no means evident a priori.
Below, we consider the case wa ≤ wb, since the description of the Algorithm (up to interchanging a and b) and the subsequent proof do not depend on which of the removal costs is smaller, wa for an a-singular vertex or wb for a b-singular vertex.
3. Proof of Theorem 1 (Case II)
First, we make an obvious remark concerning the
linear runtime of the Algorithm. For Stage 0, this follows from the fact that
a + b is constructed by one-time examination of all components in
a and
b. Stage 1 requires one-time examination of all components in
a + b. The number of interactions executed at Stage 2 is linear, since each of them reduces the number of chains in the corresponding graph, and each interaction is executed in constant time. Similarly, the number of operations executed at Stage 3 is linear, since each of them reduces the number of singular vertices or the number of chains. Linear runtime of solving the ILP problem at Stage 2 follows from [
10], where it was shown that the time required for solving an ILP problem with a fixed number of variables and constraints is polynomial in the logarithm of the maximum absolute value of a coefficient of the problem. In our problem, this coefficient is not greater than the problem size.
The rest of this section is devoted to the proof of additive exactness of the Algorithm. If, when executing a standard operation, singular vertices are joined, the operation is said to be special; otherwise, it is nonspecial; a removal operation is special by definition.
Clearly, we may assume that w = 1. For a graph G, we use the following notation: d is the total size of all components in it (we call it the size of G), f is the number of odd chains, c is the number of cycles (excluding loops), B is the number of singular vertices, S is the sum of integral parts of halved segment lengths plus the number of extremal (on a chain) odd segments minus the number of cyclic segments, D is the number of chains of types 1a, 1b, 3a, 3b, and 3, and Kb is the number of components containing a b-singular vertex.
Lemma 1. Let wa and wb be the removal costs for singular a- and b-vertices, wa ≤
wb, and let all other operations have cost 1.
Then, the autonomous cost A(
G)
of a graph G is Proof. Denote the right-hand side of this equality by A’(G). Let us check the equality for each component of the graph separately and then sum up the obtained equalities. Denote by Ib the indicator function which is 1 if G contains a b-singular vertex and 0 otherwise. □
(1) For a conventional isolated vertex, the equality is trivial, since A’(G) is equal to wa for an a-loop and wb for a b-loop. For a singular isolated vertex (odd chain), we have d = −1, f = 1, and B = 1; for a b-isolated vertex, Kb = 1 and the other quantities are zero. A’(G) is equal to wa for an a-isolated vertex and wb for a b-isolated vertex, as well as A(G).
(2) For a cycle without singular edges (and hence without singular vertices), we have d > 0 and d even, c = 1, S = 0.5d – 1; the other quantities are zero, and A’(G) = 0.5d − 1. Autonomous reduction includes only cutting out conventional edges by a DM operation. Each cutting reduces a large cycle by 2 edges; the last cycle requires no operation. Therefore, 0.5d − 1 DM operations are executed.
(3) For a cycle with singular edges, we have d > 0 and d even, B > 0, S ≥ 0, c = 1, Kb = Ib, and the other quantities are zero; A’(G) = (1 − wa)(0.5d − 1) + wa(B + S) + (wb − wa)Ib. When cutting out conventional edges, the size d of a graph does not change. Each cutting out a conventional edge or a cycle of size 2 reduces the size of a large cycle by 2; the last cycle requires no operation. Thus, 0.5d − 1 DM operations are executed. The number of nonspecial operations among them is S, since every segment of length l for an even l requires 0.5l nonspecial cuttings, and, for an odd l, l − 0.5(l − 1) nonspecial cuttings and one special cutting. Therefore, the number of Rem operations is B − (0.5d − 1 − S) (the number of b-removals among them is Ib), and A(G) = 0.5d − 1 + wa(B − (0.5d − 1 − S) − Ib) + wbIb = A’(G).
(4) For an odd chain without singular edges, we have d > 0 and d odd, f = 1, S = 0.5(d + 1) (such a chain is an extremal odd segment), and the other quantities are zero. Its autonomous reduction requires only DM operations, i.e., cutting out conventional edges, and, at the end, when a conventional edge without adjacent conventional edges remains, one OM. Each DM separates a final ab cycle from a current chain, and the chain length (equal to its size) reduces by 2. Therefore, 0.5(d + 1) operations are required in total, which equals A(G), since the cost of a standard operation is 1. For A’(G), we obtain the same quantity.
(5) For an odd chain with singular edges, we have d > 0 and d odd, f = 1, B > 0, D is either 0 or 1, S ≥ 0, Kb = Ib, and the other quantities are zero. Cutting out conventional edges requires S nonspecial DM or SM operations. After the cuttings, a chain either has an odd size strictly greater than 0 or turns into a singular isolated vertex. In the first case, the chain is circularized into a cycle by a special OM (if D = 0) or by a nonspecial OM (if D = 1), after which the obtained cycle is finalized by special operations (this cycle may contain only one conventional edge, namely, the one by which the chain was circularized into a cycle). Every standard operation in autonomous reduction increases the number of cycles in the graph by 1, an OM increases the graph size by 1, and a DM or SM does not change it. Thus, finally, the graph size becomes d + 1, and it contains 0.5(d + 1) cycles of size 2. In the second case, the graph size remains to be d, and it also contains 0.5(d + 1) cycles of size 2 formed when making cuttings (a singular isolated vertex is of size −1 and D = 0). Since the initial graph had no cycles, 0.5(d + 1) standard operations are made in total, S + D among them being nonspecial. Therefore, the number of Rem operations is B − (0.5d + 0.5 − S − D) (the number of b-removals among them is Ib), and A(G) = 0.5(d + 1) + wa(B − (0.5d + 0.5 − S − D) − Ib) + wbIb = A’(G).
(6) For an even chain without singular edges, we have d > 0 and d even, S = 0.5d, and the other quantities are zero. Its autonomous reduction requires only DM operations, cuttings of conventional edges. Each of them separates an ab cycle from the current chain; therefore, the length of the chain, equal to its size, reduces by 2. Therefore, in total, A(G) = 0.5d operations are executed. For A’(G), we obtain the same quantity.
(7) For an even chain with singular edges, we have d > 0 and d even, B > 0, D is either 0 or 1, S ≥ 0, Kb = Ib, and the other quantities are zero. Cutting out conventional edges requires S nonspecial DM or SM operations. After a cutting, the chain has an even size either strictly greater than 0 or equal to 0. In the first case, the chain is circularized by a special SM (if D = 0) or a nonspecial SM (if D = 1), after which the obtained cycle is finalized by special operations. Every standard operation in the autonomous reduction increases the number of cycles in the graph by 1, and a DM or SM does not change the size of the graph. Therefore, finally, the graph size remains to be d, and it contains 0.5d cycles of size 2. The same happens in the second case. Since the initial graph had no cycles, in total, 0.5d standard operations are applied, S + D among them being nonspecial. Thus, the number of Rem operations is B − (0.5d − S − D) (the number of b-removals among them is Ib), and A(G) = 0.5d + wa(B − (0.5d − S − D) − Ib) + wbIb = A’(G).
Recall that an interaction in
G is a sequence
s of operations successively applied to
G. The
quality P(
s)
of an interaction s is defined as
where
s(
G) is the graph obtained after applying the composition
s to
G, and
c(
s) is the
total cost of operations in
s. The quality shows what total cost can be saved by using the interaction
s as against the autonomous reduction of
G, i.e., without using
s. By examining all 2-interactions (see the example below), we check that
P(
G,
s) is determined by the
polytype of the 2-interaction, consisting of the types of its arguments or, equivalently, by the corresponding term equality. Accordingly, the quality of an element α (for the substitution in
s) is determined by its polytype, which coincides with the polytype of
s itself.
In this way, we computed the qualities of 2-interactions that were presented above, after each of them, in square brackets. For instance, let us find the quality of the interaction 1
a + 1
b = 1
b* (
Figure 4),
c(
s) = 1, and the operation is special (generally, all operations of Stage 2 are special). This 2-interaction does not change the values of
d,
c, and
S, reduces
B and
Kb by 1, and reduces
D and
f by 2. Hence,
P(
s) =
wa + wb.
Let E be any reducing sequence for a graph G, which is arbitrarily divided into connected fragments of operations; we call them interactions here and denote by s. Denote by T(R,E) the total cost of operations in a reducing subsequence which starts in E with some intermediate graph R and continues to a final form. Denote by P(R,E) the aggregate quality of all interactions in E starting from R, where P(s) is formally defined in Equation (1b).
Lemma 2. For any graph G, we have T(G,E) = A(G) − P(G,E).
Proof. It suffices to check A(R) − T(R,E) = P(R,E). This is proven by induction on the number of interactions from the end of the sequence E. If R is of a final form, all the three quantities are zero. Let A(R’) − T(R’,E) = P(R’,E) for a subsequence starting with a graph R’ next to R. Let s be an interaction taking R into R’, c(s) be the total cost of its operations, and P(s) be its quality, defined formally by (1’). Then P(R,E) = P(R’,E) + P(s), T(R,E) = T(R’,E) + c(s), and P(s) = A(R) − A(R’) − c(s). Hence, A(R) − T(R,E) = A(R’) + c(s) + P(s) − T(R’,E) − c(s) = A(R’) − T(R’,E) + P(s) = P(R’,E) + P(s) = P(R,E). □
If E is a sequence of operations constructed by the Algorithm, then it contains 2-interactions, and all other operations (i.e., those from Stages 1 and 3) by Equation (1b) have formal quality 0 (for uniformity, these operations can be viewed as formal interactions).
Notice 2. Thus, P(G) is the aggregate quality of 2-interactions (equivalently, interactions in all stages of the algorithm), equal (!) to the quality of the maximal domain on chains in the initial a + b (equivalently, on chains after all cuttings of Stage 1).
By Lemmas 1 and 2,
is the
total cost of operations of the algorithm on a graph
G. Denote the first and second term in this expression by
T’ and
T’’ respectively.
Now, we use the following important equivalence:
Exactness of the algorithm is equivalent to the
triangle inequality: for any operation
o and any graph
G, we have
where
o(
G) is the result of applying
o to
G.
The proof is performed by induction on C(G), the minimum total cost over all reducing sequences. If G is of a final form, then T(G) ≤ C(G) (let a reducing sequence be empty). Consider some nonempty shortest reducing sequence for G, and denote the first operation in it by o. By the induction hypothesis, T(o(G)) ≤ C(o(G)). Then, by this inequality, T(G) = c(o) + T(o(G)) ≤ c(o) + C(o(G)) = C(G), i.e., T(G) = C(G). The converse is even simpler, but we use only this implication. Note that this argument works for any algorithm, not only for the one described above.
Thus, to complete the proof of Theorem 1, it remains to check the triangle inequality for each of the above-mentioned operations o.
1. o is the Rem operation. When passing from G to o(G), B reduces by 1. Consider several cases.
1.1. An isolated singular vertex is removed (chain of type 2a’ or 2b’). Then S, D, and c do not change; d increases by 1; f reduces by 1. P does not increase when removing any chain. Therefore, T’ + T’’ − P reduces by at most wa. If a b-vertex is removed, then Kb reduces by 1 and T reduces by at most wb.
1.2. A singular vertex is removed from a cycle, or a loop is removed. Then, S does not reduce.
1.3. An interior singular vertex (i.e., on both sides of it there are other singular vertices) is removed from a chain. The type of the chain does not change, changes from 3b* to 3b’, or changes from 2a* to 2a’. Then, P does not increase, since no element increases its quality when making this change.
1.4. A hanging vertex which is the only singular vertex in a chain is removed from the chain. Then, S and D do not reduce, and Kb reduces by 1 if a b-vertex is removed.
1.5. A hanging vertex that is not unique in a chain is removed from the chain. If, when passing from G to o(G), S does not change (the segment adjacent to the hanging edge is even), then the hanging extremity becomes nonhanging, and the following changes in the type of the chain are possible: 1a changes into 3a, 1b changes into 3b, 2 changes into 1, 2a changes into 1a, 2b changes into 1b, or 1 changes into 3. In the first three cases, D does not change and P does not increase. Indeed, all elements containing type 1a do not increase their quality when making the change from 1a to 3a; the same applies to the two other changes. In the last three cases, D increases by 1, P either does not change or increases by at most wa (consider the inverse change), and all other quantities do not change. Then, T’ + T’’ − P reduces by at most wa. If S increases by one (the segment adjacent to the hanging edge is odd), then the hanging extremity remains to be hanging, and the type of the chain does not change. Therefore, D and P do not change.
1.6. A nonhanging exterior singular vertex (on the right or on the left of it there are no other singular vertices) is removed from a chain, and it is the only singular vertex in the chain. Then, the chain has one of the types 3a, 3b, 2a, 2b, or 1, since, after cutting out conventional edges, we obtain a chain with one singular vertex, and P does not increase. If the chain is of type 3a or 3b, then S increases by 1, since both segments adjacent to the removed vertex are even and the resulting segment is odd, and D reduces by 1. If the chain is of type 2a, 2b, or 1, then D and S do not change (in the cases of 2a or 2b, two odd segments are replaced with one odd; in the case of 1, one even and one odd segments are replaced with one even). Therefore, T’ + T’’ − P reduces by at most wa.
1.7. A nonhanging exterior singular vertex is removed from a chain, and it is not a unique singular vertex in the chain. If, when passing from G to o(G), S does not change (the extremal segment is odd, and the next one is even), then the hanging extremity becomes nonhanging, and we repeat the arguments from case 1.5. If S increases by 1, then either the type of the chain does not change (then, T’ + T’’ − P does not change) or (if both segments adjacent to the removed vertex are even) the nonhanging extremity becomes hanging. Then, one of the following changes in the type of the chain is possible: 1a changes into 2a, 1b changes into 2b, 3 changes into 1, 3a changes into 1a, 3b changes into 1b, or 1 changes into 2. In the first three cases, D reduces by 1 and P does not increase. In the last three cases, D does not change and P either does not change or increases by at most wa. Thus, in all cases, T’ + T’’ − P reduces by at most wa.
2. o is an OM.
2.1. Extremities of one chain are joined. This is possible for odd chains only. Then, d increases by 1, f reduces by 1, and c either increases by 1 or does not change, such that T’ either reduces by 1 − wa or does not change. Consider possible chain types. For a chain of type 0, S reduces by 1, since an odd segment turns into a cyclic one of length greater by 1. Then, T reduces by 1 (now, c(o) = 1). For a chain of type 1a or 1b, B and S do not change, D reduces by 1, and P either does not change or reduces by at most wa + wb. Therefore, T changes by at most 1. For types 2a or 2b, D does not change and P either does not change or reduces by at most wb. If at both ends of the chain there are hanging edges, then after joining their endpoints, B reduces by 1 and S does not change. If at least on one side there is an odd extremal segment, then B does not change and S reduces by 1. For types 3a or 3b, B and S do not change, D reduces by 1, and P either does not change or reduces by at most wb. Therefore, T changes by at most 1.
2.2. Extremities of different chains are joined. In
Table 2, we present results of joining the endpoints of nonhanging edges labeled with
a or of hanging edges labeled with
b (the added edge is labeled by
b). Such a join is referred to as a
b-
join (similarly for an
a-
join). The result of an
a-join coincides with the result of a
b-join obtained by interchanging the labels
a and
b in chains.
Define types of extremities: 0a is an extremity of an odd chain of type 0, 0 is an extremity of an even chain of type 0, 1a is a hanging extremity of a chain of type 1a, 1a’ is a nonhanging extremity of a chain of type 1a, 2a* is an extremity of a chain of type 2a* (respectively, 2a’), 3a* is an extremity of a chain of type 3a* (respectively, 3a’), 1 is a hanging extremity of a chain of type 1 with singular b-vertices, 1’ is a nonhanging extremity of a chain of type 1 with singular b-vertices (respectively, 1\b and 1’\b are extremities of chains of type 1 without singular b-vertices), 2 is an extremity of a chain of type 2, and 3 is an extremity of a chain of type 3.
Denote by Δ
X the
increment of
X, i.e., the difference of values of
X when passing from
G to
o(
G), Δ
X= X(
o(
G)) −
X(
G). In
Table 2, we present
number segments which
contain all possible increments of
T (in parentheses) and
P (in square brackets) from Equations (1a)–(2) when joining an extremity of a chain with the row name and an extremity of a chain with the column name, i.e., when passing from
G to
o(
G). These segments are merely lower and upper estimates for
T and
P, which is sufficient for the following step. The increments are given as functions of the costs
wa and
wb. At the bottom of the same cell, we give the type of the chain obtained as a result of this passing, i.e., joining the initial chains. For instance, joining the extremity 2
a* or 2
a’ with any extremity has the same increment of all arguments in Equation (1a) except for Δ
Kb, and the corresponding Δ
P is given in the cells of row {2
a*, 2
a’} in
Table 2. Here,
wb,a is equal to
wb for 2
a* and
wa for 2
a’. Similarly, this applies to the pairs 3
a* and 3
a’, 1 and 1\
b, and 1
’ and 1
’\
b. Next, (0) means that the corresponding quantity “does not change”, (−
wa) means “reduces by at most
wa”, (+
wa) means “increases by at most
wa”, (1 −
wa) means “increases by at most 1 −
wa”, etc.; an ellipsis denotes numbers between the ends of the given number segments. Bounds for Δ
T are easily computed through bounds for Δ
P and increments of other arguments in Equation (2), with the latter being easy to find.
Thus, the problem consists precisely of estimating Δ
P. For that, we use a functional
P−(
M,
M1), where
M is a set consisting of two chains in
G whose types are the one from the row name and the one from the column name, while
M1 consists of a single chain in
G with the name given in the corresponding cell. The functional itself is the
minimum increment of
P when replacing
M with
M1 over all graphs
G containing
M. Given the functional
P−(
M,
M1), one can compute a functional
P+(
M,
M1) as a function of
wa and
wb which is the
maximum increment of
P when replacing
M with
M1 over all graphs
G containing
M. Specifically, we have the equality
P+(
M,
M1) = −
P−(
M1,
M). Note that
Table 2 is symmetric around the main diagonal.
Thus, to compute P−(M,M1), we need Lemma 3 below, where M consists of different chains, denoted by 1 and 2, and M1 consists of one corresponding chain, denoted by 3. If D is a maximal domain in a graph G containing M, we denote by G’ the graph that contains all chains from M and all chains from elements in D which intersect with M. These elements themselves form a maximal domain D’ in G’. Indeed, if D’ is not maximal, strictly extend it to a maximal domain in G’, which together with elements in D\G’ forms a domain in G with quality strictly greater than that of D, a contradiction.
Lemma 3. We have ≥ .
Proof. Recall that such a difference was called the increment of the corresponding quantity. Denote the left-hand side of the inequality by d, and the right-hand side, by d’. Consider D\D’ (elements of D that do not contain chains 1 and 2), D1, a maximal domain in o(G’), and D2, the result of replacing D’ with D1 in D. Then, d ≥ P(D2) − P(D) = P(D1) − P(D’), since P(D2) = P(D1) + P(D2\D1) and P(D) = P(D’) + P(D2\D1). □
Thus, we want to find
. Let
X be a set containing at most two polytypes α* and β* (one for each element of
D’), and let
Y be a set containing at most four of the types of which these polytypes are composed (types of the chains contained in the corresponding elements of
D’) and also containing the types of the initial chains 1 and 2. There exists a
G’’ for which these polytypes correspond to disjoint elements, and for such a
G’’ the pair
D’’ = {α*, β*} is a polytype of a domain in
G’’, not necessarily maximal. In the last case,
is smaller than the quality
P(
G’’), and such an
X is inessential when searching for the minimum. Given
G’’, we form the corresponding
o(
G’’) and find in it an actual maximal domain and the quality
P(
o(
G’’)), i.e., the minuend is definitely correct, and the subtrahend may be smaller than required. Note that
P(
D’) =
P(
D’’), as well as for other domains, since the quality of any domain does not change when changing chains but preserving their types. Through an exhaustive search over all such
X, we find the desired lower bound; in this way,
Table 2 is filled. Take note that the number of possible sets
X is not greater than the squared number of interactions, and
X contains at most eight types. Therefore, due to an exhaustive search over all
X and finding a maximal domain in
o(
G’’), computing
P‒(
M,
M1), takes constant time.
Note that if the initial chains are even, then
T’ increases by 1 −
wa; otherwise, it does not change; simple observations of this kind are omitted in what follows. Let us show how seven cells in
Table 2 are filled, with the other being filled similarly.
(1) Cell 1a,1a. After the join, we obtain a chain of type 3a*. If the initial chains have hanging edges, then B reduces by 1 and S does not change. If at least one of the initial chains has an odd extremal segment, then, vice versa, B does not change and S reduces by 1, D reduces by 1, and Kb reduces by 1. Therefore, T + P reduces by wa + wb. Our functionals are as follows: P−(1a,1a; 3a*) = −wa − 1 and P+(1a,1a; 3a*) = min(1 − wa − wb,0). In other words, either P reduces by at least wa + wb − 1 but at most wa + 1 (if wa + wb − 1 > 0), or P does not increase and reduces by at most wa + 1 (otherwise). Therefore, we have |ΔT| ≤ 1.
(2) Cell 1a,2. After the join, we obtain a chain of type 1 (it is not involved in interactions). Similarly to case (1), we obtain that T + P reduces by wa + wb. We have P−(1a,2; 1) = −wa − wb, P+(1a,2; 1) = min(1 − wa − wb,0). In other words, either P reduces by at least wa + wb − 1 (if wa + wb − 1 > 0) but at most wa + wb, or P does not increase and reduces by at most wa + wb (otherwise). Therefore, |ΔT| ≤ 1.
(3) Cell 2a,3a. After the join, we obtain a chain of type 1a. Then, T + P reduces by wb − wa if the type of the 3a-chain is 3a* and does not change if it is 3a’. We have P−(2a,3a*; 1a) = −wb, P−(2a,3a’; 1a) = −wa, P+(2a,3a*; 1a) = wa, and P+(2a,3a’; 1a) = wa. In other words, P reduces by at most wb in the first case and by at most wa in the second and increases by at most wa in both cases.
(4) Cell 2a,1’. After the join, we obtain a chain of type 2. Then, B, S, and D do not change. We have P–(2a,1; 2) = −wb, P+(2a,1; 2) = max(wa + wb − 1,0).
(5) Cell 1,3. After the join, we obtain a chain of type 3b. The increment of T + P is 1 − wb if the chain of type 1 contains a b-vertex, and 1 − wa otherwise. We have P−(1,3; 3b) = min(1 − wa − wb,0) and P+(1,3; 3b) = wb. Subtracting from the increment of T + P three possible increments of P, equal to 1 − wa − wb, 0, or wb, we obtain a number of absolute value no greater than 1.
(6) Cell 2,2. After the join, we obtain a chain of type 2b*. The increment of T + P is 1 − wa − wb. We have P−(2,2; 2b*) = −wa and P+(2,2; 2b*) = 2 − wa − wb. Subtracting from the increment of T + P all possible increments of P, equal to −wa or 2 − wa − wb, we obtain a number of absolute value no greater than 1.
(7) Cell 2,3. After the join, we obtain a chain of type 1b. The increment of T + P is 1 − wb. We have P−(2,3; 1b) = min(1 − wa − wb,0) and P+(2,3; 1b) = 1. Subtracting from the increment of T + P all possible increments of P, equal to 1 − wa − wb, 0 or 1, we obtain a number of absolute value no greater than 1.
Thus, the result for OM follows from the fact that, according to
Table 2,
T changes by at most 1.
The next simple lemma is used in what follows.
Lemma 4. Let X(G) be a function of a graph G, and let ΔX(G,G1) be its increment when passing from G to G1. Then,
ΔX(G,G1) = −ΔX(G1,G). In particular, if o is an operation, then ΔX(G,o(G)) = −ΔX(o(G),G). If o is a composition of operations o1 and o2 (first o1 and then o2), then ΔX(G,o(G)) = ΔX(G,o1(G)) + ΔX(o1(G),o(G)).
For any graphs G andG1and any operations o and o1, if ΔX(G,G1) = ΔX(o(G),o1(G1)), then ΔX(G,o(G)) = ΔX(G1,o1(G1)).
Proof. The first claim is obvious. The second follows from the equalities ΔX(G,o(G)) = ΔX(G,G1) + ΔX(G1,o1(G1)) − ΔX(o(G),o1(G1)) = ΔX(G1,o1(G1)). □
3. o is a Cut. This operation is the inverse to OM; thus, the result follows from case 2 and Lemma 4.1.
4. o is an SM. Represent o as a composition of a cut and a join. By Lemma 4.1, the increment obtained in a composition of operations is the sum of increments obtained in each of them.
4.1. Reversal (i.e., rearrangement of a connected fragment of edges in reverse order at the same place) of an extremal fragment of the chain. Denote by 1 and 2 the extremities of the reversed fragment and, by 2’, the arising free endpoint of the remaining chain. Consider two joins: the first is the inverse to the cut (the first operation of the reversal), and the second is the join from the reversal. They are either both
a- or both
b-joins. We go over all rows of
Table 2 in the role of the endpoint 2’ and over pairs of columns as the extremities 1 and 2; the latter are either of types 1
a or 1
a’ or they are a pair of identical extremities of types 0
a, 2
a*, 2
a’, 3
a*, or 3
a’. The increment of
T when making a cut is opposite to the increment of
T when joining 2 and 2’, as for any mutually inverse operations. By Lemma 4.1 it suffices to check the following: when joining the extremities 2 and 2’ and extremities 1 and 2’, we obtain increments with the absolute value of their difference no greater than 1.
Let us give examples; other pairs of joins are considered similarly. Cases of a-joins are considered analogously to b-joins.
(1) The pair of cells 1a,1a and 1a,1a’ defines two joins: 2’ = 1a, 2 = 1a, 1 = 1a’. For the first of them, ΔT and ΔP are, respectively, −1 + x and 1 − wa − wb − x with 0 ≤ x ≤ wa + 1; for the second, these increments are −wb + y and 0 − y with 0 ≤ y ≤ wa + wb. The difference of increments of T is strictly greater than 1 in absolute value if x − y > 2 − wb or x − y < −wb (this region in the x,y plane is called forbidden). This difference is equal to the increment of T upon the reversal, and we want to show that the forbidden region is empty. The difference R of increments of P (the second minus the first) is x − y + wa + wb − 1. In the forbidden region, R > wa + 1 or R < wa − 1. However, R is equal to the increment of P resulting when making the reversal. The reversal result is obtained by replacing a chain of type 3a* (the result of joining the extremities 2 and 2’) with a chain of type 1a (the result of joining the extremities 1 and 2’). This increment of P lies in the segment [0,wa], since P−(3a*; 1a) = 0 and P+(3a*; 1a) = wa. Hence, the forbidden region is empty. Computation of P−(M;M1) in the cases where |M| = 1 or |M1| = 2 is performed as in Lemma 3.
(2) The pair of identical cells 1a,3a defines two joins: 2’ = 1a, 2 = 3a, 1 = 3a. For these joins, ΔT is either −wb + x and −wb + y (if the 3a chain is of type 3a*) or −wa + x and −wa + y (if this chain is of type 3a’). Although both joins are made according to the same cell, ΔT takes different values within the same segment because of other parameters of the graph. Respectively, ΔP is 0 − x and 0 − y. The forbidden region, which is shown to be empty, is as follows: x − y > 1 or x − y < −1. We have R = x − y. However, R is equal to the increment of P upon the reversal (replacing a chain 3a* (the result of joining the extremities 2 and 2’) with a chain 3a* (the result of joining the extremities 1 and 2’)), i.e., it is zero.
4.2. Circularization of an extremal fragment of a chain, i.e., the composition of a cut of the chain with closing one of the parts into a cycle or loop by a join. Denote by 1 and 2 the extremities of the circularized fragment and, by 2’, the arising free endpoint of the remaining part of the chain. Consider two joins: the first is the inverse to the cut (the first operation of the circularization), and the second is the join from the circularization. They are either both a- or both b-joins.
Let us make
Table 3 for closing a chain into a cycle, analogous to
Table 2, following the description given in case 2.1. In
Table 3, for each odd type of a chain, we give an interval of possible increments of
T and the corresponding interval of increments of
P when closing this chain into a cycle by a join.
In
Table 2 we go over all rows in the role of extremity 2’ and all columns in the role of extremity 2, the latter for all types of extremities of odd chains. By Lemma 4.1, it suffices to check the following condition:
The absolute value of the difference of ΔT for joins of 2 and 2’ and joins of 1 and 2 is at most 1. (3)
Let us give examples; other pairs of joins are considered similarly. Cases of a-joins are considered analogously to b-joins.
(1) Cell 0,1
a (i.e., 2’ = 0, 2 = 1
a, 1 = 1
a’). Here, Δ
T and Δ
P are, respectively, 0 +
x and 0 −
x, and, in
Table 3, for chain 1
a, these increments are −1 +
y and 0 −
y. The forbidden region for condition (3) is as follows:
x −
y > 0 or
x −
y < −2. The difference
R of increments of
P is
x −
y. In the forbidden region, we have, respectively,
R > 0 or
R < −2. However,
R is equal to the increment of
P when replacing a chain of type 3 (the result of joining the extremities 2 and 2’) with a chain of type 0 (the result of joining the extremities 1 and 2) and cannot take these values. Therefore, the forbidden region is empty.
(2) Cell 1a,1a (i.e., 2’ = 1a, 2 = 1a, 1 = 1a’). Here, ΔT and ΔP are, respectively, −1 + x and 1 − wa − wb − x. The forbidden region for condition (3) is as follows: x − y > 1 or x − y < −1; R = x − y + wa + wb − 1. In the forbidden region, R > wa + wb or R < wa + wb − 2. However, R is equal to the increment of P when replacing a chain of type 3a with a chain of type 1a and cannot take these values. Therefore, the forbidden region is empty.
(3) Cell 2,3
a (i.e., 2’ = 2, 2 = 3
a, 1 = 3
a). Here, Δ
T and Δ
P are, respectively, −
wb +
x (or −
wa +
x) and 0 −
x, and, in
Table 3, for chain 3
a, these increments are −1 +
y and 0 −
y. The forbidden region for condition (3) is as follows:
x −
y >
wb or
x −
y <
wb − 2 (or:
x −
y >
wa or
x −
y <
wa − 2);
R =
x −
y. In the forbidden region,
R >
wa or
R <
wb − 2. However,
R is equal to the increment of
P when replacing a chain of type 1 with a chain of type 2 and (since
P+(1;2) = max(
wa +
wb − 1,0)) cannot take these values. Therefore, the forbidden region is empty.
4.3. SM is applied to a cycle (or a loop) and a chain, i.e., a cycle or a loop is cut and the obtained chain is lengthened. This operation is the inverse to the preceding one (case 4.2); therefore, by Lemma 4.1, we have |ΔT| ≤ 1.
4.4. SM is applied to two chains: the first is cut, and the second is joined. Denote by 1 the arising free extremity in the cut chain, which is joined with an extremity of the second chain, denoted by 2’. The other arising free extremity of the cut chain is denoted by 2. Consider two joins: the first of them is the inverse to the cut (the first operation in our SM), and the second is the final OM. They are either both
a- or both
b-joins. We go over all rows of
Table 2 in the role of extremity 1 and over all pairs of columns in the role of extremities 2 and 2’. By Lemma 4.1, it suffices to check the following: for joins of extremities 1 and 2 and extremities 1 and 2’ we obtain increments with the absolute value of their difference no greater than 1.
Let us give examples; other pairs of joins are considered similarly. Cases of a-joins are considered analogously to b-joins.
(1) The pair of cells 1a,0 and 1a,1a (i.e., 1 = 1a, 2 = 0, 2’ = 1a). When making the join according to the first cell, we have ΔT = 0 + x, 0 ≤ x ≤ 1. When making the join according to the second cell, ΔT = −1 + y, 0 ≤ y ≤ wa. The difference of these expressions (the second minus the first) is y − x − 1. Its absolute value is greater than 1 if y − x > 2 or y − x < 0 (the forbidden region). The corresponding difference R of increments of P is x − y + 1 − wa − wb, which, for y − x > 2, yields R < −1 − wa − wb, and for y − x < 0, R > 1 − wa − wb. However, R is equal to the increment of P when making the original SM operation. The result is obtained by replacing chains of types 3 (joining the extremities 1 and 2) and 1a (the chain with extremity 2’) with chains of types 3a* (joining the extremities 1 and 2’) and 0 (the chain with extremity 2). The equalities P−(1a,3; 3a*,0) = −wa and P+(1a,3; 3a*,0) = min{0,1 − wa − wb} imply that such values of R are impossible and that the forbidden region is empty.
(2) The pair 2a*,1 and 2a*,1’ (i.e., 1 = 2a*, 2 = 1, 2’ = 1’). When making the join according to the first cell, we have ΔT = −wb + x. When making the join according to the second cell, ΔT = −wb + y. The difference of these expressions (the second minus the first) is y − x. The forbidden region is x − y < −1 or x − y > 1. The corresponding difference R of increments of P is x − y + wa. In the forbidden region, R < −1 + wa or R > 1+wa. However, R is equal to the increment of P when replacing chains of types 1 (joining the extremities 1 and 2) and 1 (the chain with extremity 2’) with chains of types 2 (joining the extremities 1 and 2’) and 1 (the chain with extremity 2). The equalities P−(1,1; 2,1) = 0 and P+(1,1; 2,1) = max{0,wa + wb − 1} imply that the forbidden region is empty.
(3) The pair 1,1a and 1,1 (i.e., 1 = 1, 2 = 1a, 2’ = 1). When making the join according to the first cell, we have ΔT = −wb + x. When making the join according to the second cell, ΔT = 1 − 2wb + y. The difference of these expressions is y − x + 1 − wb. The forbidden region is x − y < −wb or x − y > 2 − wb. The corresponding difference R of increments of P is x − y + wb. In the forbidden region, R < 0 or R > 2. Under the SM, chains of types 3 and 1 are replaced with chains of types 1a and 3b. The equalities P−(3,1; 1a,3b) = wb and P+(3,1; 1a,3b) = 1 imply that the forbidden region is empty.
(4) The pair (1,1\b),1a and (1,1\b),3 (i.e., 1 = 1 or 1 = 1\b, 2 = 1a, 2’ = 3). When making the join according to the first cell, we have ΔT = −wb,a + x, where the index b occurs in the case 1 = 1, and index a, in the case 1 = 1\b. When making the join according to the second cell, ΔT = −wb,a + y. The forbidden region is x − y < −1 or x − y > 1. The corresponding difference R of increments of P is x − y + 1. In the forbidden region, R < 0 or R > 2. Under the SM, chains of types 1 and 3 are replaced with chains of types 1a and 1b. The equalities P−(1,3; 1a,1b) = min(1,wa + wb) and P+(1,3; 1a,1b) = wa + wb imply that the forbidden region is empty.
(5) The pair 1,3a* and 1,1’ (i.e., 1 = 1, 2 = 3a*, 2’ = 1’). When making the join according to the first cell, we have ΔT= −wb + x. When making the join according to the second cell, ΔT = 1 − wb + wa − y. The forbidden region is x + y<wa or x + y>2 + wa. The corresponding difference R of increments of P is x + y − wa. In the forbidden region, R < 0 or R > 2. Under the SM, chains of types 1 and 3 are replaced with chains of types 3a* and 1b. The equalities P−(1,3; 3a*,1b) = wb and P+(1,3; 3a*,1b) = min(1,wa + wb) imply that the forbidden region is empty.
(6) The pair 2,1a and 2,1 (i.e., 1 = 2, 2 = 1a, 2’ = 1). When making the join according to the first cell, we have ΔT = −1 + x. When making the join according to the second cell, ΔT = 1 − wb − y. The forbidden region is x + y < 1 − wb or x + y > 3 − wb. The corresponding difference R of increments of P is x + y − 1 + wa + wb. In the forbidden region, R < wa or R > 2 + wa. Under the SM, chains of types 1 and 1 are replaced with chains of types 1a and 1b. The equalities P−(1,1; 1a,1b) = wa + wb and P+(1,1; 1a,1b) = wa + wb imply that the forbidden region is empty.
(7) The pair 2,2 and 2,3 (i.e., 1 = 2, 2 = 2, 2’ = 3). When making the join according to the first cell, we have ΔT = 1 − wb − x. When making the join according to the second cell, ΔT = −wb + y. The forbidden region is −x − y > 0 or −x − y < −2. The corresponding difference R of increments of P is −x − y + wa + 1. In the forbidden region, R > wa + 1 or R < wa − 1. Under the SM, chains of types 2b* and 3 are replaced with chains of types 1b and 2. The equalities P−(2b*,3; 1b,2) = 0 and P + (2b*,3; 1b,2) = wa imply that the forbidden region is empty.
5. o is a DM. Represent o as a composition of two cuts and two joins. One can easily check that, when making any operation, B + S changes by at most 1. This property of an operation is called the B + S property.
5.1. Reversal in a cycle or in a chain. Let both cuts be interior (i.e., on both sides of each cut there are singular vertices); then,
P and
D do not change, since the chain type does not change. The result follows from the
B + S property. Let a reversal be made in a chain where at least one cut is exterior. The extremity of the chain adjacent to an exterior cut is called
exterior; let it be the left-hand extremity. The other cut is called
interior, as well as the edge that it cuts. To reduce the number of cases to consider, note that, according to the upper row of
Table 2, joining any chain with an odd chain of type 0, as well as the inverse cut operation, does not change
T. We call this the
odd cutting property. Therefore, if at one end (or at both ends) outside the chain there is a fragment (fragments) of oddly many conventional edges, then we can cut it (them) out, make the reversal, and then again join it (them) to the resulting chain. Thus, it remains to consider the case where exterior cuts are made at extreme edges. If the reverted segment has no singular vertices, the chain does not change. Otherwise, consider two possibilities.
(1) Two singular vertices are joined into one, i.e., B reduces by 1. Then, one cut is interior and the other exterior. Consider variants of changing the parity of the extremal segment. If it does not change, the result follows from the B + S property. If an even extremal segment is replaced with an odd one, S increases by 1, since an extremal odd segment appears. The following variants of changing the chain type are possible: 3a changes into 1a, 1 changes into 2, 1a changes into 2a, and 3 changes into 1. In the first two variants, D does not change, and P does not reduce and increases by at most wa. In the last two variants, D reduces by 1 and P does not increase and reduces by at most wa. If an odd extremal segment is replaced with an even one, S does not change. Now, the following variants of changing the chain type are possible: 1a changes into 3a, 2 changes into 1, 2a changes into 1a, and 1 changes into 3. In the first two variants, D does not change, and P does not increase and reduces by at most wa. In the last two variants, D increases by 1, and P does not reduce and increases by at most wa. In all the cases, T changes by at most 1.
(2) Assume that no merging of two singular vertices into one occurs, i.e., B does not change, and let one cut be interior and the other exterior. Consider variants of changing the parity of the extremal segment. If it does not change, the result follows from the B + S property. If an even extremal segment is replaced with an odd one, S either does not change or increases by 1. The following variants of changing the chain type are possible: 3a changes into 1a, 1 changes into 2, 1a changes into 2a, and 3 changes into 1. In the first two variants, D does not change, and P does not reduce and increases by at most wa. In the last two variants, D reduces by 1, and P does not increase and reduces by at most wa. If an odd extremal segment is replaced with an even one, S either does not change or reduces by 1. Now, the following variants of changing the chain type are possible: 1a changes into 3a, 2 changes into 1, 2a changes into 1a, and 1 changes into 3. In the first two variants, D does not change, and P does not increase and reduces by at most wa. In the last two variants, D increases by 1, and P does not reduce and increases by at most wa. In all the cases, |ΔT| ≤ 1. If both cuts are exterior, then, taking into account the odd cutting property, the chain does not change.
5.2. Breaking a cycle into two cycles or a cycle and a loop (cutting out a cycle or a loop from a cycle). In this case, T’ either reduces by 1 − wa or does not change; T’’ either does not change, or increases by wa, or reduces by wa; P does not change; and (wb − wa)Kb either does not change or increases by wb − wa. Therefore, |ΔT| ≤ 1.
5.3. Cutting out a fragment from a chain and circularizing it (we consider the case where a cycle is formed; the case of a loop reduces to removal of a vertex). Here, c increases by 1. If this fragment contains no singular vertices, consider two cases. Let no merging of two singular vertices into one occur. Then, one fragment splits into two, one of the new segments being cyclic and, hence, even. Then S reduces by 1, since a cyclic segment appears, and the chain type does not change; T reduces by 1. Now, let two singular vertices merge into one. Then, one odd segment is circularized with adding an additional conventional edge, S does not change, the chain type does not change, and T reduces by 1.
If the fragment contains singular vertices, we consider the same two possibilities as in case 5.1 and repeat all arguments with replacing the reversal operation by circularization. The only case that must be considered separately is the case where both cuts are exterior. One can easily see that the odd cutting property holds for the circularization operation, as well as for the reversal. Therefore, it suffices to consider the case where both cuts are made at extremal edges. This results in a 0-chain of length 1. If merging of vertices occurs, then no segment appears in the cycle, and S increases by 1 due to the appearance of the above-mentioned 0-chain. In this case, the initial chain is of type 3a or 3b, such that, when it turns into a chain of type 0, D reduces by 1, and P does not increase and reduces by at most wa. In all the cases, |ΔT| ≤ 1.
Let there be no merging of vertices; then, two extremal segments of the chain are transformed into other two segments with the same total length. One of them is the above-mentioned 0-chain of length 1, and the other is located inside a cycle. If both extremal segments are odd, then S reduces by 1, the initial chain is of type either 2a or 2b, D does not change, and P does not increase and reduces by at most wb. If at least one of the extremal segments is odd, then S does not change, the initial chain is of type 1a, 1b, 3a, or 3b, D reduces by 1, and P does not increase and reduces by at most wa + wb. In all the cases, |ΔT| ≤ 1.
5.4. Joining two cycles into one, joining a cycle and a loop, or joining two loops. In this case, T’ either increases by 1 − wa or does not change, T’’ does not change, increases by wa, or reduces by wa, P does not change, and (wb − wa)Kb either does not change or reduces by wb − wa. Therefore, |ΔT| ≤ 1.
5.5. One cut is made in a chain, and the other in a cycle or loop. The case of a loop is trivial; consider the case of a cycle. The cycle is cut and inserted into a chain. If no merging of vertices occurs, then this operation is the inverse to that considered in case 5.3. Otherwise, B reduces by 1. Furthermore, c reduces by 1. If the cut in the chain is interior or the parity of the extremal segment does not change, the result follows from the B + S property. Next, we repeat the arguments from case 5.1, subcase (1).
5.6. Each cut is made in a separate chain.
5.6.1. Both cuts are interior. In what follows, we implicitly use the B + S property without referring to it. To trace the changes of D and P, consider types of both chains. If the set of types of the two chains does not change or the change consists in replacing the «asterisk» with the «prime» in the type of one of the chains or vice versa, then the result follows from the fact that, when making such a replacement, P changes by at most wb − wa, since P−(2b*; 2b’) = P−(3a*; 3a’)= wa − wb and P−(2b’; 2b*)= P−(3a’; 3a*) = 0. In what follows, we call this case the identical transformation and omit it from consideration. Consider other cases.
(1) Both chains are odd, and either both are a- or both are b-chains. T’ does not change. If both chains are of type 1a, the only nonidentical change of types is transformation of this pair into a pair of chains of types 2a and 3a or 2a and 3a’: D reduces by 1, and (wb − wa)Kb either reduces by wb − wa or does not change. Since P−(1a,1a; 2a,3a) = −2wa, P−(1a,1a; 2a,3a’) = −1, and P+(1a,1a; 2a,3a) = P+(1a,1a; 2a,3a’) = 1 − wa − wb, we have |ΔT| ≤ 1. Type 1b is considered similarly. Any other pair of types of the initial chains (except for 2a and 3a, which give the inverse transformation) results in the identical change.
(2) Both chains are odd, one of them being an a-chain and the other a b-chain. If their pair of types is 1a,1b, then, when making a DM, it transforms into either a 1,1 or a 2,3 pair: T’ reduces by 1 − wa; (wb − wa)Kb in the first case either reduces by wb − wa or does not change and, in the second case, does not change. In the first case, D reduces by 2, and P reduces by wa + wb. In the second case, D reduces by 1, and P reduces by at most 1 and at least min(1,wa + wb) (since P + (1a,1b; 2,3) = max(−1,−wa − wb)). If the pair of initial types is 1a,2b or 1a,2b’, then, when making a DM, it transforms into a pair 1,2: T’ reduces by 1 − wa; (wb − wa)Kb does not change, reduces by wb − wa (in the case of 2b), or increases by wb − wa (in the case of 2b’); D reduces by 1; P reduces by at most 1 and at least wb (in the case of 2b) or wa (in the case of 2b’). The pair 1a,3b is considered similarly. If the pair of initial types is 2a,2b or 2a,2b’, then, when making a DM, it transforms into a pair 2,2: T’ reduces by 1 − wa; (wb − wa)Kb either does not change or increases by wb − wa; D does not change; P does not increase and reduces by at most 2 − wa − wb, since P−(2a,2b; 2,2) = P−(2a,2b’; 2,2) = wa + wb − 2 and P + (2a,2b; 2,2) = P + (2a,2b’; 2,2) = 0. The pairs 3a,3b or 3a’,3b are considered similarly. If the initial pair is 2b,3a, 2b’,3a, 2b,3a’, or 2b’,3a’, then, when making a DM, it transforms into a pair 1,1: (wb − wa)Kb does not change, increases by wb − wa (for the last three pairs), or reduces by wb − wa (for the first pair); T’ reduces by 1 − wa; D reduces by 1; P reduces by wb (in the first three cases) or wa (in the last case). Similarly, this applies to the pair 2a,3b. In all the cases, |ΔT| ≤ 1.
(3) Both chains are even. The only nontrivial transformation relates to pairs 2,3 and 1,1; other transformations are either identical or inverse to those considered in case (2). T’ does not change. When a pair 2,3 transforms into 1,1, D reduces by 1, (wb − wa)Kb either does not change or reduces by wb − wa, and ΔP = min(0,1 − wa − wb).
(4) One chain is odd, and the other even: T’ does not change. If a pair 1b,1 transforms into 2b,3 or 2b’,3, then D does not change; (wb − wa)Kb does not change, increases by wb − wa (for the first case), or reduces by wb − wa (for the second case); ΔP is not less than wb − 1 and wa − 1, respectively, and not greater than 0, whence the desired follows. Transformation into a pair 3a,2 is similar. If a pair 1b,2 transforms into 2b,1 or 2b’,1, then D reduces by 1, (wb − wa)Kb either does not change or reduces by wb − wa, and ΔP is not less than − wb and not greater than min(0,1 − wa − wb), whence the desired follows. Transformation of a pair 1a,3 into 3a,1 is similar. Transformation of a pair 2a,1 into 1a,2 is inverse to the one considered above. If a pair 2a,3 transforms into 3a,2 or 3a’,2, then D does not change, ΔP is not less than wa − 1 and not greater than 1 − wb, and Kb does not change. Transformations 2a,3 into 3a’,2 and 2b’,3 into 3b,2 are considered similarly. Transformations 2a,3 into 1a,1, 3a,1 into 1a,3, and 3a,2 into 1a,1 are inverse to those considered above. For a pair 3a,3, the identical transformation is only possible.
5.6.2. One of the cuts is exterior. We reduce this case to an SM or OM operation as follows: the extremity of the chain adjacent to an exterior cut is called exterior. The other cut is called interior, as well as the edge that it cuts. If an exterior cut is at neither an extremal edge nor the edge next to it, we remove two conventional edges from the exterior end. Then, T reduces by 1 both in the initial graph and in the resulting one, which allows us to apply Lemma 4.2. Therefore, it suffices to consider cases where the exterior cut is at an extremal edge of a chain or at the next to it.
(1) The exterior cut is at the next to extremal edge. If it is conventional, remove two extremal edges together with the exterior cut, thus replacing the DM with an SM (see
Figure 5a). Then,
T reduces by 1 both in the initial graph and in the resulting one, which by Lemma 4.2 reduces the problem to the SM case. If the edge with the exterior cut is singular, remove the extremal edge together with its endpoints, replacing an odd extremal segment of length 1 with a hanging edge (the singular vertex becomes an endpoint of a hanging edge). Again, the DM is changed to an SM with reducing
T by 1 in both graphs (see
Figure 5b).
(2) The exterior cut is at the extremal edge, and this edge is conventional. If the interior edge is conventional or its singular vertex is on the side that is joined with the exterior extremity, move the exterior cut outside the end of the chain (i.e., make it “fictitious”) and move the interior cut to the next edge in the opposite direction from the potential singular vertex (and, if this edge is missing, then outside the end of the chain) (see
Figure 5c). Thus, the DM is changed to an SM (or, respectively, to the identity operation, which changes nothing). The result of the operation does not change. If the singular vertex is on the other side, move the exterior cut from the end to the next edge and, accordingly, move the interior cut to the neighboring edge (see
Figure 5d). The result of the operation does not change, and the problem reduces to that considered in the preceding case.
(3) The exterior cut is at the extremal edge, and this edge is singular. If the interior edge is conventional or its singular vertex is on the side that is joined with the exterior extremity, we proceed as in the preceding case (see
Figure 6a). Otherwise, move the exterior cut outside the end of the chain and move the interior cut to the neighboring edge in the opposite direction from the singular vertex (and, if this edge is missing, then outside the end of the chain) (see
Figure 6b–d). Thus, the DM is replaced with an SM or OM. To obtain the result of the first operation (DM) from the result of the second (SM or OM), merge the two singular vertices by deleting the conventional edge that separates them, and add a chain from one conventional edge (in the case of OM) or add two extremal conventional edges to the chain (if the interior cut was moved to a conventional edge), or replace a hanging edge with an extremal segment of length 1 (if the interior cut was moved to a singular edge). In all the cases, the transformation does not change
T, which completes the analysis of the cases.
Theorem 1 is proven.