Certifying Fully Dynamic Algorithms for Recognition and Hamiltonicity of Threshold and Chain Graphs

Solving problems on graphs dynamically calls for algorithms to function under repeated modifications to the graph and to be more efficient than solving the problem for the whole graph from scratch after each modification. Dynamic algorithms have been considered for several graph properties, for example connectivity, shortest paths and graph recognition. In this paper we present fully dynamic algorithms for the recognition of threshold graphs and chain graphs, which are optimal in the sense that the costs per modification are linear in the number of modified edges. Furthermore, our algorithms also consider the addition and deletion of sets of vertices as well as edges. In the negative case, i.e., where the graph is not a threshold graph or chain graph anymore, our algorithms return a certificate of constant size. Additionally, we present optimal fully dynamic algorithms for the Hamiltonian cycle problem and the Hamiltonian path problem on threshold and chain graphs which return a vertex cutset as certificate for the non-existence of such a path or cycle in the negative case.


Introduction
In many graph-theoretical applications graphs are not static, but change over time. For example in a social network it is common that vertices (representing members of the network) as well as edges (representing a connection between two members) can be added or deleted at any given time. As these types of networks can be very large, it is important to update certain properties of a network efficiently when making such a modification. Due to the size of some of these networks, however, even a running time linear in the size of the network can be prohibitive, begging the question whether it is possible to make such an update either in time logarithmic in the input or ideally with a running time linear in the size of the modification. In particular, we can ask if it is possible to use such a scheme when checking whether a given graph is part of some graph class. Such schemes are called dynamic recognition algorithms and are categorized depending on the modification operations they support: An edges-only dynamic recognition algorithm supports both edge additions and edge deletions. A fully dynamic recognition algorithm supports edge modifications as well as vertex additions and deletions. Note that for vertex additions one usually is also given a set of neighbors of the new vertex. A dynamic recognition algorithm is said to be optimal if the running time of each operation is linear in the number of edges involved in that operation.
Dynamic recognition algorithms have been developed for many different graph classes. For example, Ibarra [20] presented edges-only fully dynamic recognition algorithms for chordal graphs and split graphs. Similar results were attained by Hell et al. [16] for proper interval graphs, by Crespelle and Paul [9] for permutation graphs and by Soulignac [28] for proper circular arc graphs. Furthermore, Shamir and Sharan [27] formulated a fully dynamic algorithm for the recognition of cographs. The combination of this algorithm with Ibarra's for split graphs implies a fully dynamic recognition algorithm for threshold graphs, as these form the intersection of split and cographs [27]. However, this algorithm does not yield a certificate for the negative case and does not fully represent the special structure of threshold graphs, as it relies on algorithms for other graph classes. Besides the recognition of graph classes, fully dynamic algorithms have also been developed for many other graph-theoretical problems such as connectivity [18,19,29], shortest paths [10,21] and matching approximation [2], as well as for minimal integral separators for threshold and difference graphs [4].
Threshold graphs were first introduced by Hammer and Chvátal [5,6], where they were used to solve the aggregation problem for set-packing inequalities, and, independently by Henderson and Zalcstein [17]. Furthermore, Hammer and Chvátal [6] showed that threshold graphs can be characterized as the graphs which do not contain an induced subgraph isomorphic to 2K 2 , P 4 or C 4 . Since then, there has been considerable interest in this graph class leading to many interesting results. A survey can be found in the book by Peled and Mahadev [23]. Apart from linear integer programming, threshold graphs have also been used in applications as diverse as mathematical psychology [7,8], scheduling [22] and parallel computing [24,25].
In the context of fully dynamic recognition algorithms, the relationship between threshold graphs and the aggregation problem for set packing inequalities is of particular interest. In this problem one is given a linear integer program containing a collection of set-packing inequalities and wishes to find an equivalent program in which this collection of inequalities is covered by a single equation. In [6], Hammer and Chvátal showed that this problem is in fact equivalent to the recognition of threshold graphs. To this end, each variable of the linear program contained in set-packing inequalities is identified with a vertex of a graph, where two vertices are connected by an edge if they both appear together in some equation. The binary solutions to these inequalities correspond to the independent sets of the constructed graph. In particular, they can be aggregated to one linear equation if and only if the graph is threshold. In this context, adding and removing vertices from the graph can be seen as the addition or removal of variables, while the addition and deletion of edges corresponds to the modification of the inequalities.
Chain graphs (also known as difference graphs in the literature), introduced by Yannakakis [30] and also independently by Hammer et al. [11], are closely related to threshold graphs and in many ways form a bipartite variant of threshold graphs. In fact, a bipartite graph G with bipartition (X , Y ) is a chain graph if and only if adding all edges between vertices in X yields a threshold graph [23]. Equivalently, Yannakakis [30] characterized chain graphs as bipartite graphs that do not contain an induced 2K 2 . Heggernes and Kratsch showed that both threshold and chain graphs can be recognized in linear time [13].
Our Contribution. In this paper, we present optimal fully dynamic recognition algorithms for threshold graphs and chain graphs. These algorithms are certifying, i.e., they return a certificate in form of a forbidden subgraph for the negative case. The algorithms need linear time for preprocessing and the running time of the operations are as follows: O(1) for deleting and inserting an edge and O(d) for inserting or deleting a vertex v which has d neighbors in G. For threshold graphs Shamir and Sharan [27] already introduced a fully dynamic recognition algorithm with similar running times. However, their algorithm is not certifying and uses the fully dynamic recognition algorithms for split graphs and cographs, while our implementation is self contained, using an efficient data structure for threshold graphs, and yields certificates.
Furthermore, we expand on the idea of a fully dynamic algorithm by giving efficient routines for the addition and deletion of sets of vertices or edges. While for the studied graph classes the modification of sets of vertices is a straightforward extension of the previous results, the modification of sets of edges needs a different approach which leads to a running time of O(min{k log k, n + k}), where k is the size of the modified edge set. This approach uses special edge elimination schemes introduced by Beisegel et al. [1].
Using concepts from these recognition algorithms, we also present fully dynamic algorithms for both threshold graphs and chain graphs that decide whether a given threshold and chain graph has a Hamiltonian cycle or a Hamiltonian path. These algorithms have running times that are identical to the running times of the recognition algorithms. In the positive case, they can find a Hamiltonian cycle or path in time O(n). Otherwise, they can find in time O(n) a vertex cutset that separates the graph into many connected components. This can be used as a certificate for the non-existence of such a path or cycle. To the best of our knowledge, these are the first dynamic algorithms for the Hamiltonian path and cycle problem.

Preliminaries
Throughout this paper, we consider graphs G = (V , E) with n = |V | vertices and m = |E| edges, which are always finite, simple and undirected. Apart from possible isolated vertices, i.e., vertices without incident edges, the graphs are connected, that is, they have only one non-trivial component. An edge between u and v is simply Given a subset of vertices U ⊆ V , the subgraph of G induced by U is denoted by Let u and v be two different vertices of G = (V , E). Then, G − uv denotes the graph without edge uv, i.e., the graph with vertex set V and edge set E = E\{uv}. Similarly, G + uv is the graph with edge uv, that is, E = E ∪ {uv}.
In this paper, we mainly focus on two graph classes, namely threshold graphs and chain graphs. A graph is a threshold graph if there are vertex weights w(v) for each vertex v ∈ V and a value S (the threshold) such that uv ∈ E if and only if w(u) + w(v) > S. Although this is the standard definition of threshold graphs, an equivalent definition will turn out to be more convenient for our purpose: A graph is a threshold graph if and only if it can be generated from a one-vertex graph by repeated additions of isolated vertices or universal vertices, i.e., vertices that are adjacent to all already existing vertices. Furthermore, threshold graphs are exactly the graphs that do not contain an induced P 4 , C 4 or 2K 2 [6], that is, there are no induced paths or cycles with four vertices and no two non-adjacent edges.
Similarly, chain graphs can be defined in various ways. A graph is a chain graph if there are a positive threshold T and vertex weights w(v) with |w(v)| < T such that uv ∈ E if and only if |w(u) − w(v)| > T . Therefore, these graphs are also called difference graphs [11]. In fact, chain graphs are exactly the bipartite 2K 2 -free graphs [30]. The complement of a bipartite graph G is an interval graph if and only if G is a chain graph. Furthermore, chain graphs can be characterized as those bipartite graphs with vertex bipartition B 1∪ B 2 , where the neighborhoods of the vertices in B 1 are totally ordered by set inclusion, i.e., for every There is a close relation between threshold and chain graphs. Given a threshold graph G with the vertex partition in the set U of universal vertices and the set I of independent vertices, the graph consisting only of the edges of G between U and I and the same vertex set is a chain graph. Vice versa, completing one of the sets B i of a chain graph to a clique yields a threshold graph [30]. Note that both threshold and chain graphs have only one non-trivial component, as they are 2K 2 -free. Moreover, threshold graphs are chordal, whereas chain graphs are AT-free and co-comparability graphs [3]. A comprehensive survey on threshold and chain graphs is given in the book of Mahadev and Peled [23].
The following lemma shows that the neighborhoods of two vertices in a threshold or chain graph can be compared by simply comparing their respective degrees. This property will be used frequently throughout.

Lemma 2.1 Let G = (V , E) be a threshold graph and let u, v ∈ V be two vertices in
Let G = (X ∪ Y , E) be a chain graph and let u, v ∈ X be two vertices in the same Proof We start with the threshold graphs. Let x be a vertex in N G (u)\N G [v]. Then for the weight function w : V → R and the threshold S it holds: w(u) + w(x) > S and w(v) + w(x) ≤ S. Therefore, w(u) must be larger than w(v) and for every vertex y ∈ V holds w(u) + w(y) > w(v) + w(y). Thus, there cannot be a vertex in N (v) that is not in N [u] and the degree condition holds.
For the chain graph we turn X into a clique and get a threshold graph. Since the property of the neighborhoods of u and v still holds, it follows from the first part of the lemma that the degree of u is larger than the degree of v in the threshold graph. This also holds for the chain graph, as both degrees were raised by the same number.
This shows that vertex degrees play an important role in threshold and chain graphs and motivates the following definition which aims to simplify notation throughout.

Definition 2.2
Let uv and x y be two edges connecting vertices of a graph G with Note that it is not necessary that these edges are contained in the edge set of G. The edge x y is called degree-lower than edge uv in G if: The edge x y is called degree-greater than edge uv if: Note that an edge x y can be both degree-lower and degree-greater than an edge uv = x y at the same time. This holds for example if x = u and d G ( . Furthermore, in the definition of degree-lower and degreegreater, we consider both edges and non-edges of a graph. This is necessary as we will consider both the insertion and the deletion of edges in our dynamic algorithms. For a graph G and a set of edges F connecting vertices of G, but not necessarily contained in G we say that e ∈ F is degree-minimal in F if it is degree-lower in G than any other edge in F. Edge e is said to be degree-maximal in F if it is degree-greater in G than any other edge in F.
The problem of dynamically recognizing certain graph classes can be defined as follows: Given a graph class G and a graph G ∈ G, one looks for a representation which allows the efficient insertion or deletion of vertices and edges and a decision whether the new graph is still in G. Algorithms for this problem are called dynamic a b e c f d Fig. 1 A threshold graph together with its threshold partition. Black vertices belong to 3 i=1 U i and white vertices belong to the 3 i=1 I i . Thus, the partition is ( . Usually, both a and b would be included in the clique set of the threshold graph. However, since we have an odd number of degrees, one of the vertices of degree three, i.e., vertex a, forms the set I 1 and the rest forms U 1 recognition algorithms and are categorized depending on the modification operations they support. Following the terminology used in [27], we call a dynamic recognition algorithm an edges-only fully dynamic recognition algorithm if it supports both edge additions and edge deletions. A fully dynamic recognition algorithm supports edge modifications as well as vertex additions and deletions. Note that for vertex additions one usually is also given a set of neighbors of the new vertex.

Threshold Graphs
Heggernes and Papadopoulos [15] introduced a vertex partition of threshold graphs which consists of an ordered partition of the clique set and an ordered partition of the independent set. Here, we introduce a similar structure that merges these two partitions into one and swaps the order of the partition sets (see Fig. 1for an example). Definition 3.1 Let G = (V , E) be a threshold graph. A threshold partition of G is an ordered partition P = (I 1 , U 1 , . . . , I k , U k , I k+1 ) of the vertex set V with I i , U i = ∅ for all 1 ≤ i ≤ k such that x y ∈ E if and only if x ∈ I i ∪ U i and y ∈ U j or vice versa for some i ≤ j.
Note that the set I k+1 contains the isolated vertices of G and can be empty. The existence of a threshold partition for every threshold graph follows from the fact that a threshold graph can be generated from a one-vertex graph by repeated additions of isolated or universal vertices. The following observation is a direct result of the definition of the threshold partition and Lemma 2.1. • If x, y ∈ I i or x, y ∈ U i , then d G (x) = d G (y).
• If x ∈ I i and y ∈ I j with i < j, then d G (x) > d G (y).
• If x ∈ U i and y ∈ U j with i < j, then d G (x) < d G (y).
• If x ∈ I i and y ∈ U j , then d G (x) ≤ d G (y) and unless i = j = 1 and |I 1 | = 1, it holds that d G (x) < d G (y).
Thus, apart from I 1 and U 1 , the sets of the threshold partition coincide with the sets of vertices of the same degree. However, the U -sets are ordered increasingly by the degree of their vertices while the I -sets are ordered decreasingly. As we will see in the following, this unusual ordering ensures that vertices incident to edges which are safe to add or to delete lie close to each other in the threshold partition. This would not be the case if we order the partition sets strictly due to their vertex degrees. As well as leading to more intuitive proofs, this definition also has benefits with regard to the implementation of this structure.
Observation 3.2 also implies a linear-time algorithm to compute such a partition.

Theorem 3.3
There is an algorithm that computes the threshold partition of a threshold graph in time O(n + m).
Proof We sort the vertices by their degrees using bucket sort. If there are vertices of degree zero, then they form the set I k+1 and we delete them from the graph G. Then we consider the vertices with the smallest degree of the remaining graph. They form set I k and their neighbors form set U k . Note that, due to G being a threshold graph, all vertices contained in U k are universal in G. Again, we delete both the vertices of I k and of U k from G. The resulting graph is still a threshold graph and the degree ordering does not change as the vertices of U k are adjacent to all remaining vertices and the vertices of I k are adjacent to none of them. We repeat this procedure until we have either partitioned the whole graph or we only have one bucket S left, i.e., all the remaining vertices have the same degree. The degree of these remaining vertices was not minimal in the step before, i.e., these vertices have neighbors that were not neighbors of the vertices in I 2 . This implies that there are at least two vertices in S and the vertices of S are pairwise adjacent. We choose one of the vertices of S that forms I 1 , the other vertices of S form U 1 .
The whole procedure has a running time of O(n + m). The first sorting of the vertices can be found in linear time. Because there is no resorting needed, the rest of the procedure can also be done in linear time.
In the following, we will present three lemmas that use the threshold partition to characterize edges and vertices that can be deleted from a threshold graph or added to it such that it is still a threshold graph. The proofs of these lemmas are constructive, i.e., for the positive case they provide the updated threshold partition of the new graph and for the negative case they imply a certificate for the graph not being a threshold graph in form of a forbidden induced subgraph. Both the new threshold partition as well as the forbidden subgraph will be helpful for our fully dynamic algorithm for threshold graph recognition. Additionally, we will show that the vertices of the certificate still induce a forbidden subgraph if we delete or add further edges with a special property on the degrees of their vertices. We will use these results in Sect. 5 to present a certifying dynamic algorithm for the addition and deletion of several edges at the same time.
The following data structure will be used throughout to represent threshold graphs.

Definition 3.4 (Threshold data structure)
For a threshold graph G = (V , E) a threshold data structure consists of the following elements: • a threshold partition P of G as a doubly linked list of doubly linked lists, • a pointer from every vertex v ∈ V to its list L in P and to its element in L • for every list in P the information whether it represents a U -set or an I -set We begin with the deletion of an edge.
Lemma 3.5 Let G = (V , E) be a threshold graph with a threshold data structure containing threshold partition P = (I 1 , U 1 , . . . , I k , U k , I k+1 ) and let x y ∈ E. There is an algorithm with running time in O(1) which returns a threshold data structure of G − x y if one of the following conditions holds: 1. |I 1 | = 1 and both x and y are elements of U 1 2.
x ∈ I j and y ∈ U j for some j ∈ {1, . . . , k}, or vice versa.
Otherwise the algorithm returns a set of four vertices that induces a P 4 or a C 4 in G-x y and a P 4 , C 4 or 2K 2 in the graph G-x y-F where F is an arbitrary set of edges in G that are degree-greater than x y in G.
Proof In order to decide whether the first condition holds, we only have to check the size of I 1 and whether both x and y are contained in the set U 1 of the doubly linked list.
For the second condition we only have to check whether the set containing one of the vertices is the successor of the set containing the other vertex in P. These operations can be done in constant time. Now we show that the edge x y can be removed without leaving the class of threshold graphs if one of the two conditions holds. Note that this result was already proven by Heggernes and Papadopoulos [15]. However, we need a slightly different technical argument for the fully dynamic recognition algorithm, so we present it here again. For the two cases we consider the following vertex partitions: Note that in P 2 the vertex x becomes a member of U j−1 if I j \{x} is empty and y becomes a member of I j+1 if U j \{y} is empty. It follows by definition that P 1 is again a threshold partition of the graph G − x y if Condition 1 holds. Furthermore, P 2 is also a threshold partition of G − x y if Condition 2 holds. To compute theses partitions we only have to remove a constant number of elements from their corresponding lists and put them in lists that are predecessors or successors of the old lists. Therefore, these operations can be done in O(1).
We will show that for every edge x y ∈ E that does not fulfill the conditions the graph G − x y is not a threshold graph. To this end, we will show how we can find an induced P 4 or C 4 in G − x y. Without loss of generality, we may assume that y ∈ U j for some j ∈ {1, . . . , k}.
In the following we consider three cases (see Fig. 2). Case (i) We first consider the case that x is an element of an independent set I . As x y is an edge of G it holds that ≤ j. Since Condition 2 fails, we have < j. Let a be a vertex in U and b be a vertex in I j . Both vertices can be found in constant The three cases of the proof of Lemma 3.5. Black vertices belong to k i=1 U i and white vertices belong to k i=1 I i . The thick edge is the edge we want to delete. The order of the vertices respects the order of their corresponding sets in the threshold partition time. The set {x, a, y, b} induces the following edges: xa, ay, by. Thus, (x, a, y, b) is an induced P 4 in G − x y, since x is not adjacent to b, as both x and b are part of an independent set, and a is not adjacent to b because < j. Due to Observation 3.2, both xa and by are not degree-greater than x y in G. If we remove arbitrary edges from G − x y which are degree-greater than x y, then the vertices a, b, x and y induce a P 4 or a 2K 2 , depending on whether the edge ay was removed.
For cases (ii) and (iii) we assume that x ∈ U i and i ≤ j, as otherwise we can swap the roles of x and y.
Case (ii) Let i = j. If i = 1, then I 1 contains at least two vertices because Condition 1 does not hold. Otherwise, there are at least two vertices in I 1 ∪ I 2 . In both cases we have at least two non-adjacent vertices a and b which are adjacent both to x and to y. Thus, the set {x, y, a, b} induces a C 4 in G − x y. Both a and b can be found in constant time. Furthermore, all the edges contained in this cycle are not degree-greater than edge x y in G, due to Observation 3.2. Therefore, the C 4 is also contained in any graph G − F where F is a set of edges that are degree-greater than x y in G.
Case (iii) Let i < j. We pick vertices a ∈ I 1 and b ∈ I j in constant time. The edges ax, ay and by are contained in G. Note that x is not adjacent to b since j > i and that a is not adjacent to b since both belong to independent sets. Now (x, a, y, b) is an induced P 4 in G − x y. Again, all the edges contained in this path are not degree-greater than edge x y in G.
For the addition of an edge there is a similar characterization.

Lemma 3.6 Let G = (V , E) be a threshold graph with a threshold data structure containing threshold partition
There is an algorithm with running time in O(1) which returns a threshold data structure of G + x y if one of the following conditions hold: 1. x ∈ I 1 and y ∈ I 1 ; 2. I 1 = {x} and y ∈ I 2 , or vice versa; 3. x ∈ U j and y ∈ I j+1 for some j ∈ {1, . . . , k}, or vice versa.
Otherwise the algorithm returns a set of four vertices that induces a P 4 or a 2K 2 in G + x y and a P 4 , 2K 2 or C 4 in the graph G + x y + F where F is an arbitrary set of non-edges of G that are degree-lower than x y in G.
x a b y Fig. 3 The cases of the proof of Lemma 3.6. Black vertices belong to k i=1 U i and white vertices belong to k i=1 I i . The thick edge is the edge we want to add. The order of the vertices respects the order of their corresponding sets in the threshold partition Proof All three conditions can be checked in constant time. Assume first that the edge x y fulfills one of the three conditions. Then consider the following threshold partitions: If I 1 \{x, y} in P 1 is empty, then y becomes an element of U 1 . If U 1 \{z} is empty in P 2 , then we join the sets {z} and {y}. If I 2 \{y} in P 2 is empty, x becomes a member of U 2 . If U j \{x} is empty in P 3 , then {y} becomes a member of I j and if I j+1 \{y} is empty, then x is added to U j+1 . It is not difficult to see that these three partitions form threshold partitions of G + x y for the three different cases, respectively. Just as in the argument in the proof of Lemma 3.5, they can be computed in constant time.
Now assume that x y does not fulfill any of these three conditions. First assume that one of the vertices, say x, is in a set U i . Since x y / ∈ E and Condition 3 does not hold, vertex y must be in a set I j with j > i + 1. Let a be a vertex in I i+1 and b be a vertex in U i+1 . Then, (a, b, x, y) is an induced P 4 in G + x y (see Fig. 3(i)). Note that we can find a and b in constant time since we only have to find the successor of U i and its successor in the threshold partition P. Furthermore, the only non-edge of the P 4 that is degree-lower than x y in G is the edge ay, due to Observation 3.2. Therefore, in any graph G + x y + F where F contains only edges that are degree-lower than x y in G the vertices a, b, x and y induce a P 4 or C 4 , depending on whether ay is in F.
Thus, we can assume that both x and y are elements of I -sets. First assume that both x and y are elements of I i . Since Condition 1 does not hold, i must be greater than 1. Let a ∈ I 1 and b ∈ U 1 . Then the vertices a, b, x, and y induce a 2K 2 in G + x y (see Fig. 3(ii)) Again, we can find a and b in constant time and all non-edges of the 2K 2 are not degree-lower than x y in G.
Now consider the case that x and y are in different I -sets. Without loss of generality, we assume that x ∈ I i and y ∈ I j with i < j. Assume first that i = 1. If j = 2, then, by Condition 2, there is a vertex a ∈ I 1 \{x}. In this case let b ∈ U 1 . If j > 2, than let a ∈ I 2 and b ∈ U 2 . In both cases (a, b, x, y) is an induced P 4 in G + x y (see Fig. 3(iii)) and we find a and b in time O (1). Similar to the first case, ay is the only non-edge of this path that is degree-lower than x y and the insertion of ay turns the P 4 into a C 4 in any G + x y + F. Now assume that i = 1 and let a ∈ I 1 and b ∈ U 1 . The vertices a, b, x and y induce a 2K 2 in G + x y (see Fig. 3(ii)), which is also a 2K 2 in any G + x y + F with suitable F.
Since threshold graphs are hereditary, the deletion of a vertex in a threshold graph always leads to a threshold graph. Therefore, we only have to characterize the case in which a vertex with a given set of neighbors can be added to G such that G is still threshold.
There is an algorithm with running time in O(|N z |) which returns a threshold data structure of G if one of the following conditions hold.
Otherwise the algorithm returns a set of four vertices that induces a P 4 , C 4 or 2K 2 in G .
Proof We first describe how to check in time O(|N z |) whether one of the three conditions hold. We iterate through N z , mark the contained vertices and count the number of elements of N z in each set U i and I i as well as the total number of elements of N z in U -sets and I -sets, respectively. Furthermore, when considering an element of N z we remove it from its list and reinsert it at the front of this list. Therefore, in every list the elements of N z are at the beginning.
If all elements of N z are in U -sets, then we have to check whether Condition 1 holds. We iterate through the U -sets starting in U k and check whether the number of elements of N z in the respective set is equal to the size of the set. Furthermore, we count how many elements of N z we have already found in the considered sets. When we have found the first set U i for which |U i | = |U i ∩ N z |, we check whether we have already found all elements of N z .
If there is only one vertex in I 1 and this vertex is the only element of an I -set in N z , then we check Condition 2 in the same way that we have checked Condition 1. Otherwise, we have to check whether Condition 3 holds. We first examine whether for all U -sets their size is equal to the number of elements of N z in it. Then we iterate through the I -sets starting in I 1 and check the same property. When the first I -set for which this does not hold is found, we check whether we have discovered all elements of N z so far. Now we present the threshold partitions of the graph G belonging to each of the three conditions. For the first condition let A = U i \N z and B = U i ∩N z . The following partition is a threshold partition of G : Fig. 4 The three cases of the proof of Lemma 3.7. Black vertices belong to k i=1 U i and white vertices belong to k i=1 I i , the added vertex z is gray. In (a) and (b) the order of the vertices respects the order of their corresponding sets in the threshold partition (apart from the position of z). Dashed edges could be in the graph or not, missing edges are not in the graph For the second condition let A = U 1 \N z and B = U 1 ∩ N z and let a be an arbitrary vertex in A. Then the following partition is a threshold partition of G : If A is empty, then we omit the sets {a} and A\{a}. For the third condition let A = I i \N z and B = I i ∩ N z . In this case is a threshold partition of G . If in any of the three cases the set preceding (or succeeding) {z} is empty, then we remove this empty set and put z into the set preceding (or succeeding) this empty set. Due to our sorting of the lists in P, we can find A and B in time O(|N z |). This is done by simply iterating through U i or I i , removing the elements from U i or I i and put them into the new list B as long as they are in N z . The remaining list is A. Now, we show how to find the forbidden induced subgraphs in the case that none of the three conditions hold. Assume first that there is a vertex x ∈ U i ∩ N z and a vertex y ∈ U j with j > i and y / ∈ N z . Vertex y is found at the end of the first set for which |U j | = |U j ∩ N z |. To find the vertex x we mark each set U i while iterating through the U -sets. If Condition 1 fails, then we iterate through N z and find x by checking whether the U -sets of the vertices are marked or not. Additionally, we consider a vertex a ∈ I j . The set {a, x, y, z} induces a P 4 or a C 4 in G depending on whether a is in N z or not (see Fig. 4(i)).
Assume that x ∈ I i ∩ N z and y ∈ I j \N z with j < i. We find both vertices in a similar way as we found x and y in the case above while iterating through the I -sets in order to check Condition 3. For some a ∈ U j the set {a, x, y, z} induces a P 4 or a 2K 2 depending on whether a is in N z or not (see Fig. 4(ii)).
If none of the two cases above occurs, then there must be a vertex x ∈ U \N z and a vertex y in N z which is an element of an I -set. Since Condition 2 does not hold, there must be another vertex a in an I -set with a = y and xa ∈ E. We find x by scanning the U -sets starting in U k and consider the set U i with largest index that contains a vertex x / ∈ N z . We choose an arbitrary vertex y ∈ N z \U and another vertex a in I i or I i−1 . We know that both yz and ax are edges of G and neither ay nor zx are edges in G . Depending on which of the edges x y and az are in G , the set {a, x, y, z} induces a P 4 or a C 4 or a 2K 2 in G (see Fig. 4(iii)).
Using the results above, we now present an optimal fully dynamic algorithm for threshold graphs that provides a certificate for the negative case.

Theorem 3.8
There is a fully dynamic algorithm for the recognition of threshold graphs which provides a set of four vertices inducing a forbidden induced subgraph as certificate in the negative case and has the following costs: Proof It follows from Lemmas 3.5, 3.6 and 3.7 that we have an algorithm which allows addition and deletion of edges and the addition of a vertex with d neighbors. It remains to show that this is also possible for the deletion of a vertex. Since threshold graphs are hereditary, we do not have to check anything if we delete a vertex z. The new threshold partition is constructed by simply deleting z from its set. If the set is empty afterwards, then we remove it from the threshold partition and merge its predecessor set with its successor set. If z was in a set U i we move all vertices from I i into I i+1 . If z was in a set I i , then we move all vertices from U i into U i−1 . Therefore, only neighbors of z change their set and the whole procedure can be done in O(|N (z)|).

Chain Graphs
We begin with the definition of a special vertex partition of chain graphs that we will use for this algorithm.  A 1 , B 1 , . . . , A k such that x y ∈ E if and only if x ∈ A i and y ∈ B j or vice versa with i ≤ j. In particular, the set I is the set of isolated vertices and can be empty.
In order to be more convenient in this context, this definition has been adapted from a similar concept introduced by Heggernes and Papadopoulos [15]. Note that a graph with a chain partition does not contain a 2K 2 , as for any two edges the vertex that appears first in the ordered partition must be adjacent to both vertices in the other set of the bipartition. Thus, a graph with a chain partition is, in fact, a chain graph, as it is also bipartite by definition. For the existence and computation of a chain partition we use the following result by Hammer et al. [11].

Lemma 4.2 [11] A bipartite graph is a chain graph if and only if every induced subgraph without isolated vertices has a dominating vertex on each side of the bipartition, that is, a vertex adjacent to all the vertices on the other side of the bipartition.
For a chain graph we first remove all isolated vertices and insert them into I . For the remaining graph we compute a bipartition (A, B). Due to Lemma 4.2, there must be at least one vertex in B that is adjacent to all vertices in A. These vertices form the elements of B k . After the deletion of B k there are isolated vertices in A which form the set A k . These are then also removed from the graph. Repeating this procedure until the graph is empty leads to a chain partition. For our fully dynamic algorithm we use the following data structure.

Definition 4.3 (Chain data structure)
For a chain graph G = (V , E) a chain data structure consists of the following elements: • a chain partition P of G as a doubly linked list of doubly linked lists • a pointer from every vertex v ∈ V to its list L in P and to its corresponding element in L • for every list in P the information whether it stands for an A-set or a B-set or the set I Similar to the results for threshold graphs, we now present algorithms for the deletion and addition of edges as well as the addition of a vertex with a set of neighbors. These algorithms will either return a new chain data structure or they will return an induced 2K 2 or an odd cycle contained in the new graph, showing that it is not a chain graph. (A 1 , B 1 , . . . , A k , B

k , I ) and let x y ∈ E. There is an algorithm with running time in O(1) which returns a chain data structure of G − x y if x ∈ A i and y ∈ B i or vice versa. Otherwise, the algorithm returns a set of four vertices that induces a 2K 2 in G − x y and any graph G − x y − F where F is an arbitrary set of edges in G that are degree-greater than x y in G.
Proof In order to check the condition we only have to compare the successor of the set of x to the set of y in the chain partition and vice versa. This can be done in constant time. If x ∈ A i and y ∈ B i , then consider the following partition: If A i \{x} is empty, then y becomes a member of B i−1 and if B i \{y} is empty, then x becomes a member of A i+1 (or I if i = k). It is not difficult to see that P is a chain partition of G − x y and can be constructed in time O (1).
On the other hand, assume that x y does not fulfill the condition, i.e., without loss of generality we may assume that x ∈ A i and y ∈ B j with j > i. Consider vertices w ∈ B i and z ∈ A j . Then the set {w, x, y, z} induces a 2K 2 in G − x y. Since d G (z) < d G (x) and d G (w) < d G (y), this 2K 2 is contained in any graph G − x y − F where F only contains edges that are degree-greater than x y. Lemma 4.5 Let G = (V , E) be a chain graph with a chain data structure containing chain partition P = (A 1 , B 1 , . . . , A k , B k , I ) and let x y / ∈ E. There is an algorithm with running time in O(1) which returns a chain data structure of G + x y if one of the following conditions holds: 1. x ∈ A i and y ∈ B i−1 or vice versa 2. x ∈ A 1 and y ∈ I or vice versa 3. x ∈ I and y ∈ B k or vice versa 4. I = V Otherwise, the algorithm returns an induced 2K 2 or a C 3 contained in G + x y. In this case let F be an arbitrary set of non-edges of G that are degree-lower than x y in G. Then the algorithm can find an induced 2K 2 or a C 3 contained in G = G + x y + F in time O(|F|).
Proof One can check whether one of the conditions holds in O(1) using the information given by the chain data structure. Consider the following partitions: Similar to the proofs of Lemmas 3.5-3.7, we remove empty sets from these partitions and add x and y to the preceding or succeeding set. It follows from the structure of the chain graphs, as given above, that partition P i is a chain partition of graph G + x y if Condition i holds. Furthermore, all partitions can be constructed in time O (1).
For the reverse, first consider the case that x, y ∈ I but I = V . Then let w ∈ A 1 and z ∈ B 1 . The set {w, x, y, z} induces a 2K 2 in G + x y and any missing edge in this 2K 2 is not degree-lower than x y in G. If both x and y are elements of A-sets, then we choose a vertex z ∈ B k . If both x and y are elements of B-sets, then we choose a vertex z ∈ A 1 . In both cases the set {x, y, z} induces a C 3 in G + x y and any graph containing G + x y, showing that they are not bipartite and, thus, not chain graphs.
If x ∈ A i and y ∈ B j with j < i − 1, then x and y together with vertices w ∈ A i−1 and z ∈ B i−1 induce a 2K 2 in G + x y. Assume x ∈ I . If y ∈ B i with i < k, then a 2K 2 is induced by x and y and the vertices w ∈ A k and z ∈ B k . If y ∈ A i with i > 1, then the 2K 2 is induced by x, y and the vertices w ∈ A 1 and z ∈ B 1 . All these vertices can easily be found in constant time. The only missing edges of the 2K 2 that could be degree-lower than the edge x y in G are the edges yz and wx. However, these edges connect two vertices of A or B, respectively. Therefore, if we find such an edge in the set F, then we can find a C 3 contained in G + x y + F using the steps described above.

Lemma 4.6
Let G = (V , E) be a chain graph with a chain data structure containing chain partition P = (A 1 , B 1 , . . . , A k , B k , I ). For a vertex z / ∈ V and a set N z ⊆ V of vertices in G we consider the graph G There is an algorithm with running time in O(|N z |) which returns a chain data structure of G if one of the following conditions holds.
1. N z = ∅; 2. k j=1 A j ⊆ N z and B j ∩ N z = ∅ for all 1 ≤ j ≤ k; 3. k j=1 B j ⊆ N z and A j ∩ N z = ∅ for all 1 ≤ j ≤ k; 4. there is an 1 ≤ i ≤ k such that i−1 j=1 A j ⊆ N z and A ∩ N z = ∅ for all k ≥ > i, B j ∩ N z = ∅ for all 1 ≤ j ≤ k and I ∩ N z = ∅; 5. there is an 1 ≤ i ≤ k such that k j=i+1 B j ⊆ N z and B ∩ N z = ∅ for all 1 ≤ < i, A j ∩ N z = ∅ for all 1 ≤ j ≤ k and I ∩ N z = ∅.
Otherwise the algorithm returns an induced C 3 or 2K 2 contained in G or a set of five vertices inducing a subgraph of G that contains a C 5 .

Proof
To check these conditions, we iterate through N z and count the number of elements that it has in each set in the chain partition. Furthermore, when considering an element of N z we remove it from its list and reinsert it at the front of this list. Therefore, in every list the elements of N z are at the beginning. If there are vertices from both A-and B-sets in N z , then none of the conditions hold. If there are only vertices of A-sets (and maybe vertices of I ), then we iterate through the A-sets starting in A 1 and search for the first set where the size of the set is not equal to the number of vertices of N z in this set. At this point we must have found all elements of N z , as otherwise none of the conditions hold. If no such set exists, then Condition 2 holds. For the case that N z only contains elements of B-sets (and maybe I ) we do the same, with the difference that we start in B k . All these steps can be done in O(|N z |) since the number of sets that we have to consider is bounded by O(|N z |).
Assume that z fulfills one of the conditions of the lemma. If N z = ∅, then we simply insert z into I . For the other conditions we consider the following partitions: (A 1 , B 1 , . . . , A k , B k , I ∩ N z , {z}, I \N z ), ∩ N z , A 1 , B 1 , . . . , A k , B k , I \N z ), In the partition P 4 vertex z is added to B i−1 if N z ∩ A i is empty and to B i if A i \N z is empty. In the partition P 5 vertex z is added to A i if B i \N z is empty and to A i+1 if B i ∩ N z is empty. The partition P i is a chain partition of G if Condition i holds. Furthermore, we can compute these partitions in time O (|N z |). Now assume that z does not fulfill any of the conditions. If there are vertices of N z in both A-sets and B-sets, then we consider different cases. If there is a vertex x ∈ A 1 ∩ N z , then we choose an arbitrary vertex y in N z which is an element of a B-set and {x, y, z} induces a C 3 in G . If there is a vertex in x ∈ B k ∩ N z , then this vertex x together with z and an arbitrary vertex y in A i ∩ N z induces a C 3 in G . If none of these two cases occurs, then we choose arbitrary vertices in x ∈ N z ∩ A i and y ∈ N z ∩ B j . Additionally, we choose a vertex a ∈ A 1 and b ∈ B k . The set {a, b, x, y, z} induces a subgraph of G that contains a C 5 . Now assume that there are vertices a ∈ A i ∩ N z (or a ∈ I ∩ N z ) and b ∈ A j \N z with j < i (or ≤ k). We find b while iterating through the A-sets and afterwards a while iterating through N z and check whether the sets of the vertices are already marked. Let c be an arbitrary vertex in B j . Then the set {a, b, c, z} induces a 2K 2 in G . Analogously, we find a 2K 2 if a ∈ B i ∩ N z (or a ∈ I ∩ N z ) and b ∈ B j \N z with j > i (or ≤ k) by considering a vertex c ∈ A j .
Using these results, we can state a fully dynamic recognition algorithm for chain graphs.

Theorem 4.7
There is a fully dynamic algorithm for the recognition of chain graphs which provides a set of at most five vertices inducing a forbidden subgraph as certificate in the negative case and has the following costs:

Adding and Deleting Multiple Vertices and Edges
In some applications it is important to not only delete or add one edge (vertex) at a time but rather sets of edges (vertices). This problem cannot always be solved by regular dynamic algorithms. For example, when dealing with the vertex connectivity problem we cannot delete vertices in an arbitrary order while maintaining connectivity. However, if we have a set of vertices after whose deletion the graph is still connected, then we can find an order of deletions of these vertices that maintains connectivity. On the other hand, if we consider edge deletion in Eulerian graphs, then it is obvious that no one edge can be deleted without leaving the class of Eulerian graphs. For the graph classes considered in this paper, i.e., threshold and chain graphs, we will see that it is always possible to add and delete sets of edges (vertices) one at a time by finding a suitable order.
Since both threshold graphs and chain graphs are hereditary, the deletion of a set of vertices can be done iteratively in any order. The addition of vertices together with incident edges is also simple. If the graph that results from this addition is still in the respective graph class, then we can delete the vertices from this larger graph in an arbitrary order and all intermediate graphs are in the respective graph class. The reverse of this deletion scheme is an addition scheme of the vertices. Therefore, any ordering of the vertices to add is sufficient. Furthermore, a forbidden induced subgraph found by the algorithms described in Lemmas 3.7 and 4.6 remains an induced subgraph, even if we add further vertices together with edges incident to at least one of these vertices.
In (a) the graphs with and without the thick edges are threshold graphs. However, if we delete the edge vx from the larger graph or add the edge vw to the smaller graph, then the result is not a threshold graph. In (b) both graphs are chain graphs. The deletion of wx from the larger graph or the addition of vw to the smaller graph results in a graph that is not a chain graph Therefore, we can easily adapt our certifying dynamic algorithms to the addition and deletion of whole sets of vertices (and incident edges). For sets of edges, the problem is more difficult. In Fig. 5we present two examples which show that we cannot choose an arbitrary ordering in which we add or delete the edges iteratively since there are orderings where the intermediate graphs are not threshold or chain graphs anymore. However, in both examples there is an ordering where the intermediate graphs are in the respective class. This motivates the following definition: A graph class C is called sandwich monotone if for any graph G = (V , E) with G ∈ C and any set F ⊆ E with G − F ∈ C it holds that there is an ordering (e 1 , . . . , e k ) of the edges in F such that for any i ∈ {1, . . . , k} the graph G−{e 1 , . . . , e i } is in C. Equivalently, we can say that F must contain an edge e ∈ F such that G −e ∈ C. From this definition it follows directly that the same holds for the addition of edges, i.e., if G ∈ C and G + F ∈ C, then there is an edge e ∈ F for which G + e is in C.
This property was already studied in 1976 by Rose et al. [26], who showed that chordal graphs fulfill the property. The term sandwich monotonicity was introduced in 2007 by Heggernes and Papadopoulos [14]. The same authors also proved that both threshold and chain graphs are sandwich monotone.
This result leads to a dynamic algorithm that decides whether a set of edges can be added to or deleted from a threshold graph (chain graph) such that the graph is still a threshold graph (chain graph). We iterate through the edges that are not already added or deleted and check with the algorithms of Lemmas 3.5, 3.6, 4.4 and 4.5 whether they are a safe choice. If we do not find such an edge, then the graph that results from the addition or deletion of all edges of the set is not a threshold or chain graph. This algorithm needs time O(k 2 ) to delete or add k edges. In the following, we will present a more sophisticated approach that only needs time O(min{k log k, n + k}). In the negative case, the presented algorithms return a forbidden induced subgraph of the graph that results from the addition or deletion of all edges.
Beisegel et al. [1] showed that for any threshold graph (chain graph) and a special partition (E 1 , . . . , E k ) of the edges of the graph one can compute an elimination ordering of the edges of the graph in linear time such that the edges within a set E i are consecutive and the graph never leaves its respective graph class during the elimination process.
The difference to the problem discussed here is that all edges of the graph are deleted and, as a result, the running time must be dependent on n + m. Here, we only delete k edges and ask whether this can be done faster than n + k. Furthermore, we want to give a certificate in the negative case which was not considered in [1]. However, it will be possible to follow a similar approach using so-called degree-minimal edge elimination schemes. G = (V , E) be a graph and F ⊆ E be a set of edges of G. A degreeminimal edge elimination scheme of F from G is an ordering (e 1 , . . . , e k ) of the edges in F such that for any i ∈ {1, . . . , k} it holds that the edge e i is a degree-minimal edge of F\{e 1 , . . . , e i−1 } for the graph G − {e 1 , . . . , e i−1 }.

Theorem 5.3 [1] Let G = (V , E) be a threshold graph (chain graph). Let F ⊆ E be a subset of the edges of G such that G − F is a threshold graph (chain graph). Then for any degree-minimal edge e in F it holds that G − e is a threshold graph (chain graph).
This immediately implies the following corollary. (e 1 , . . . , e k ) of F from G it holds that G − {e 1 , . . . , e i } is a threshold graph (chain graph) for any i ∈ {1, . . . , k}.

Corollary 5.4 Let G = (V , E) be a threshold graph (chain graph) and F ⊆ E. Then, G − F is a threshold graph (chain graph) if and only if for any degree-minimal edge elimination scheme
Beisegel et al. [1] showed that for any graph we can compute a degree-minimal elimination scheme of all the edges of the graph in time O(n + m).

Theorem 5.5 [1] Given a graph G = (V , E), there is an algorithm that computes a degree-minimal edge elimination scheme of E from G in time O(n + m).
An important step in this algorithm is the sorting of up to m objects by a degree value in time O(n + m) using counting sort. As here it is only necessary to sort up to k objects we can sort these objects in O(k log k). This allows us to reach an overall time bound of O(min{k log k, n + k}). We will give a short overview of the steps of the algorithm. For an exhaustive analysis we refer to [1].
First we identify all vertices that are incident to an edge in F. Then we sort these vertices due their degrees in G. This takes O(min{k log k, n + k}) many steps. Now, we remove the edges of F incident to the first vertex of our ordering and update the ordering of the vertices in time linear in the number of deleted edges. Iterating this process leads to an edge elimination scheme. In order to turn this elimination scheme into a degree-minimal edge elimination scheme, we have to sort the edges that are deleted at the same vertex by the degree of their second vertex. This can be done in O(min{k log k, n + k}) when sorting all edges together.  This example shows why the usage of the reverse of a degree-minimal edge elimination scheme as an edge addition scheme is a problem. Black vertices belong to k i=1 U i and white vertices belong to k i=1 I i . The order of the vertices respects the order of their corresponding sets in the threshold partition. The edges of the graph are not depicted but given implicitly by the threshold partition. The thick edges are elements of the set F, which we want to add to the graph Proof As described above, we first compute a degree-minimal edge elimination scheme of F from G in time O(min{k log k, n + k}). Then we delete the edges following this scheme using the algorithms given by Lemmas 3.5 and 4.4. If the graph G − F is still a threshold (chain) graph, then this procedure results in a threshold (chain) data structure of G − F.
It remains to show that otherwise the returned vertices induce a forbidden subgraph in G − F. If the algorithms described in Lemmas 3.5 and 4.4 fail to remove the edge e, then all edges in F that are not already deleted are degree-greater than e in the currently considered graph. Therefore, it follows from Lemmas 3.5 and 4.4 that the returned vertices also induce a forbidden subgraph in G − F.
For the addition of the edges contained in a set F but not in the graph G we could use the following algorithm: We compute a degree-minimal edge elimination scheme of the set F from the graph G + F. If G + F is a threshold graph (chain graph), then all intermediate graphs of this elimination scheme must be threshold graphs (chain graphs). Therefore, we can use the reverse ordering as an edge addition scheme of the set F to the graph G. If G + F is not threshold (not chain), then in the reverse ordering there must be an edge which cannot be added to the graph such that it remains a threshold graph (chain graph). However, the forbidden subgraph returned by the algorithm proposed in Lemmas 3.6 and 4.5 does not have to be an induced subgraph of G + F. An example for threshold graphs is given in Fig. 6. The threshold graph G is given by its threshold partition. The edge set F is marked with thick lines. The graph G + F is not threshold. A possible degree-minimal edge elimination scheme of F from G + F is (vw, uy, vy). Therefore, our addition scheme would add vy to G first. The algorithm of Lemma 3.6 would reject this addition and would return the path (w, x, v, y) which is an induced P 4 in G + vy. However, the four vertices do not induce a forbidden subgraph in G + F since the edge vw is in F.
To solve this problem we consider degree-maximal addition schemes. We will now show that in such an addition scheme every intermediate graph is a threshold or chain graph if the initial and the final graph are threshold or chain graphs.
The following observation for degree-maximal edges will be helpful for this. It follows directly from the definition of degree-maximal edges.

Observation 5.8 Let G be a graph, F be a set of edges of G, and x y a degree-maximal edge in F. Then, for every edge x z ∈ F, we have d G (z) ≤ d G (y).
In the following two propositions we will show that a degree-maximal edge in F can be added to a threshold or chain graph without leaving the respective graph class. Proposition 5.9 Let G = (V , E) be a threshold graph and F be a set of non-edges of G such that G + F is a threshold graph. Then for any degree-maximal edge e ∈ F it holds that G + e is a threshold graph.
Proof Let e = x y and assume for contradiction that G + e would not be a threshold graph. Then there must be an induced P 4 , 2K 2 or C 4 in G + e. If the addition of e leads to an induced C 4 in G, then G must contain an induced P 4 , which is a contradiction to the fact that G is a threshold graph. Thus, we can assume that G + e contains a P 4 or 2K 2 . First we consider the case of a P 4 . Without loss of generality, we may assume that the path has the form (a, b, x, y) since G does not contain a 2K 2 . Since G + F is a threshold graph, F must contain ax or by. Due to Lemma 2.1, it holds that d G (b) is larger than both d G (a) and d G (x) since b is adjacent to both a and x in G, whereas a and x are not adjacent. Furthermore, d G (y) is smaller than min{d G (a), d G (x)} since y is not adjacent to b. Thus, x y cannot be degree-maximal in F, due to Observation 5.8. Now assume that G + e contains an induced 2K 2 containing the edges ab and x y. Due to Lemma 2.1, both d G (a) and d G (b) are greater than max{d G (x), d G (y)}. Since G + F is a threshold graph, F contains an edge with one endpoint in {a, b} and one endpoint in {x, y}. Thus, the edge x y is not degree-maximal in F, due to Observation 5.8.

Proposition 5.10 Let G = (A ∪ B, E) be a chain graph and F be a set of non-edges of G such that G + F is a chain graph. Then for any degree-maximal edge e ∈ F it holds that G + e is a chain graph.
Proof Let e = x y and assume for contradiction that G + e is not a chain graph. If G + e contains an odd cycle, then there is also an odd cycle in G + F; a contradiction. Therefore, we can assume that G + e contains a 2K 2 containing the edges ab and x y with a, x ∈ A and b, y ∈ B. Since G + F does not contain an induced 2K 2 , either xb or ay must be part of F. Due to Lemma 2.1, it holds that d G (x) < d G (a) and d G (y) < d G (b). Due to Observation 5.8, x y was not degree-maximal in F; a contradiction.
In order to compute a degree-maximal edge addition scheme using only O(min{k log k, n + k}) many steps, we can use a modified version of the algorithm that computes the degree-minimal edge elimination scheme. The following theorem follows from Lemmas 3.6 and 4.5 as well as Propositions 5.9 and 5.10.

Theorem 5.11
Let G = (V , E) be a threshold graph (chain graph) with a threshold (chain) data structure and let F be a set of non-edges of G. There is an algorithm that returns either a threshold (chain) data structure of G + F or returns a constant number of vertices of G that induce a forbidden subgraph in G + F. This algorithm runs in time O(min{k log k, n + k}).
Proof Similar to Theorem 5.6, we compute a degree-maximal addition scheme of F to G and then add the edges of F one by one following this scheme using the algorithms given by Lemma 3.6 and 4.5. Following from Propositions 5.9 and 5.10, the algorithms return a threshold (chain) data structure of G + F if and only if G + F is a threshold (chain) graph.
If the respective algorithm fails to add an edge e, then G + F is not a threshold (chain) graph. If G is a threshold graph, then, due to Lemma 3.6, the returned set of vertices induces a forbidden subgraph in G + F since the edges following in the addition scheme are degree-lower than edge e. If G is a chain graph, then by Lemma 4.5 the algorithm can find a set of vertices, that induced a forbidden subgraph in G + F needing time O(|F|).

Fully Dynamic Algorithms for Hamiltonian Cycles and Paths
In this section we present fully dynamic algorithms that decide for a given threshold graph or a given chain graph whether it has a Hamiltonian cycle or a Hamiltonian path. Similar to the algorithms in the former sections these algorithms can handle updates until the graph leaves the corresponding graph class. However, the graph is not forced to stay Hamiltonian during the process, i.e., some of the intermediate graphs can have a Hamiltonian cycle or path while others have no such cycle or path.
We will first characterize when a threshold graph or a chain graph has such a cycle or path using the threshold partition and chain partition. Afterwards, we will explain how we can use these characterizations algorithmically. Note that threshold graphs with Hamiltonian cycles have already been characterized by Harary and Peled [12].
The following observation holds for all graphs and is well known. The following four lemmas characterize threshold and chain graphs that contain a Hamiltonian cycle or path. The proofs of the lemmas are constructive, i.e., we will explain how to find the cycle or path in the positive case and we will give a cut set contradicting Observation 6.1 for the negative case. For both cases we will show that the respective certificate can be found in time O(n). We start by characterizing those threshold graphs which contain a Hamiltonian path.
There is an algorithm that finds a Hamiltonian path or a set S ⊂ V where G − S has more than |S| + 1 components in time O(n).
hold for i ∈ {2, . . . , k}, we choose set S = k j=i U j . In G − S every element of I * = k j=i I j is isolated. Since |I * | + 1 > |S| and the elements of I 1 and U 1 form their own component, G − S has more than |S| components. Due to Observation 6.1, G does not contain a Hamiltonian cycle. If the third statement does not hold, we choose S = k j=1 U j . Then G − S contains more than |S| components. Similar to the proof of Lemma 6.2, both the construction of the Hamiltonian cycle and of the set S can be implemented in time O(n).
Due to the close relation between threshold and chain graphs, there are similar characterizations for chain graphs which have a Hamiltonian cycle or a Hamiltonian path. Lemma 6.4 Let G = (V , E) be a chain graph and let P = (A 1 , B 1 , . . . , A k , B k , I ) be the corresponding chain partition. The graph G has a Hamiltonian path if and only if the following conditions hold: There is an algorithm that finds a Hamiltonian path or a set S ⊂ V where G − S has more than |S| + 1 components in time O(n).
Proof Assume that all four statements hold. First we consider the case that k j=1 |B j | ≤ k j=1 |A j |. We start in a vertex of A k . Due to Condition 2, we can visit all vertices in k j=2 A j by alternating between these vertices and their neighbors in the sets B 2 , . . . , B k and end in a vertex of B 2 . The number of visited vertices in A-sets and B-sets is identical at this point. Due to Condition 4, the number of unvisited vertices in B-sets is either |A 1 | − 1 or |A 1 |. Therefore, we can visit all vertices in A 1 and all remaining vertices in B.
It remains to show that for k j=1 |B j | = k j=1 |A j |+1 there is also a Hamiltonian path. In this case, it holds that |B k | > |A k | due to Condition 3 for i = k −1. Therefore, we can start in a vertex of B k and visit all vertices of A k . Following the same argument as in the first case, we find a Hamiltonian path. Now assume that G does not fulfill one of the statements. If I = ∅, then G is connected and we can return S = ∅. If the second statement does not hold for i ∈ {2, . . . , k}, then we choose S = k j=i B j . If the third statement does not hold, then we choose S = i j=1 A j . If the fourth statement does not hold, we put all vertices of the smaller partition set into the set S. In all cases, the graph G − S contains more than |S| + 1 components.
Similar to the proof of Lemma 6.2, both the construction of the Hamiltonian path and of the set S can be implemented in time O(n). Lemma 6.5 Let G = (V , E) be a chain graph and let P = (A 1 , B 1 , . . . , A k , B k , I ) be the corresponding chain partition. The graph G has a Hamiltonian cycle if and only if the following conditions hold: There is an algorithm that finds a Hamiltonian path or a set S ⊂ V where G − S has more than max{1, |S|} components in time O(n).

Proof
The proof follows a similar chain of arguments as the proof of Lemma 6.3. If the three conditions hold, then we start in a vertex of B k and visit all vertices in A k first, alternating with vertices from B k . Iterating this procedure also for the other A-sets and using Conditions 2 and 3 we can visit all vertices in A and B. After visiting the last vertex in A 1 , we go back to our starting vertex in B k . Since Condition 3 holds with equality, all vertices are contained in the cycle.
If the first statement does not hold, then we set S = ∅. If the second statement does not hold for i ∈ {2, . . . , k}, then we set S = k j=i B j . If the last statement does not hold, we add all vertices of the smaller partition set to the set S. In all three cases, the graph G − S contains more than max{1, |S|} components.
Similar to the proof of Lemma 6.2, both the construction of the Hamiltonian cycle and of the set S can be implemented in time O(n).
Using the above characterizations and the results of Sect. 3, we can formulate a fully dynamic algorithm on threshold graphs and chain graphs for both Hamiltonian paths and cycles. Theorem 6.6 There are fully dynamic algorithms for the Hamiltonian cycle problem and the Hamiltonian path problem on threshold graphs and chain graphs which have the following costs: Proof We will prove this theorem for threshold graphs; the algorithms for chain graphs work analogously and their correctness and running time can be shown in the same way. We use the threshold data structure defined in Definition 3.4. Let P = (I 1 , U 1 , . . . , U k , I k+1 ) be the threshold partition of the threshold graph G. For every set U i we introduce a variable α i storing the number i j=1 |I j | and for every set I i we have a variable β i storing the number k j=i |U j |. This ensures that every set only counts vertices that are adjacent to the elements of the set. Furthermore, we store the total size γ of the U -sets and the total size δ of the I -sets. In order to check whether G has a Hamiltonian cycle or a Hamiltonian path, we have to compare γ and δ. Furthermore, for every set I i and U i we have to compare β i and γ − α i + |I i | as stated in Lemmas 6.2 and 6.3. Since we also want to handle threshold graphs without a Hamiltonian cycle or a Hamiltonian path, we introduce a variable ζ which counts the number of pairs U i and I i whose values α i and β i do not fulfill the given constraint. Whenever we update αor β-values we check whether the status of the corresponding constraint has changed. If this is the case we increase or decrease ζ . Therefore, the graph has a Hamiltonian cycle or Hamiltonian path if and only if ζ = 0, I k+1 is empty and the constraint on γ and δ is fulfilled.
If we delete an edge from G or add an edge to G, we apply the operations described in the proofs of the Lemmas 3.5 and 3.6. As one can see there is only a constant number of variables α i and β i which have to be updated. Furthermore, we have to update γ and δ. For the addition and deletion of whole sets of edges we use the algorithms described in Theorems 5.6 and 5.11.
If we delete a vertex z of a U -set, we only have to update the variables of I -sets that are to the left of it in P. All elements of these sets are neighbors of z and, therefore, it only uses O(|N (z)|) operations. If we delete an element z of an I -set, we only have to update the variables of U -sets to the right of it and their elements are neighbors of z. Thus, the number of operations is also in O (|N (z)|).
For the addition of a vertex we consider the operations in the proof of Lemma 3.7. Here, we only have to update sets whose elements are neighbors of the new vertex z. Therefore, these operation can also be done in time O(d), where d is the number of neighbors of z.

Conclusion
In this paper we have presented optimal fully dynamic recognition algorithms for the classes of threshold and chain graphs, which additionally yield a constant size certificate in the negative case. Furthermore, we expand on the idea of a fully dynamic algorithm by giving efficient routines for the addition and deletion of sets of vertices or edges. Using the techniques developed for these algorithms, it was also possible to state fully dynamic algorithms for the Hamiltonian path and cycle problems for both of these classes. These algorithms have the same running times as the recognition algorithms and return certificates in the negative case which are of size O(n) and can also be checked in time O(n).
Some open questions remain. While our algorithms are able to decide whether a modified graph has a Hamiltonian path or cycle, it is not yet possible to give a fully dynamic update on the path or cycle itself. Therefore, it is an interesting question whether there exists a data structure to keep track of the cycle or the path efficiently on these graph classes while adding or removing vertices and edges.
To the best of our knowledge the problem of dynamically solving the Hamiltonian cycle and path problems has not been considered so far. Thus, a natural question is whether one can find efficient dynamic algorithms for these problems on other graph classes. Clearly, only graph classes for which these problems can be solved efficiently in a non-dynamic way are candidates. Examples for such graph classes are cographs and interval graphs.
Similarly, the addition or deletion of whole sets of edges does not seem to have been considered so far. It is an interesting question whether similar approaches can be implemented for other graph classes, especially graph classes that are not sandwich monotone.
In the light of these results, one can also ask whether further graph problems can be solved efficiently in a dynamic way on threshold or chain graphs. A possible candidate could be a dynamic algorithm for the max cut problem on threshold graphs.