Recognition and Optimization Algorithms for P5-Free Graphs

The weighted independent set problem on P5-free graphs has numerous applications, including data mining and dispatching in railways. The recognition of P5-free graphs is executed in polynomial time. Many problems, such as chromatic number and dominating set, are NP-hard in the class of P5-free graphs. The size of a minimum independent feedback vertex set that belongs to a P5-free graph with n vertices can be computed in O(n16) time. The unweighted problems, clique and clique cover, are NP-complete and the independent set is polynomial. In this work, the P5-free graphs using the weak decomposition are characterized, as is the dominating clique, and they are given an O(n(n + m)) recognition algorithm. Additionally, we calculate directly the clique number and the chromatic number; determine in O(n) time, the size of a minimum independent feedback vertex set; and determine in O(n + m) time the number of stability, the dominating number and the minimum clique cover.


Notations, Basics and Applications
Graphs, including the P 5 -free graphs, have many real-life applications, including: preference elicitation applied to a brownfield redevelopment conflict in China [1], evaluation of the energy supply options of a manufacturing plant [2], lifestyle pattern mining based on image collections in smartphones [3] and conflict resolution based on option prioritization [4]. In [5] we point out some applications of bipartite chain graphs in chemistry and approach the minimum chain completion problem. The very large numbers of studies and researchers focused on graphs [6][7][8] outline the importance of this field.
Next we give the terminology used in graph theory that we approach. Throughout this work, G = (V, E) is a connected, undirected, finite, without multiple edges and loops graph [9], where V = V(G) is the vertices set and E = E(G) is the set of edges. G= co − G is the complement graph of G. If U ⊆ V, with G(U) (or [U] or [U] G ) we denote the subgraph of G induced by U. Throughout this paper, all subgraphs are considered induced subgraphs. With G − X we denote the graph G(V − X), every time X ⊆ V, and we simply write G − v, (∀v ∈ V), when X = {v}. Theorem 1 ([10]). A graph G is called a perfect connected-dominant graph if and only if G contains no induced cycle C 5 and induced path P 5 [10].
(Let us consider D a dominating set and G(D) a connected subgraph. D is called a connected dominating set. It is connected ti domination number nu c (G) of G the minimum size of a connected dominating set in G. Clearly, nu(G) ≤ nu c (G) for any connected graph G. A graph G is called a perfect connected-dominant graph if nu(H) = nu c (H) for all connected induced subgraphs H of G).

Theorem 2 ([11]).
(i) The paper [11] presents a O(n 12 m) time algorithm for weighted independent set on P 5 -free graphs; (ii) The weighted independent set problem applications include train dispatching [12] and data mining [13].

Theorem 3 ([14]).
(i) In the case of line graphs of planar subcubic bipartite graphs, the near-bipartiteness is proven to be NP-complete; (ii) In the case of line graphs of planar subcubic bipartite graphs, it is proven that the considered independent feedback vertex set is NP-complete; (iii) List semi-acyclic 3-coloring is algorithmically solvable on P 5 -free graphs in O(n 16 ) time; (iv) The size of the minimum independent feedback vertex set of a P 5 -free graph with n vertices is algorithmically solvable in O(n 16 ) time [14].
(Let S be a set of vertices in a graph G. S is a feedback vertex set of G in the case graph G-S is a forest. In the following is considered the problem with the requirement of the feedback vertex set to be an independent set. Such a set is called independent feedback vertex set. It is known that graphs which admit an independent feedback vertex set are called near-bipartite). Theorem 4 ([15]). The k-restricted-coloring problem in the class of P 5 -free graphs can be solved in polynomial time [15]. Diverse problems are known to be NP-hard in the class of P 5 -free graphs. The dominating set [16] and chromatic number [17] are illustrative examples in this sense. Property 1 ([18]). According to [18] a connected augmenting graph is P 5 -free if and only if it is chain bipartite.
(A bipartite graph denoted H = (V 1 ; V 2 ; E) with the parts denoted V 1 and V 2 is named augmenting for a stable set S in a graph denoted G if A stable set S in a graph denoted G is maximal if and only if does not exist augmenting graphs for S).
Theorem 5 ([19]). Let us denote with G a connected graph. The two conditions from below are equivalent.
(A strong matching of a graph denoted G is a matching (cardinality two or higher) that is also an induced subgraph of G. A connected graph that does not have strong matching is said to be nonseparable.) Theorem 6 ([20]). A graph G is {P 5 , P 5 }-free if and only if at least one of the following conditions holds: G is a split graph; G is a C 5 ; G is obtained by substitution from smaller {P 5 , P 5 }-free graphs; G or G is obtained by split unification from smaller {P 5 , P 5 }-free graphs [20]. Theorem 7 ([21]). A connected graph denoted G is P 5 -free if and only if each connected induced subgraph has a dominating induced C 5 or a dominating clique [21].
The content of the upcoming parts of the paper is organized as follows. Section 2 presents results reported in the scientific literature about the weak decomposition of a graph, and we recall the relationship between P 5 -free graphs and the dominating clique, given in [21]. Section 3, characterizes the P 5 -free graphs using weak decomposition, dominating clique and gives an O(n(n + m)) recognition algorithm. Next, we approach some combinatorial optimization problems for which we directly calculate some combinatorial numbers; for the other combinatorial optimization numbers, we use an algorithm of complexity O(n + m).

Materials and Methods
The method is the one of the weak decomposition of a graph. In Consequence 1 is presented the use of the dominant clique. The correctness in execution of the designed algorithms is shown, and their complexity is determined.
We recap a characterization of the weak decomposition of a graph here.
Definition 1 ([22,23]). Let us denote with G = (V, E) a graph. A set of vertices denoted A is called a weak set if N G (A) = V − A and the induced subgraph by A is connected. If the set A is a weak set, satisfying the property that is maximal considering the inclusion, the subgraph induced by A is a weak component. For simplification, the weak component G(A) will be symbolized with A.
The use of the name "weak component" is justified by the next result.
We should also address the characterization of P 5 -free graphs according to the dominating clique, given by the authors from [21]: A connected graph denoted G is P 5 -free if and only if each connected induced subgraph detains a dominating induced C 5 or a dominating clique.

Characterization of P 5 -Free Graphs
In [26], the authors present the following results: A connected bipartite graph denoted G is called difference graph if and only if it has no induced P 5 graph, the path that connects five vertices; A graph denoted G is a difference graph if and only if it has no induced 2K 2 , no triangle and no induced pentagon (i.e., C 5 ).
In [5], the authors characterize the bipartite chain graphs using weak decomposition. In the following is a specific characterization of a P 5 -free graph using the idea from [5]. For the work to be a whole, we present the demonstration.
Proof. Proof. Let us denote G, a non-complete, connected, bipartite and P 5 -free graph. (A, N, R) is a weak decomposition with the G(A) weak component. In this case N ∼ R and G(A) is a P 5 -free graph. If N was not stable, in this case n 1 , n 2 ∈ N would exist such that n 1 , n 2 ∈ E; then G(n 1 , n 2 , r) C 3 , ∀r ∈ R, a contradiction, since G being the difference graph is C 3 -free . If R were not stable, then r 1 , r 2 ∈ R would exist such that r 1 , r 2 ∈ E; then G(r 1 , r 2 , n) C 3 , ∀n ∈ N.
Distinct vertices do not exist in N with distinct neighbors in A. Indeed, if n, n ∈ N exist such that a = a where a, a ∈ A and na, n a ∈ E (na , n a ∈ E), then if aa ∈ E, then G(a, n, r, n , a ) C 5 , ∀r ∈ R; else G(a, n, n , a ) 2K 2 .
So, ∀n 1 , n 2 ∈ N we have either Let us suppose that (a) holds. Let x, belonging to A, be adjacent only to n 1 , and y from A to be adjacent to n 1 and n 2 at the same time. Since G(A) is connected, P xy is. If xy ∈ E, then G(x, y, n 1 ) C 3 . If xy ∈ E in this case either x and y have a same neighbor b in A and in this case G(b, x, n 2 , r) 2K 2 or x and y have different neighbors in It is supposed that (i), (ii) and (iii) hold. According to (i), G(R ∪ N) is C 3 -free, C 5 -free and 2K 2 -free. Similarly, G(N ∪ B) is a C 3 -free, C 5 -free and 2K 2 -free. According to [18], G(R ∪ N) and G(N ∪ B) are difference graphs. According to [18], it follows that G(R ∪ N) and G(N ∪ B), are P 5 -free graphs. From (iii), it follows that G(A)(= G(B ∪ (A − B))) is P 5 -free graph. From (i) and (ii) (i.e., R, N, B and A − B are stable sets and R ∼ N ∼ B and A − B ∼ N ∪ R) and from (iii) (i.e., G(A) is P 5 -free) it follows that G is C 3 -free and 2K 2 -free.
Suppose that ∃X ⊆ V : Since G is a connected bipartite and a difference graph, G is P 5 -free graph.
In [21], the authors present the following theorem: A connected graph denoted G is P 5 -free in case if and only if each connected induced subgraph has a dominating induced C 5 or a dominating clique.
Using the Theorem 10, we obtain the consequence mentioned in the following.
Proof. (I) Suppose G is P 5 -free. According to the Theorem 10. (i) holds. According to Theorem 10, it follows that R ∼ N ∼ B, so (ii) and (iii) hold. According to Theorem 10. it follows that: "b 1 , b 2 ∈ B does not exist in B vertices with distinct neighbors in A − B". Indeed. If b 1 , b 2 ∈ B would exist such that a 1 = a 2 , where a 1 , a 2 ∈ A − B and b 1 a 1 , b 2 a 2 ∈ E (b 1 a 2 , b 2 a 1 ∈ E), then, since A − B, B are stable sets and B ∼ N it follows that G(a 1 , b 1 , n, b 2 , a 2 ) P 5 , ∀n ∈ N, a contradiction. Therefore, A − B)), which is also the minimum. So (iv) holds.
(II) We assume that (i), (ii), (iii) and (iv) hold. We show G is P 5 -free, proving the conditions in the Theorem 10. According to (ii) and the previous theorem, it follows that G(R ∪ N) is P 5 -free. Indeed. Let ∀H be connected induced subgraph of G(N ∪ R); it follows that (since H is connected) both V(H) ∩ R = ∅ and V(H) ∩ N = ∅, given that r ∈ V(H) ∩ R and n ∈ V(H) ∩ N. From (ii) it follows that {r, n} is a dominating clique. According to the previous theorem (i.e., A connected graph is called P 5 -free if and only if each connected induced subgraph has a dominating induced C 5 or a dominating clique) G(R ∪ N) is P 5 -free. Since G(A) is the weak component, it follows that R ∼ N. Since R ∼ N, it follows that G(R ∪ N) is complete bipartite. By using (iii) and the previous theorem, similarly, it follows that G(N ∪ B) is complete bipartite. Therefore, (i) and (ii) according to Theorem 10 hold.
We show G(A) = G(B ∪ (A − B)) is a P 5 -free graph.
Let ∀H be an connected induced subgraph of G(A).
According to the previous theorem, it follows that G(A) is P 5 -free. The conditions the Theorem 10 hold; therefore, G is P 5 -free graph.

Proposed Recognition Algorithm for P 5 -Free Graphs
In this section we design the algorithm of recognition for the P 5 -free graphs class. In [27], it is specified in "Unweighted problems" that: recognition of P 5 -free graphs is executed in polynomial time.
In [27], it is specified in "Unweighted problems" that: recognition the bipartite graphs is linear. Using Theorem 10.(or Consequence 1, if G is C 5 -free), we obtain the following recognition Algorithm 2. If (∃v ∈ R such that d H (v) = nr) Then The graph G is not P 5 -free ElseIf (∃v ∈ N so that d H (v) = b + r) Then Graph G is not P 5 -free Else Insert, in L, the induced subgraph of A (at each iteration the graph is called H, so H = [A]) of order strictly higher than 5. EndIf EndWhile 6. Graph G is P 5 -free End It is shown that the execution is in O(n(n + m)) time, because the complexity of the weak decomposition algorithm is O(n + m); the other operations of the recognition algorithm of P 5 -free graphs are less complex.
The recognition algorithm is executed in a finite number of steps. Initially, the graph is finished. In the next interaction, the graph H is replaced by the induced subgraph by A obtained from the weak decomposition (we have V(H) = A∪N∪R, therefore (because N = N(A), R = N(A)), A∩N = φ, A∩R = φ, N∩R = φ), that is A⊂V(H).
Let k be the number of repetitions of the while loop. We have: |A|≥1, |N|≥1, |R|≥1. So, the execution of the algorithm ends when n − ∑ k i=1 (r i + (nr) i ) = p, where p (0 < p ≤ 5) is the cardinal of the set of vertices (i.e., number of vertices, because the given graph is finished) of the graph obtained in the last stage.
The complexity of the recognition algorithm. The graph is presented through the adjacent matrix (O(n 2 )) or adjacency list (O(n + m)).

1.
Determine the degree of each vertex/we count the binary numbers with the value 1 on each line of the adjacent matrix (O(n 2 )) or we count the vertices of adjacent list (O(n + m)).

2.
Determine a weak decomposition (A, N, R) with N ∼ R for H/the algorithm for the weak decomposition of a graph has the complexity O(n + m).

5.
If (∃v ∈ R such that d H (v) = nr)/ The time for comparing the degrees of the vertices in R with nr is O(n).

The induced subgraph of A (H = [A])/H is connected, non-complete and bipartite graph.
In the second and following while loops, the role of graph H is assumed by the induced subgraph by A.
All in all, the complexity is O(k(n + m)), where k is the number of repetitions of the while loop.

An example of application of the recognition algorithm
We apply the algorithm to the graph b 4 n 3 , n 1 r 1 , n 1 r 2 , n 1 r 3 , n 1 r 4 , n 2 r 1 , n 2 r 2 , n 2 r 3 , n 2 r 4 , n 3 r 1 , n 3 r 2 , n 3 r 3 , n 3 r 4 }.
Repeating the while loop with the new graph H we obtain (Initial, A = {a 1 }):

Combinatorial Optimization Algorithms for P 5 -Free Graphs
In [27], it is specified in "Unweighted Problems" that: clique, clique cover, colorability and domination are NP-complete; the feedback vertex set is unknown to ISGCI; and the independent set is polynomial.
Theorem 10 has the following consequence. α(G) = max{|A| − |B| + |N|, |A| − |B| + |R|, |B| + |R|}; 3. We color the vertices of R with c R . We color the vertices of N with c N . Since N ∼ R, it follows that c R = c N . We can color the vertices in B with c R and the vertices in A − B with c N (since A − B ∼ N). If we suppose |R| > |N|, a minimum cover with cliques (which are the edges) of G(N ∪ R) is: {n 1 r i |n i ∈ N, r i ∈ R, i = 1, . . . , |N|} ∪ {n |N| r k |k = |N| + 1, . . . , |R|}.
The vertices of G(A) need to be covered. According to Theorem 10 it follows that: "Distinct vertices in B that have distinct neighbors in So, there is an order of vertices in B according to their neighborhoods in A − B from the point of view of inclusion (i.e., we can assume: We show ∀n ∈ N, {n} ∪ B is a dominating set. Indeed. ∀r ∈ R: nr ∈ E (since R ∼ N). ∀n ∈ N − {n}: From Consequence 2 it follow that the clique number and the chromatic number are calculated directly; the number of stability is determined in O(n + m) (as the complexity of the weak decomposition algorithm); the minimum clique cover and the dominating number are O(n + m) (since the determination of the neighbors of a vertex in (B or A − B) is not more than the complexity of the weak decomposition algorithm).
In [14] are the following results: • For line graphs of planar subcubic bipartite graphs, it is proven that near-Bipartiteness is NP-complete; • For line graphs of planar subcubic bipartite graphs, it is proven that Independent Feedback Vertex Set is NP-complete; • List Semi-Acyclic 3-Colouring is algorithmically solvable on P 5 -free graphs in O(n 16 ) time; • The size of a minimum independent feedback vertex set of a P 5 -free graph with n vertices can be solved in O(n 16 ) time.
Using Theorem 10, the size of a minimum independent feedback vertex set is given in the following consequence. Indeed. Since G − N (which means G(A ∪ R)), as well as G − B (which means G((A − B) ∪ (N ∪ R))), are acyclic graphs. Using Consequence 2 and Consequence 3, we obtain the Algorithm 3 for determining combinatorial optimization numbers. The determination of the neighbors of an vertex in (B or A − B) is not more than the complexity of the weak decomposition algorithm, which is O(n + m).
According to Consequence 2, the complexity of determining α(G), θ(G), γ(G) are O(n + m). According to Consequence 3, the complexity of determining the size of a minimum independent feedback vertex set is O(1).

Conclusions
In this paper the P 5 -free graphs are characterized using the weak decomposition presented in Theorem 10. The results consist of an O(n(n + m)) recognition algorithm. Consequence 1 characterizes the P 5 -free graphs using the dominant clique. A result of Consequence 1 is the direct calculation of the clique and chromatic number of the P 5 -free graphs. Based on the fact that the complexity of the weak decomposition algorithm is O(n + m), and because |A| − |B| + |N|, |A| − |B| + |R|, |B| + |R| is determined in O(n) time, it follows from the Consequence 1 that the stability number of P 5 -free graphs is calculated in O(n + m) time. Because N(b 1 )∩ (A − B), and N(a |A−B| ) ∩ B is determined linearly, it follows that the minimum clique cover and the dominating number is O(n + m) (this is based on the fact that the complexity of the weak decomposition algorithm being O(n + m)). Since the complexity of the weak decomposition algorithm is O(n + m) and |N|, |B|, it is calculated in O(n) time it follows, from the Consequence 3, that the size of a minimum independent feedback vertex set of P 5 -free graphs is calculated in O(n + m) time.