Computing and Listing Avoidable Vertices and Paths

A simplicial vertex of a graph is a vertex whose neighborhood is a clique. It is known that listing all simplicial vertices can be done in $O(nm)$ time or $O(n^{\omega})$ time, where $O(n^{\omega})$ is the time needed to perform a fast matrix multiplication. The notion of avoidable vertices generalizes the concept of simplicial vertices in the following way: a vertex $u$ is avoidable if every induced path on three vertices with middle vertex $u$ is contained in an induced cycle. We present algorithms for listing all avoidable vertices of a graph through the notion of minimal triangulations and common neighborhood detection. In particular we give algorithms with running times $O(n^{2}m)$ and $O(n^{1+\omega})$, respectively. Additionally, based on a simplified graph traversal we propose a fast algorithm that runs in time $O(n^2 + m^2)$ and matches the corresponding running time of listing all simplicial vertices on sparse graphs with $m=O(n)$. Moreover, we show that our algorithms cannot be improved significantly, as we prove that under plausible complexity assumptions there is no truly subquadratic algorithm for recognizing an avoidable vertex. To complement our results, we consider their natural generalizations of avoidable edges and avoidable paths. We propose an $O(nm)$-time algorithm that recognizes whether a given induced path is avoidable.


Introduction
Closely related to chordal graphs is the notion of a simplicial vertex, that is a vertex whose neighborhood induces a clique.In particular, Dirac [13] proved that every chordal graph admits a simplicial vertex.However not all graphs contain a simplicial vertex.Due to their importance to several algorithmic problems, such as finding a maximum clique or computing the chromatic number, it is natural to seek for fast algorithms that list all simplicial vertices of a graph.For doing so, the naive approach takes O(nm) time, whereas the fastest algorithms take advantage of computing the square of an n × n binary matrix and run in O(n ω ) and O(m 2ω/(ω+1) ) time [19].Hereafter we assume that we are given a graph G on n vertices and m edges; currently, ω < 2.37286 [2].
A natural way to generalize the concept of simplicial vertices is the notion of an avoidable vertex.A vertex u is avoidable if either there is no induced path on three vertices with middle vertex u, or every induced path on three vertices with middle vertex u is contained in an induced cycle.Thus every simplicial vertex is avoidable, however the converse is not necessarily true.As opposed to simplicial vertices, it is known that every graph contains an avoidable vertex [1,7,5,22].Extending the notion of avoidable vertices is achieved through avoidable edges and, more general, avoidable paths.This is accomplished by replacing the middle vertex in an induced path on three vertices by an induced path on arbitrary k ≥ 2 vertices, denoted by P k .Beisegel et al. [3] proved first that every non-edgeless graph contains an avoidable edge, considering the case of k = 2. Regarding the existence of an avoidable induced path of arbitrary length, Bonamy et al. [9] settled a conjecture in [3] and showed that every graph is either P k -free or contains an avoidable P k .Gurvich et al. [15] strengthened the later result by showing that every induced path can be shifted in an avoidable path, in the sense that there is a sequence of neighboring induced paths of the same length.Although the provided proof in [15] is constructive and identifies an avoidable path given an induced path, the proposed algorithm was not settled whether it runs in polynomial time.
Since avoidable vertices generalize simplicial vertices, it is expected that avoidable vertices find applications in further algorithmic problems.Indeed, Beisegel et al. [3] revealed new polynomially solvable cases of the maximum weight clique problem that take advantage of the notion of avoidable vertices.Similar to simplicial vertices, the complexity of a problem can be reduced by removing avoidable vertices, tackling the problem on the reduced graph.It is therefore of interest to list all avoidable vertices efficiently.If we are only interested in computing two avoidable vertices this can be done in linear time by using fast graph searches [5,3].However, an efficient elimination process, such as deleting or removing avoidable vertices, is not enough to recursively compute the rest of the avoidable vertices.Thus, computing the set of all avoidable vertices requires to decide for each vertex of the graph whether it is avoidable and a usual graph search cannot guarantee to test all vertices.
Concerning lower bounds, it is known [20] that the problem of finding a triangle in an n-vertex graph can be reduced in O(n 2 ) time to the problem of counting the number of simplicial vertices in an O(n)-vertex graph.Moreover, Ducoffe proved that under plausible complexity assumptions computing the diameter of an AT-free graph is at least as hard as computing a simplicial vertex [14].For general graphs, the quadratic time complexity of diameter computation cannot be improved by much [23].We note that the currently fastest algorithms for detecting a triangle run in O(nm) time and O(n ω ) time [18].Notably, we show a similar lower bound for recognizing an avoidable vertex.In particular, via a reduction form the Orthogonal-Vector problem, we prove that under the Strong Exponential-Time Hypothesis, there is no truly subquadratic algorithm for deciding whether a given vertex is avoidable.This gives a strong evidence that our O(nm)-and O(n ω )-recognition algorithms upon which are based our listing algorithms cannot be improved significantly.
A naive approach that recognizes a single vertex u of a graph G of whether it is avoidable or not, needs to check if all neighbors of u are pairwise connected in an induced subgraph of G. Thus the running time of recognizing an avoidable vertex is O(n 3 + n 2 m) or, as explicitly stated in [3], it can be expressed as O(m • (n + m)) where m is the number of edges in the complement of G. Inspired by both running times, we first show that we can reduce in linear time the listing problem on a graph G having m ≥ n and m ≥ n.In a sense such a result states that graphs that are sparse (m < n) or dense (m < n) can be decomposed efficiently to smaller connected graphs for which their complement is also connected.Towards this direction, we give an interesting connection with the avoidable vertices on the complement of G.As a result, the naive algorithms for listing all avoidable vertices take O(n 3 • m) and O(n • m • m) time, respectively.Moreover, based on the proposed reduction we derive an optimal, linear-time, algorithm for listing all avoidable vertices on graphs having no induced path on four vertices, known as cographs.
Our main results consist of new algorithms for listing all avoidable vertices in running times comparable to the ones for listing simplicial vertices.More precisely, we propose three main approaches that result in algorithms for listing all avoidable vertices of a graph G with the following running times: • O(n 2 • m), by using a minimal triangulation of G.A close relationship between avoidable vertices and minimal triangulation was already known [3].However, listing all avoidable vertices through the proposed characterization is inefficient, since one has to produce all possible minimal triangulations of G.Here we strengthen such a characterization in the sense that it provides an efficient recognition based on one particular minimal triangulation of G.More precisely, we take advantage of vertex-incremental minimal triangulations that can be computed in O(nm) time [8].
• O(n 2 + m 2 ), by exploring structural properties on each edge of G.This approach is based on a modified, traditional breadth-first search algorithm.Our task is to construct search trees rooted at a particular vertex that reach all vertices of a predescribed set S, so that every non-leaf vertex does not belong to S. If such a tree exists then every path from the root to a leaf that belongs to S is called an S-excluded path.It turns out that S-excluded paths can be tested in linear time and we need to make 2m calls of a modified breadth-first search algorithm.
• O(n 1+ω ), where O(n ω ) is the running time for matrix multiplication.For applying a matrix multiplication approach, we contract the connected components of G that are outside the closed neighborhood of a vertex.Then we observe that a vertex u is avoidable if the neighbors of u are pairwise in distance at most two in the contracted graph.As the distance testing can be encapsulated by the square of its adjacency matrix, we deduce an algorithm that takes advantage of a fast matrix multiplication.
We should note that each of the stated algorithms is able to recognize if a given vertex , and O(n ω ), respectively, where d(u) is the degree of u in G. Further, all of our proposed algorithms are characterized by their simplicitiy and, besides the fast matrix multiplication, consist of basic ingredients that avoid using sophisticated data structures.
In addition, we consider the natural generalizations of avoidable vertices, captured within the notions of the avoidable edges and avoidable paths.A naive algorithm that recognizes an avoidable edge takes time O(n 2 • m) or O(m • m).Here we show that recognizing an avoidable edge of a graph G can be done in O(n • m) time.This is achieved by taking advantage of the notions of the S-excluded paths and their efficient detection by the modified breadth-first search algorithm.Also notice that an avoidable edge is an avoidable path on two vertices.We are able to reduce the problem of recognizing an avoidable path of arbitrary length to the recognition of an avoidable edge.In particular, given an induced path we prove that we can replace the induced path by an edge and test whether the new added edge is avoidable or not in a reduced graph.Therefore our recognition algorithm for testing whether a given induced path is avoidable takes O(n • m) time.As a side remark of the later algorithm, we partially resolve an open question raised in [15].In particular, [15] asks whether their algorithm for identifying an avoidable path given an induced path, runs in polynomial time.Our result implies that if the given path is avoidable then their algorithm runs in polynomial time.

Preliminaries
All graphs considered here are finite undirected graphs without loops and multiple edges.We refer to the textbook by Bondy and Murty [10] for any undefined graph terminology.For a graph G = (V G , E G ), we use V G and E G to denote the set of vertices and edges, respectively.We use n to denote the number of vertices of a graph and use m for the number of edges.Given x ∈ V G , we denote by N G (x) the neighborhood of x.The degree of x is the number of edges incident to x, denoted by Given X ⊆ V G , we denote by G − X the graph obtained from G by the removal of the vertices of X.If X = {u}, we also write G − u.The subgraph induced by X is denoted by G[X], and has X as its vertex set and {uv | u, v ∈ X and uv ∈ E G } as its edge set.
A clique of G is a set of pairwise adjacent vertices of G, and a maximal clique of G is a clique of G that is not properly contained in any clique of G.An independent set of G is a set of pairwise non-adjacent vertices of G.The induced path on k ≥ 2 vertices is denoted by P k and the induced cycle on k ≥ 3 vertices is denoted by C k .For an induced path P k , the vertices of degree one are called endpoints.
A vertex of degree one is called leaf.A graph is connected if there is a path between any pair of vertices.A connected component of G is a maximal connected subgraph of G.For any two vertices x and y of a connected graph there is an induced path having x and y as endpoints.Given two vertices u and v of a connected graph G, a set S ⊂ V G is called (u, v)-separator if u and v belong to different connected components of G − S. We say that S is a separator if there exist two vertices u and v such that S is a (u, v)-separator.For a set of finite graphs H, we say that a graph G is H-free if G does not contain an induced subgraph isomorphic to any of the graphs of H.
The disjoint union of two graphs G and H, denoted by G ∪ H, is the graph on vertex set V (G) ∪ V (H) and edge set E(G) ∪ E(H).The complement of G, denoted by G, is the graph on vertex set V (G) and edge set {uv | uv / ∈ E(G)}.We say that a graph Given an edge e = xy, the contraction of e removes both x and y and replaces them by a new vertex w, which is made adjacent to those vertices that were adjacent to at least one of the vertices x and y, that is N (w) = (N (x)∪N (y))\{x, y}.Let S be a vertex set of G such that G[S] is connected.If we repeatedly contract an edge of G[S] until one vertex remains in S then we say that we contract S into a single vertex.In different terminology, contracting a set of vertices S is the operation of substituting the vertices of S by a new vertex w with N (w) = N (S).
A vertex v is called simplicial if the vertices of N G (v) induce a clique.Listing all simplicial vertices of a graph can be done O(nm) time.The fastest algorithm for listing all simplicial vertices takes time O(n ω ), where O(n ω ) is the time needed to multiply two n×n binary matrices [19] (currently, ω < 2.37286 [2]).Avoidable vertices and edges generalize the concept of simplicial vertices in a natural way.Definition 1.A vertex v is called avoidable if every P 3 with middle vertex v is contained in an induced cycle.Equivalently, v is avoidable if d G (v) ≤ 1 or for every pair x, y ∈ N G (v) the vertices x and y belong to the same connected component of Every simplicial vertex is avoidable, however the converse is not necessarily true.It is known that every graph contains an avoidable vertex [1,7,22].Every vertex of a graph of degree ≤ 1 is simplicial and hence avoidable.Thus a non-avoidable vertex of a graph, has degree ≥ 2.
Observation 1.Let G be a graph and let u be a vertex of G. Then u is non-avoidable if and only if there is an (x, y)-separator S that contains u such that S ⊂ N G [u] for some vertices x, y ∈ N G (u).
Proof.Assume that u is non-avoidable.Then by Definition 1, there are two vertices x, y ∈ N G (u) that belong to different connected components in G − (N G [u] \ {x, y}).This means that S = N G [u] \ {x, y} is an (x, y)-separator.On the other hand, if there is such a separator S for some vertices x, y ∈ N G (u) then x and y do not belong to the same connected component in the graph G − S and, consequently, also in the graph Thus u is non-avoidable vertex.

A Lower Bound for Recognizing an Avoidable Vertex
In the forthcoming sections, we give algorithms for recognizing an avoidable vertex in O(nm) time and O(n ω ) time.Here we show that, under plausible complexity assumptions, a significant improvement on the stated running times is unlikely, as we show that there is no truly subquadratic algorithm for deciding whether a given vertex is avoidable.By truly subquadratic, we mean an algorithm with running time O(n 2− ), for some > 0 where n is the size of its input.
More precisely, the Strong Exponential-Time Hypothesis (SETH) states that for any > 0, there exists a k such that the k-SAT problem on n variables cannot be solved in O((2 − ) n ) time [17].The Orthogonal-Vector problem (OV) takes as input two families A and B of n sets over a universe C, and asks whether there exist a ∈ A and b ∈ B such that a ∩ b = ∅.An instance of OV is denoted by OV (A, B, C).It is known that under SETH, for any > 0, there exists a constant c > 0 such that For deciding whether a given vertex is avoidable, we give a reduction from OV.
Theorem 2. The OV problem with |A| = |B| = n can be reduced in O(n log n) time to the problem of deciding whether a particular vertex of an O(n)-vertex graph is avoidable.
Proof.Let OV (A, B, C) be an instance of OV.We construct a graph G as follows.The vertex set of G consists of A ∪ B ∪ C and three additional vertices u, c A , c B .For the edges of G, we have: • c A is adjacent to every vertex of A and c B is adjacent to every vertex of B; • for every a ∈ A and every c ∈ C, ac ∈ E(G) if and only if c ∈ a; • for every b ∈ B and every c ∈ C, bc ∈ E(G) if and only if c ∈ b.
These are exactly the edges of G.In particular notice that G[C ∪ {u, c A , c B }] is an independent set.Moreover, observe that G has 2n + |C| + 3 vertices and the number of edges is O(n log n).We claim that OV (A, B, C) is a yes-instance if and only if u is non-avoidable in G.
Assume that there are sets a ∈ A and b ∈ B such that a ∩ b = ∅.Let x ∈ A and y ∈ B be the vertices of A and B that correspond to a and b, respectively.By construction, x and y are non-adjacent in G.Moreover, by construction, x and y have no common neighbor in C, as a ∩ b = ∅.Now notice that all neighbors of x and y that do not belong to For the converse, assume that which is not possible.Similarly, both x and y do not belong to B due to vertex c B .Thus x ∈ A and y ∈ B. As there are no edges in G[C ∪ {c A , c B }] we deduce that x and y have no common neighbor in C. Hence there are sets in A and B that correspond to the vertices x and y, respectively, that have no common element.Therefore OV (A, B, C) is a yes-instance.

Detecting Avoidable Vertices in Sparse or Dense Graphs
Here we show how to compute efficiently all avoidable vertices on sparse or dense graphs.In particular, for a graph G on n vertices and m edges, we consider the cases in which m < n (sparse graphs) or m < n (dense graphs), where m = |E(G)|.Our main motivation comes from the naive algorithm that lists all avoidable vertices in O(n advantage of the non-edges of G [3].We will show that we can handle the non-edges in linear time, so that the running time of the naive algorithm can be written as O(n 3 • m).For doing so, we consider the behavior of avoidable vertices on the complement of a graph by considering the connected components in both G and G. Before reaching the details of our approach, we give a simple linear-time algorithm on the class of cographs, since they can be totally decomposed by the corresponding operations.

Appetizer: an optimal algorithm on cographs
A graph G is cograph if every induced subgraph of G on at least two vertices is either disconnected or its complement is disconnected.Cographs are exactly the class of P 4 -free graphs [11].Every cograph G admits a unique tree representation known as cotree which is a rooted tree T with two types of internal nodes: 0-nodes and 1-nodes.The vertices of G are assigned to the leaves of T in a one-to-one manner.Thus T contains O(n) nodes.The properties of a cotree T are summarized as follows: (i) Two vertices of G are adjacent if and only if their least common ancestor in T is a 1-node.
(ii) Every internal node of T has at least two children.
(iii) No two internal nodes of the same type are adjacent in T .
The cotree of a cograph is unique and can be generated in linear time [12].We give the following characterization of avoidable vertices in G in terms of the cotree T .For doing so, we denote by p(u) the parent of a vertex u in T .A 1-node w of T is called full 1-node if the children of w are all leaves in T .Lemma 3. Let T be a cotree of a cograph G and let u be a vertex of G.Then, u is avoidable in G if and only if either p(u) is a 0-node or p(u) is a full 1-node.
Proof.We first introduce some notation.For a node w of T , we let T w be the subtree of T rooted at w and we denote by V (T w ) the set of leaves in T w .Recall that V (T w ) corresponds to a subset of vertices of G.By property (i) observe that all the vertices of V (T w ) are either adjacent or non-adjacent to a vertex x of V (G) \ V (T w ).Let r be the root of T and let w be the parent node of vertex u, that is w = p(u).We consider separately the following cases (see Figure 1).
• Assume that w is a 0-node in T .We show that u is avoidable in G. Consider two vertices x, y ∈ N G (u).By property (i), x, y ∈ V (T r ) \ V (T w ) and any vertex of V (T w ) is nonadjacent to u.Moreover, property (ii) implies that there is a vertex a ∈ V (T w ) \ {u} such that au / ∈ E(G).Thus, both x and y are adjacent to u and a, since x, y / ∈ V (T w ).Hence, regardless of whether x and y being adjacent, there is a path between x and y that does not contain any vertex of N G (u).
• Assume that w is a full 1-node in T .We show that u is avoidable in G. Consider two vertices x, y ∈ N G (u).If x ∈ V (T w ) then xy ∈ E(G) because either y ∈ V (T w ) as a leaf vertex, or y / ∈ V (T w ) and y is adjacent to every vertex of V (T w ) as uy ∈ E(G).Suppose that both x, y ∈ V (T r ) \ V (T w ).Let P (r, w) be the unique path of T between the root r and the 1-node w.Since x, y ∈ N G (u), there are 1-nodes w x and w y (not necessarily distinct) on P (r, w) such that x ∈ V (T wx ) and y ∈ V (T wy ).Now consider the parent w of w in T .By property (iii), w exists and is a 0-node of T .Thus there is a vertex a ∈ V (T w ) \ V (T w ) that is non-adjacent to u.Since the least common ancestor of x and a is w x , by property (i) we have xa ∈ E(G).Similarly, we have ya ∈ E(G).Hence there is a path between x and y that contains a non-neighbor of u, which shows that u is an avoidable vertex of G.
• Assume that w is a 1-node that is not full in T .We show that u is non-avoidable in G.
Let w be a non-leaf child of w.By property (iii), w is a 0-node.Moreover, property (ii) implies that there are vertices x, y ∈ V (T w ) for which their least common ancestor is w .Thus xy / ∈ E(G) and ux, uy ∈ E(G), because w is a 1-node.If there is no path between x and y in G − u then u is non-avoidable.Let A be the internal vertices of an induced path between x and y in G − u.Since G is P 4 -free, every vertex of A is adjacent to both x and y, so that A = {a}.We show that u is adjacent to a.To see this, observe that a does not belong to V (T w ), since w is the 0-node that is the least common ancestor of x and y.Hence a belongs to V (T r ) \ V (T w ) and its least common ancestor w a with x and y is a 1-node.This means that w a is an ancestor of w that is a 1-node in T .As w is a child of w, we deduce that w a is the least common ancestor of a and u.Thus ua ∈ E(G), which means that u is non-avoidable, since there is no path between x and y that avoids any neighbor of u.
Therefore, we have a complete characterization of u since all cases have been considered depending on the parent of u in T .Thus, we deduce the following optimal algorithm for the vertices of a cograph G.Note that, given a cograph G, its corresponding cotree T can be constructed in O(n + m) time [12].Theorem 4. Given a cotree T of a cograph G, there is an O(n)-time algorithm that lists all avoidable vertices of G.
Proof.We first mark the internal nodes of the cotree T that have as children only leaves of T .By a single bottom-up traversal from the leaves of T , this can be done in O(n) time.Thus applying Lemma 3 in a straightforward way on the cotree T with the marked information, results in an O(n)-time algorithm.

Sparse or dense graphs
Here we extend the previous notions on cographs and show how to handle the cases in which m < n (sparse graphs) or m < n (dense graphs).
It is not difficult to handle sparse graphs.Observe that m < n implies that G is disconnected or G is a tree.The connectedness assumption of the input graph G follows from the fact that a vertex u is avoidable in G if and only if u is avoidable in the connected component containing u, since there are no paths between vertices of different components.Moreover, trees have a trivial solution as the leaves are exactly the set of avoidable vertices.We include both properties in the following statement.
Observation 5. Let u be a vertex of G and let C(u) be the connected component of G containing u. Then u is avoidable if and only if u is avoidable in G[C(u)].Moreover, if G is a tree then u is avoidable if and only if u is a leaf in G.
Next we describe that we can follow almost the same approach on the complement of G.For doing so, we first prove the following result which interestingly relates avoidability on G and G. Note, however, that the converse is not necessarily true.Lemma 6.Let G be a graph and let u be a non-avoidable vertex.Then, u is avoidable in G.
Proof.Since u is a non-avoidable vertex in G, there is a separator S that contains u such that S ⊂ N G [u] by Observation 1.Let C 1 , . . ., C k be the connected components of G − S, with k ≥ 2. Notice that at least two components of C 1 , . . ., C k contain a neighbor of u.Without loss of generality, assume that Consider the complement G and let x, y be two neighbors of u in G. Observe that both x and y do not belong to S, since S ⊂ N G [u]. Thus x ∈ C i and y ∈ C j , for 1 ≤ i, j ≤ k.We show that either xy ∈ E(G) or there is a path in G between x and y that avoids vertices of Thus in both cases there is a path of length two between x and y that avoids vertices N G (u).Therefore, u is avoidable in G.
We next deal with the case in which G is disconnected.Notice that if G = K n then every vertex of G is simplicial and thus avoidable.Proof.Assume first that C(u) = {u}.Then u is universal in G. Since G = K n , there are vertices x, y such that xy / ∈ E(G).As any path between x and y contains a neighbor of u, we deduce that u is non-avoidable.In the following we assume that |C(u)| > 1.This assumption implies that there is a vertex a ∈ C(u) such that ua / ∈ E(G).Also notice that every vertex of C(u) is adjacent to every vertex of V (G) \ C(u).
• Suppose that u is avoidable in G. Assume for contradiction that u is non-avoidable in G[C(u)].Then there are vertices x, y in C(u) such that x, y ∈ N G (u), xy / ∈ E(G), and every path (if it exists) between x and y in G[C(u)] contains a neighbor of u.Since G[C(u)] is an induced subgraph of G and u is avoidable in G, there is path in G between x and y that contains a vertex z of V (G) \ C(u) such that zu / ∈ E(G).Then, however, we reach a contradiction to the fact that every vertex of C(u) is adjacent to every vertex of . Now assume that both vertices x, y belong to V (G) \ C(u).Then the path x, a, y with a ∈ C(u) and ua / ∈ E(G) is the desired path between x and y.Thus u is avoidable in G.
Therefore both directions show the claimed statement.
In general, avoidability is not a hereditary property with respect to induced subgraphs, even when restricted to the removal of non-avoidable vertices.However, as we show next, the removal of universal vertices does not affect the rest of the graph.Lemma 8. Let G be a graph and let w be a universal vertex of G. Then w is avoidable if and only if G is a complete graph.Moreover, any vertex u ∈ V (G) \ {w} is avoidable in G if and only if u is avoidable in G − w.
Proof.First statement follows by Lemma 7 and from the fact that every vertex of a complete graph is simplicial.For the second statement, assume that u is avoidable in G.We show that u is avoidable in the graph Then, as u is avoidable in G, there is a path P between x and y in G. Since w is universal in G, w does not belong to P .Thus P exists in G which shows that u is avoidable in G .For the reverse direction, assume that u is avoidable in G = G − w.Observe that any two vertices x, y ∈ N G (u) \ {w} fulfill the necessary conditions in G, since G is as induced subgraph of G.Moreover, w ∈ N G (u) and for any vertex x ∈ N G (u) \ {w}, we have wx ∈ E(G).Therefore u remains avoidable in G.
To conclude the cases for which m < n, we next consider graphs whose complement is a tree.By Observation 5 we restrict ourselves on connected graphs.Lemma 9. Let G be a connected graph such that G is a tree T .A vertex u of G is avoidable if and only if u is a non-leaf vertex in T .
Proof.We consider the vertices of T .Let u be a non-leaf vertex of T .Then u is a non-avoidable vertex in G. Thus by Lemma 6 u is avoidable in G.
Now assume that u is a leaf vertex of T , and thus avoidable in G.We prove that u is non-avoidable in G. Since both graphs G and G are connected, u belongs to a P 4 in T [11].Let u, a, x, y be a P 4 in T that contains u.Observe that u is adjacent to every vertex of V (G) \ {a} in G. Consider the vertices x and y of the P 4 for which x, y ∈ N G (u).As xy ∈ E(G), we have xy / ∈ E(G).We show that there is no path between x and y that avoids any neighbor of u in G.If there is a path between x and y then it contains the vertex a and it has the form x, a, y in G.Then, however, notice that ya ∈ E(G) but xa / ∈ E(G) by the induced P 3 = a, x, y in G. Thus u is non-avoidable in G, because of x and y.Therefore, every avoidable vertex of T is non-avoidable in G, since the set of leaves in T are exactly the set of avoidable vertices in G.
Based on the previous results, we can reduce our problem to a graph G that is both connected and co-connected and neither G nor G are isomorphic to trees.To achieve this in linear time we apply known techniques that avoid computing explicitly the complement of G, since we are mainly interested in recursively detecting the components and co-components of G.Such a decomposition, known as the modular decomposition, can be represented by a tree structure, denoted by T (G), of O(n) size and can be computed in linear time [21,25].More precisely, the leaves of T (G) correspond to the vertices of G and every internal node w of T (G) is labeled with three distinct types according to whether the subgraph of G induced by the leaves of the subtree rooted at w is (i) not connected, or (ii) not co-connected, or (iii) connected and co-connected.Moreover the connected components and the co-components of types (i) and (ii), respectively, correspond to the children of w in T (G).Let G be a collection of maximal vertex-disjoint induced subgraphs of G that are both connected and co-connected.Then T (G) determines all graphs of G in linear time.Observe that if G is empty, then G is a cograph.In addition, we call G, typical collection of G if for each graph H ∈ G: • H is connected and co-connected,
The results of this section deduce the following algorithm.
Theorem 10.Let G be a graph and let A(G) be the set of avoidable vertices in G.There is a linear-time algorithm, that • computes a typical collection G of maximal vertex-disjoint induced subgraphs of G and Proof.We first compute T (G) in linear time [21,25].Then we visit all nodes of T (G) starting from the root and move towards the leaves of T (G).We stop each branch when we reach either a leaf for which we include it in A(G), or when we reach a graph of G. Given a node w of T (G), let G w be the graph induced by the leaves of the subtree rooted at w.At each node of T (G) we perform the following steps.
Observe that all universal vertices in G w (that is, |C i | = 1) have been disregarded by Lemma 8.

Computing Avoidable Vertices Directly from G
Here we give two different approaches for computing all avoidable vertices of a given graph G.
Both of them deal with the input graph itself without shrinking any unnecessary information, as opposed to the algorithms given in forthcoming sections.Our first algorithm makes use of notions related to minimal triangulations of G and runs in time O(n 2 m).The second algorithm runs in time O(n 2 + m 2 ) and is based on a modified, traditional breadth-first search algorithm.Let us first explain our algorithm through a minimal triangulation of G.We first need some necessary definitions.A graph is chordal if it does not contain an induced cycle of length more than three.In different terminology, G is chordal if and only if G is (C 4 , C 5 , . ..)-free graph.
A graph H = (V, E ∪ F ) is a minimal triangulation of G = (V, E) if H is chordal and for every F ⊂ F , the graph (V, E ∪ F ) is not chordal.The edges of F in H are called fill edges.Several O(nm)-time algorithms exist for computing a minimal triangulation [4,6,16,24].In connection with avoidable vertices, Beisegel et al. [3] showed the following characterization.

Theorem 11 ([3]
).Let u be a vertex of G. Then u is avoidable in G if and only if u is a simplicial vertex in some minimal triangulation of G.
Although such a characterization is complete, it does not lead to an efficient algorithm for deciding whether a given vertex is avoidable, since one has to produce all possible minimal triangulations of G.Here we strengthen such a characterization in the sense that it provides an efficient recognition based on a particular, nice, minimal triangulation of G.
Lemma 12. Let u be a vertex of a graph G = (V, E) and let H = (V, E ∪ F ) be a minimal triangulation of G such that u is not incident to any edge of F .Then u is avoidable in G if and only if u is simplicial in H.
Proof.If u is simplicial in H then by Theorem 11 we deduce that u is avoidable in G. Suppose that u is non-simplicial in H. Then there are two vertices x, y ∈ N G (u) that are non-adjacent in H. Since G is a subgraph of H, we have xy / ∈ E(G).We claim that there is no path in G between x and y that avoids any vertex of N G [u] \ {x, y}.Assume for contradiction that there is such a path P .Then V (P ) \ {x, y} is non-empty and contains vertices only from V \ N [u].This means that x, y belong to the same connected component of H induced by (V \ N [u]) ∪ {x, y}.As u is non-adjacent to any vertex of V \ N [u] in H, the vertices of (V \ N [u]) ∪ {x, y, u} induce an induced cycle of length at least four in H. Then we reach a contradiction to the chordality of H. Therefore, there is no such path between x and y, which implies that u is non-avoidable in G.
Next we show that such a minimal triangulation with respect to u, always exists and can be computed in O(nm) time.Our approach for computing a nice minimal triangulation of G is vertex incremental, in the following sense.We take the vertices of G one by one in an arbitrary order (v 1 , . . ., v n ), and at step i we compute a minimal triangulation by adding only edges incident to v i .This is possible thanks to the following result.We denote by H(v 1 , . . ., v n ) a vertex incremental minimal triangulation of G which is obtained by considering the vertex ordering (v 1 , . . ., v n ) of G. Computing such a minimal triangulation of G, based on any vertex ordering, can be done in O(nm) time [8].
Consider the vertex ordering (A, u, X).Observe that when adding u to H[A] no fill edge is required, as the considered graph H[A] + u is already chordal.Moreover u is adjacent in G to every vertex appearing after u in the described ordering (A, u, X).Thus u is non-adjacent to any vertex of A in H(A, u, X) which means that no edge of F is incident to u.
A direct consequence of Lemmas 12 and 14 is an O(nm)-time recognition algorithm for deciding whether a given vertex u is avoidable.For every vertex u, we first construct a vertex incremental minimal triangulation H(A, u, X) of G by applying the O(nm)-time algorithm given in [8].Then we simply check whether u is simplicial in the chordal graph H(A, u, X) by Lemma 12, which means that the overall running time is O(nm).
We note that one may compute any minimal triangulation H of G, as a preprocessing step in time O(nm), and then use H for constructing the vertex incremental minimal triangulation Algorithm 1: Testing if u is avoidable with a vertex incremental minimal triangulation Input : A graph G, a minimal triangulation H of G, and a vertex u Output: 3 Add the vertices of X in H in an arbitrary order and maintain a minimal triangulation H of G by applying the O(nm)-time algorithm given in [8]; Although such an approach results within the same theoretical time complexity, in practice it avoids recomputing common parts of the input data.We give the details in Algorithm 1 and, as already explained, its running time is O(nm).By applying Algorithm 1 on each vertex, we obtain the following result.
Theorem 15.Listing all avoidable vertices of G by using Algorithm 1 takes O(n 2 m) time.
An interesting remark of such an approach is that we can list all avoidable vertices of a chordal graph G in an efficient way.We note that such a result can be obtained directly from the definition of an avoidable vertex which shows that a non-simplicial vertex of a chordal graph is non-avoidable.
Corollary 16.Let G be a chordal graph.Listing all avoidable vertices of G can be done in O(n ω ) time, where O(n ω ) is the time required to multiply two n × n binary matrices.
Proof.By Lemma 12 the set of simplicial vertices of G is the set of avoidable vertices because any minimal triangulation H of G contains no fill edge, as G is chordal.Thus listing the avoidable vertices of a chordal graph G reduces to listing the simplicial vertices of G. Therefore detecting all avoidable vertices can be done in O(n ω ) time by using the algorithm of [19], which is the time needed to perform a fast matrix multiplication.

A fast algorithm for listing avoidable vertices
Our second approach is based on the following notion of protecting that we introduce here.Given a set of vertices S ⊆ V , an S-excluded path is a path in which no internal vertex belongs to S. Observe that an edge is an S-excluded path, for any choice of S. By definition a single vertex is connected to itself by the trivial path.Whenever there is an S-excluded path in G between vertices a and b, notice that a can reach b through vertices of V (G) \ S.
Definition 2 (protecting).Let x and y be two vertices of G.We say that x protects y if there is a N G [y]-excluded path between x and every vertex of N G (y).In other words, Let us explain how to check if x protects y in linear time, that is in O(n + m) time.We consider the graph G = G − y and run a slight modification of a breadth-first search algorithm on G starting from x.In particular, we try to reach the vertices of N G (y) \ {x} (target set) from x in G .Every time we encounter a vertex v of the target set, we include v in a set T of discovered target vertices and we do not continue the search from v by avoiding to place v within the search queue.Consequently, no vertex of the target set is a non-leaf node of the constructed search tree.Algorithm 2 shows in detail the considered modification of a breadth-first search.
Algorithm 2: Detecting whether there is an S-excluded path between x and every vertex of S Input : A graph G, a vertex x, and a target set S ⊆ V (G) Output: Returns true iff there is an S-excluded path between x and every vertex of S 1 Initialize a queue Q = {x} and set T = ∅; 2 Mark x; Proof.For the correctness, let T be the search tree discovered by the algorithm when the search starts from x. Observe that the basic concepts of the breadth-first search are maintained, so that the key properties with the shortest paths between the vertices of G and the search tree T are preserved.If there is a leaf vertex v in the constructed tree T such that v S then the unique path in T is an S-excluded path in G between x and v, since no vertex of S is a non-leaf vertex of T .On the other hand, assume that there is an S-excluded path in G between x and every vertex of S. For every v ∈ S, among such S-excluded paths between x and v, choose P (v) to be the shortest.Let p(v) be the neighbor of v in P (v).Clearly x and every vertex p(v) belong to the same connected component of G. Consider the graph G − S. Notice that every vertex p(v) belongs to the same connected component with x in G − S, since for otherwise some vertices of S separate x and a vertex v of S which implies that there is no S-excluded path in G between x and v in G. Now let T x be a breadth-first search tree of G − S that contains x.Then the distance between x and p(v) in T x corresponds to the length of their shortest path in G − S. Construct T by attaching every vertex v of S to be a neighbor of p(v) in T x .Therefore T is a tree that contains the shortest S-excluded paths between x and the vertices of S.
Regarding the running time, notice that no additional data structure is required compared to the classical implementation of the breadth-first search.Hence the running time of Algorithm 2 is bounded by the breadth-first search algorithm which is O(n + m).
Therefore we can check whether x protects y by running Algorithm 2 on the graph G − y with target set S = N G (y) \ {x}.The connection to the avoidability of a vertex, can be seen with the following result.
Lemma 18.Let u be a vertex of a graph G = (V, E).Then u is avoidable in G if and only if x protects u for every vertex x ∈ N G (u).
Proof.Suppose first that u is avoidable.Consider a vertex x ∈ N G (u). Then for any vertex y ∈ N G (u) \ {x} there is a path between x and y that avoids vertices of N G (u).This means that there is an S-excluded path between x and y with S = N G [u]. Thus x protects u in G.
For the other direction, assume that u is non-avoidable.Then there are vertices x, y ∈ N G (u) that belong to different connected components of G − (N G [u] \ {x, y}).Thus x cannot reach y same connected component of G − S. Thus the vertices of P belong to exactly one connected component C P of G − (S ∪ {x, y}).As S ∪ {x, y} = N G [u], there is a vertex C i ∈ C that corresponds to C P in the contracted graph G u (X, C).Hence, the path x, C i , y forms the desired path in G u (X, C) − S.
If there is a path between x and y in G u (X, C) − S then such a path is of length two and has the form x, C i , y where C i ∈ C. Since xC i is an edge in G u (X, C), there is a vertex a ∈ V (C i ) such that xa ∈ E(G).Similarly, there is a vertex b ∈ V (C i ) such that yb ∈ E(G).As a and b belong to the same connected component C i of G − N G [u], there is a path P i in G between a and b that contains only vertices from V (C i ).Thus there is a path x, P i , y in G where P i ⊆ V (C i ).
Now observe that any path between two neighbors of u in either G − S or G u (X, C) − S does not contain any vertex of N G [u].Therefore, by the above claim, we get the desired characterization of u in both graphs.
Lemma 21 implies that we can apply all of our algorithms given in the previous section in order to recognize an avoidable vertex.Although such an approach does not lead to faster theoretical time bounds, in practice the contracted graph has substantial smaller size than the original graph and may lead to practical running times.We next show that the contracted graph results in an additional algorithm with different running time.
Let G u (X, C) be the contracted graph of a vertex u.The filled-contracted graph, denoted by H u (X, C), is the graph obtained from G u (X, C) by adding all necessary edges in order to make every neighborhood of C i ∈ C a clique.That is, for every C i ∈ C, N Hu (C i ) is a clique.The following proof resembles the characterization given through minimal triangulations in Lemma 12. However observe that H u (X, C) is not necessarily a chordal graph, because X N Gu (C).
Proof.We apply Lemma 21 and we need to show that u is avoidable in G u (X, C) if and only if H u [X] is a clique.Assume that u is avoidable in G u (X, C).We show that H u [X] is a clique.Consider two vertices x, y ∈ X.If xy is an edge in G u (X, C) then xy remains an edge in H u (X, C), as G u (X, C) is a subgraph of H u (X, C).If x and y are non-adjacent in G u (X, C), there is a vertex C i ∈ C such that {x, y} ⊆ N Gu (C i ), because u is avoidable and G u [C] is an independent set.Thus, by the definition of H u (X, C), N Hu (C i ) is a clique implying that xy is an edge in H u [X].
Assume that u is non-avoidable in G u (X, C).Then there are vertices x, y ∈ X such that xy / ∈ E(G u ) and they belong in different connected components of G u [C ∪ {x, y}].Thus x and y is a pair of non-adjacent vertices in H u [X], since there is no vertex C i ∈ C such that x, y ∈ N Gu (C i ).Hence there is a pair of non-adjacent vertices in H u [X], so that H u [X] is not a clique.
We take advantage of Lemma 22 in order to recognize whether u is avoidable.The naive construction of H u (X, C) requires O(n 3 ) time, since |X| ≤ n and |C| ≤ n.Instead of constructing H u (X, C), we are able to check H u [X] in an efficient way through matrix multiplication.
To do so, we consider the graph G obtained from G u (X, C) by removing u and deleting every edge with both endpoints in X. Observe that the resulting graph G is a bipartite graph with bipartition (X, C), as G u [C ∪ {u}] is an independent set.It turns out that it is enough to check whether two vertices of X are in distance two in G which can be encapsulated by the square of its adjacency matrix.Algorithm 4 shows in details our proposed approach.
We are now in position to claim the following running time through matrix multiplication.
Observe that x protects y, because x has {c, y, d}-excluded paths to both c and d, and similarly y protects x.However, the edge xy is not protected because, for instance, there is no V (G)-excluded path (and, thus, an edge) between a and d.Also notice that there is a P 4 = a, x, y, d that is not contained in an induced cycle.
Under this terminology, observe that A x ∩ A y = ∅ and N G ({x, y}) is partitioned into the three sets B(x, y), A By Observation 24, the recognition of a simplicial edge can be achieved in O(n + m) time: consider the bipartite subgraph H(A x , A y ) of G[A x ∪ A y ] which is obtained by removing every edge having both endpoints in either A x or A y .Then it is enough to check whether H(A x , A y ) is a complete bipartite graph.
We show that the more general concept of an avoidable edge can be recognized in O(nm) time.For doing so, we will take advantage of Algorithm 2 and the notion of protecting given in Definition 2.
Definition 4 (protected edge).An edge xy is protected if there is an (N G [x] ∪ N G [y])-excluded path between every vertex of N G (x) and every vertex of N G (y).
We note that if an edge xy is protected then x protects y and y protects x in accordance to Definition 2. However, the reverse is not necessarily true, as shown in Figure 2. Proof.Let H = G − B(x, y) and let us first show that xy is an avoidable edge in G if and only if xy is an avoidable edge in H. Suppose that xy is an avoidable edge in G.For any two vertices a ∈ A x and b ∈ A y such that ab / ∈ E(G), there is an induced cycle C that contains a, x, y, b.Now observe that no vertex of B(x, y) belongs to C, as C is an induced cycle in G. Thus xy is an avoidable edge in H.For the converse, notice that H is an induced subgraph of G, so that all induced cycles of H remain induced cycles in G. Therefore our task is to show that xy is an avoidable edge in H if and only if xy is protected in the same graph H.
Suppose that xy is an avoidable edge in H. Observe that N H (x) = A x ∪ {y} and N H (y) = A y ∪ {x}.If at least one of A x , A y is empty then xy is protected (as well as simplicial), because all required (N H [x] ∪ N H [y])-excluded paths have length one between a vertex and its neighbors.Proof.We claim first that there is a P k+2 that contains P k as an internal path in G if and only if there is a P 4 that contains xy as a middle edge in the graph H Assume that there is a P k+2 that contains P k as an internal path in G. Let x and y be the endpoints of P k+2 .As P k+2 is an induced path, both x , y belong to H and x y, xy , x y / ∈ E(H).Thus x , x, y, y is a P 4 in H that contains xy as a middle edge.
Assume that there is a P 4 = x , x, y, y in H that contains xy as a middle edge.Consider the vertices of the path P k−2 of P k − {x, y} in G that correspond to the edge xy of H. Then no vertex of the P k−2 is adjacent to any of x or y by the construction of H. Thus, replacing the edge xy in the P 4 = x , x, y, y by the path P k−2 , results in an induced path P k+2 on k + 2 vertices in G.
Observe that the above claim implies that P k is a simplicial path in G if and only if xy is a simplicial edge in H. Next we show that a non-simplicial path P k with endpoints x and y is avoidable in G if and only if the non-simplicial edge xy is avoidable in H. Assume that there is a P k+2 = x , x, P k−2 , y, y that contains P k = x, P k−2 , y as an internal path in G. Let C G be an induced cycle that contains the P k+2 in G. Since C G is induced cycle, every vertex of C G − P k−2 belongs to H. Now observe that the vertices of C G − P k−2 induce a path in G of length at least four.Hence the vertices of C G − P k−2 induce a cycle in H, since xy ∈ E(H), which shows that xy is avoidable edge in H.
To show that P k is avoidable in G, we show that there is an induced cycle that contains the described P k+2 .Let C H be an induced cycle of H containing a

Concluding Remarks
The running times of our algorithms for listing all avoidable vertices are comparable to the corresponding ones for listing all simplicial vertices.Thus we believe it is difficult to achieve a reduction of the running time for avoidable vertices without affecting the time needed for simplicial vertices.As pointed out, we can detect avoidable vertices in particular graph classes in more efficient way.Towards this direction, it is interesting to consider planar graphs and reveal any possible improvement on the running time.Moreover the notion of protecting and the relative S-excluded paths seem to tackle further problems concerning avoidable structures.Our recognition algorithm for avoidable edges results in an algorithm for listing avoidable edges with running time O(nm 2 ) which is comparable to the O(m 2 )-algorithm for listing avoidable vertices.Regarding avoidable paths on k vertices, one needs to detect first with a naive algorithm a path P k in O(n k ) time and then test whether P k being avoidable or not.As observed in [9], such a detection is nearly optimal, since we can hardly avoid the dependence of the exponent in O(n k ).Therefore by Theorem 26 we get an O(n k+1 • m)-algorithm for listing all avoidable paths on k vertices.
An interesting direction for further research along the avoidable paths is to reveal problems that can be solved efficiently by taking advantage the list of all avoidable paths in a graph.For instance, one could compute a minimum length of a sequence of shifts transforming an induced path P k to an avoidable induced path.Gurvich et al. [15] proved that each induced path can be transformed to an avoidable one by a sequence of shifts, where two induced paths on k vertices are shifts of each other if their union is an induced path on k + 1 vertices.To compute efficiently a minimum length of shifts, one could construct a graph H that encodes all neighboring induced paths on k vertices of G.In particular, the nodes of H correspond to all induced paths on k vertices in G and two nodes in H are adjacent if and only if their union is an induced path on k + 1 vertices in G.Note that H contains O(n k ) nodes and can be constructed in n O(k) time.Having the list of avoidable paths on k vertices, we can mark the nodes of H that correspond to such avoidable paths.Now given an induced path P k on k vertices in G we may ask the shortest path in H from the node that corresponds to P k towards a marked node that corresponds to an avoidable path.Such a path always exists from the results of [15] and can be computed in time linear in the size of H. Therefore, for fixed k, our algorithm computes a minimum length of sequence of shifts in polynomial time answering an open question given in [15].

Figure 1 :
Figure 1: Illustrating the cases considered in the proof of Lemma 3.

Lemma 7 .
Let G = K n , u ∈ V (G), and let C(u) be the co-component containing u.Then, u is avoidable in G if and only if |C(u)| > 1 and u is avoidable in G[C(u)].

3 .
Handling connected and co-connected graphs: (a) If G w = T then A(G w ) = the set of leaves in T by Observation 5. (b) If G w = T then A(G w ) = the set of non-leaves in T by Lemma 9. (c) Otherwise, include G w in the collection G.All steps can be carried out in O(n + m) time by checking the type of the internal node w in T (G) and assigning the components and the co-components with the subtrees of w's children.Testing the corresponding cases whenever G w is connected and co-connected can be done by looking at the number of edges of G w , that is in time O(|V (G w )| + |E(G w )|).Therefore the algorithm outputs in O(n + m) time the described collection G and the set A(G) \ A(G).

Lemma 13 (
[8]).Let G be an arbitrary graph and let H be a minimal triangulation of G.Consider a new graph G = G + v, obtained by adding to G a new vertex v.There is a minimal triangulation H of G such that H − v = H.

Theorem 23 .Figure 2 :
Figure 2: In this example we have NG [x] ∪ N G [y] = V (G).Observe that x protects y, because x has {c, y, d}-excluded paths to both c and d, and similarly y protects x.However, the edge xy is not protected because, for instance, there is no V (G)-excluded path (and, thus, an edge) between a and d.Also notice that there is a P 4 = a, x, y, d that is not contained in an induced cycle.

Lemma 25 .
Let xy be an edge of G. Then xy is an avoidable edge in G if and only if xy is a protected edge in G − B(x, y).
of N G [in(P k )] \ {x, y}.That is, I[P k ] contains the vertices of the internal path of P k and their neighbors outside P k .Given two non-adjacent vertices x and y in G, we denote by G + xy the graph obtained from G by adding the edge xy.Lemma 27.Let P k be an induced path on k vertices of a graph G with k ≥ 3 having endpoints x and y.Then P k is an avoidable path in G if and only if xy is an avoidable edge in G+xy −I[P k ].
P 4 = x , x, y, y .Since xy is a avoidable edge in H, such a cycle exists.Construct the cycle C obtained from C H by removing the edge xy and attaching the path P k−2 of P k − {x, y}.Then C is an induced cycle in G because:• C H − {x, y} is an induced path in G, as H − {x, y} is an induced subgraph of G,• P k is an induced path in G by definition, and• no vertex of P k−2 has a neighbor in C H − {x, y}, as N G (P k−2 ) \ {x, y} ⊂ I[P k ].Therefore there is an induced cycle in G that contains the described P k+2 of P k .Theorem 28.Given an induced path P k on k > 2 vertices of G, testing whether P k is avoidable can be done in O(n • m) time.Proof.Assume that the endpoints of P k are x and y.By Lemma 27, it is enough to check if the edge xy is avoidable in the graph G + xy − I[P k ].Constructing the graph G + xy − I[P k ] takes O(nk) time.Applying the algorithm given in Theorem 26 results in an algorithm with the claimed running time, since k ≤ n.
Observation 24.An edge xy of G is simplicial if and only if A x = ∅ or A y = ∅ or every vertex of A x is adjacent to every vertex of A y .
x , A y .Clearly all described sets can be computed in O(d(x) + d(y)) time.Proof.Consider a P 4 = a, x, y, b that contains xy as a middle edge.Then a ∈ A x and b ∈ A y because ay / ∈ E(G) and xb / ∈ E(G).Thus both sets A x and A y are non-empty.Moreover, since ab /∈ E(G), we deduce that any non-edge with one endpoint in A x and the other in A y results in a P 4 having xy as a middle edge.