Let be a finite, simple and undirected graph and let (respectively, ) denote the vertex set (respectively, the edge set) of . For , let denote the subgraph of induced by . Throughout this paper, all subgraphs are understood as induced subgraphs.
For , let be the open neighborhood of in , let be the closed neighborhood of in , and let be the anti-neighborhood of in . For and , with , let .
If (, respectively) we say that sees ( misses , respectively). An independent set (or stable set) in a graph is a subset of pairwise nonadjacent vertices of . An independent set in a graph is maximal if it is not properly contained in any other independent set of .
Given a graph and a weight function on , the Maximum Weight Independent Set (MWIS) problem asks for an independent set of with maximum weight. Let denote the maximum weight of an independent set of . The MWIS problem is called MIS problem if all vertices have the same weight .
The MIS problem ([GT20] in ) is well known to be NP-complete . While it is solvable in polynomial time for bipartite graphs (see e.g. [1, 8, 11]), it remains NP-hard even under various strong restrictions, such as for triangle-free graphs .
The following specific graphs are subsequently used. has vertices and edges for . has vertices and edges for (index arithmetic modulo ). has vertices which are pairwise adjacent. Clearly, . (and thus, ) is also called triangle. A claw (with center ) has vertices and edges . (with center ) is the graph obtained from a claw with center by subdividing respectively its edges into , , edges (e.g., is a , is a claw).
For a given graph , a graph is -free if no induced subgraph of is isomorphic to . If for given graphs , is -free for all then we say that is -free.
Alekseev [2, 5] proved that, given a graph class defined by forbidding a finite family of induced graphs, the MIS problem remains NP-hard for the graph class if each graph in is not an for some index . Various authors [9, 16, 17, 18, 25] proved that MWIS can be solved for claw-free (i.e., -free) graphs in polynomial time (improving the time bounds step by step). Lozin and Milanič  proved that MWIS can be solved for fork-free graphs (i.e., -free graphs) in polynomial time Alekseev [3, 4] previously proved a corresponding result for the unweighted case.
In this paper, we show that for (,triangle)-free graphs, MWIS can be solved in polynomial time. This generalizes the polynomial-time result for MWIS on (,triangle)-free graphs  (which was extended by Maffray and Pastor  showing that MWIS can be solved in polynomial time for (,bull)-free graphs; in the same paper, they also showed that MWIS can be solved in polynomial time for (,bull)-free graphs).
The following result is well known:
Let be a bipartite graph with vertices.
MWIS with rational weights is solvable for in time
via linear programming or network flow.
MIS is solvable for in time .
A graph is nearly bipartite if, for each , the subgraph induced by its anti-neighborhood is bipartite. Obviously we have:
Thus, by Theorem 1, the MWIS problem (with rational weights) can be solved in time for nearly bipartite graphs.
That allows, by detecting an opportune sequence of vertices, to split and to finally reduce the problem to certain instances of bipartite subgraphs, for which the problem can be solved in polynomial time (recall Theorem 1). In particular, as a corollary we obtain: For every (,triangle)-free graph there is a family of subsets of inducing bipartite subgraphs of , with detectable in polynomial time and containing polynomially many members, such that every maximal independent set of is contained in some member of . That seems to be harmonic to the result of Prömel et al. 
showing that with “high probability”, removing a single vertex in a triangle-free graph leads to a bipartite graph.
1.1 Further notations and preliminary results
For any missing notation or reference let us refer to . For , with , has a join (a co-join, respectively) to , denoted by (, respectively), if each vertex in is adjacent (is nonadjacent, respectively) to each vertex in .
For and , with , contacts if is adjacent to some vertex of ; dominates if is adjacent to all vertices of , that is, ( for short); misses if is non-adjacent to all vertices of , that is, ( for short).
A component of is a maximal connected subgraph of . The distance of two vertices in is the number of edges of in a shortest path between and in .
Recall that is a triangle.
Connected -free graphs are nearly bipartite.
Proof. Let be a connected -free graph. Suppose to the contrary that for some vertex , is not bipartite, i.e.,
contains an odd chordless cycle. Then, sinceis ()-free, contains an odd chordless cycle , say , for some . Let be the vertices of and let (index arithmetic modulo ) be the edges of . Then let be a shortest path between and ; clearly, the distance between and is at least 2. Without loss of generality (since the other cases can be similarly treated), assume that has exactly one internal vertex, say (i.e., is adjacent to and to some vertex of ).
If then or .
Proof. Since is -free, implies and , and since is -free and thus, do not induce a , we have . Now, since (with center ) do not induce an , we have or which shows Claim 1.
Now, since is an odd cycle, Claim 1.1 leads to a or which is a contradiction (for example, if and then clearly, , and leads to a with vertices ).
Thus Lemma 1 is shown.
Since by Lemma 1, every component of a -free graph is nearly bipartite, and since MWIS is solvable in polynomial time for nearly bipartite graphs (recall Theorem 1 and MWIS for nearly bipartite graphs), we have:
MWIS is solvable in polynomial time for -free graphs.
Our aim is to show that MWIS can be solved in polynomial time for ()-free graphs. Since by Corollary 1, we are done with -free graphs, from now on let be a connected ()-free graph containing a . Using again the anti-neighborhood approach, let and let be a component of the induced subgraph of its anti-neighborhood . Since is connected, has a neighbor contacting . Since is -free, is independent.
A component of is nontrivial if contains a .
For any -free graph and for any and its anti-neighborhood , if contacts two nontrivial components of then for any in , if then or .
Proof. Let be a in which is contacted by , say , and clearly, since is -free. For a in , let . Then, since (with center ) do not induce an , we have or . Thus, Fact 1 is shown.
For any -free graph and for any and its anti-neighborhood , at most one component of can contain a .
Proof. Let be a connected -free graph. Suppose to the contrary that for some vertex , there are two components in containing a , say in and in . Let be a neighbor of contacting , and let be a neighbor of contacting . First assume that contacts and . Clearly, and are nontrivial. By Fact 1, contacts since otherwise, there is a in such that contacts only one end-vertex of , and correspondingly, contacts in . Without loss of generality, let and . Then again by Fact 1, has exactly two neighbors in and in , say and . But now, (with center ) induce an in which is a contradiction.
Thus, no neighbor contacts and ; let contact and let contact , , while and . Recall that is independent, i.e., . Without loss of generality, let and . Clearly, or . If and then (with center ) would induce an . Thus, without loss of generality, let and thus, , , but now, (with center ) induce an which is a contradiction. Thus Lemma 2 is shown.
Recall that is a component of , and contacts . Let
Obviously, is a partition of . Since is -free, is an independent set.
For showing that MWIS can be solved for in polynomial time, let us first consider the case when is bipartite.
2 Case 1: is bipartite
Recall that, if component contains no , then by Corollary 1, MWIS can be solved in polynomial time for . Thus assume that contains a , say with vertices and edges (index arithmetic modulo 5). Since we assume that is bipartite and since is an independent set, every in has at least one vertex in , and thus, we have one of the following two types:
Type : has exactly one vertex in (and thus, the four vertices of in induce a ).
Type : has exactly two vertices in (and thus, the three vertices of in induce a ).
Let be a nontrivial component of . If contacts both sides of then there is a of type in .
Proof. Let and be two neighbors of . Note that is nonadjacent to since is -free. Then, since is connected, there is a shortest path, say (of an even number of internal vertices) in between and ; without loss of generality, let us assume that is nonadjacent to any internal vertex of (else we may re-define the choice of and ).
If has only two internal vertices, say , then induce a of type 1 in . Thus, suppose to the contrary that has more than two internal vertices (and then has at least four internal vertices). Then , and the three vertices of closest to induce an in which is a contradiction. Thus, Fact 2 is shown.
2.1 Case 1.1: Every in is of type 2.
For and nontrivial component of , we define:
has a half-join to if either or i.e., either and or and .
properly one-side contacts if either or .
By Fact 2 and Case 1.1, we have:
For every , if contacts a nontrivial component of and every in is of type then either has a half-join to or properly one-side contacts .
A nontrivial component of is a green component of if there is a vertex which properly one-side contacts .
Case 1.1.1 has no green component.
If there is no green component in then MWIS is solvable in polynomial time for .
Proof. Since has no green component, Fact 3 implies that, for each and for each nontrivial component of , if contacts then has a half-join to , i.e., either and or and . In particular, that implies:
For each , there is no induced , say , of such that is an endpoint of the in .
For any and for any in with vertices such that and , let us say that doubly contacts the if is adjacent to and to exactly one vertex of .
Then let doubly contacts a in .
If , then has no of type 2, i.e., by assumption of Case 1.1, is -free and then, by Lemma 1, MWIS can be solved in polynomial time for . Thus, assume that .
Let and such that doubly contacts a with and in , and contacts a in . If then and .
Proof. Assume without loss of generality that . Clearly, since . By Claim 2.1 and since is -free, do not induce a in , and thus, which implies . If then and . Now assume that , and recall that .
Now, let ’’ be the following binary relation on : For any pair , if either or contacts all ’s of which are doubly contacted by . Correspondingly, if vertex doubly contacts a of such that does not contact . In particular let us write if and .
For any , either or .
Proof. Suppose to the contrary that and . Then doubly contacts a of with and such that is adjacent to , while , and doubly contacts a of with and such that is adjacent to , while .
By Claim 2.2, and .
Clearly, since and , we have and .
For any , if and then .
Proof. Since and , there is a with and in such that is adjacent to , while , and there is a with and in such that is adjacent to , while .
Suppose to the contrary that . Then there is a with and in such that is adjacent to while .
By Claim 2.2, the sets , , and are pairwise disjoint, and , , and .
Since and , we have , and clearly, . Thus, possibly , and analogously, possibly , and .
Now first assume that , , and . Then we claim that (with center ) would induce an :
Recall that , , , , and . Clearly, doubly contacts the with and . Then clearly, and since is -free, and , . Moreover, since , , , and . Finally, since clearly, , , since , and is -free, and , , , and . Thus, induce an which is a contradiction, i.e., , , and is impossible.
Now assume that we have exactly two such equalities. If but and then we claim that (with center ) would induce an :
Recall that in this case, doubly contacts the with and , and , . Clearly, since is -free. Since , , and , and by Claim 2.1, we have ; in particular, if then there is a which contradicts Claim 2.1. Finally, as before. Thus, (with center ) induce an which is a contradiction, i.e., exactly two such equalities and are impossible.
By symmetry, we can show that the two other cases of exactly two such equalities are impossible.
Now assume that we have exactly one such equality. By symmetry, assume that , but . Then we claim that (with center ) would induce an :
Recall that in this case, doubly contacts the with and , and , . Clearly, since is -free and , (recall ). Moreover, . Thus, (with center ) induce an which is a contradiction, i.e., exactly one such equality is impossible.
Finally assume that , , and . Since and , does not doubly contact the .
If (and since is -free, ) then (with center ) would induce an (recall that , and by Claim 2.1, we have , since otherwise there is a ).
Thus, and by symmetry, .
If then (with center ) would induce an (recall , , and by Claim 2.1, we have , since otherwise there is a ).
Thus, . But then (with center ) induce an which is a contradiction.
Thus, Claim 2.4 is shown.
There is a vertex such that for every .
Now assume that and that Claim 2.5 holds for . Let