I need an algorithm to find max independent set in a tree. I'm thinking start from all leaf nodes, and then delete the direct parent nodes to these leaf nodes, then choose the parent nodes of the parent nodes we deleted, repeat this procedure recursively until we get to root. and is this done in O(n) time? any reply is appreciated. thanks.
And could anyone please point me an algorithm to find the max dominating set in a tree.
The Maximum Independent Set (MIS) problem in graph theory is the task of finding the largest independent set in a graph, where an independent set is a set of vertices such that no two vertices are adjacent. There is currently no known efficient algorithm to find maximum independent sets.
Typical way to find independent sets is to consider the complement of a graph. A complement of a graph is defined as a graph with the same set of vertices and an edge between a pair if and only if there is no edge between them in the original graph.
A maximum independent line set of 'G' with maximum number of edges is called a maximum independent line set of 'G'. L3 is the maximum independent line set of G with maximum edges which are not the adjacent edges in graph and is denoted by β1 = 3. Line independent number (Matching number) = β1 = [n/2] α1 + β1 = n.
Maximum independent sets and maximum cliques The independent set decision problem is NP-complete, and hence it is not believed that there is an efficient algorithm for solving it. The maximum independent set problem is NP-hard and it is also hard to approximate.
You can compute the maximum independent set by a depth first search through the tree.
The search will compute two values for each subtree in the graph:
These can be computed recursively by considering two cases:
The root of the subtree is not included.
B(i) = sum(max(A(j),B(j)) for j in children(i))
The root of the subtree is included.
A(i) = 1 + sum(B(j) for j in children(i))
The size of the maximum independent set in the whole tree is max(A(root),B(root)).
According to the definition of dominating set in wikipedia the maximum dominating set is always trivially equal to including every node in the graph - but this is probably not what you mean?
Simple and fast approach:
As long as the graph is not empty, iteratively add a leaf v (degree 1) to the independent set V and remove v and its neighbor.
This should work, since
A tree always has a degree-1-vertex,
Adding a degree-1-vertex to V preserves optimality and
The result of such a step again gives a tree or a forest which is a union of trees.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With