    # A Linear Algorithm for Computing Independence Polynomials of Trees

An independent set in a graph is a set of pairwise non-adjacent vertices. Let α(G) denote the cardinality of a maximum independent set in the graph G = (V, E). Gutman and Harary defined the independence polynomial of G I(G;x) = ∑_k=0^α(G)s_kx^k=s_0+s_1x+s_2x^2+...+s_α(G)x^α(G), where s_k denotes the number of independent sets of cardinality k in the graph G. A comprehensive survey on the subject is due to Levit and Mandrescu, where some recursive formulas are allowing to calculate the independence polynomial. A direct implementation of these recursions does not bring about an efficient algorithm. Yosef, Mizrachi, and Kadrawi developed an efficient way for computing the independence polynomials of trees with n vertices, such that a database containing all of the independence polynomials of all the trees with up to n-1 vertices is required. This approach is not suitable for big trees, as an extensive database is needed. On the other hand, using dynamic programming, it is possible to develop an efficient algorithm that prevents repeated calculations. In summary, our dynamic programming algorithm runs over a tree in linear time and does not depend on a database.

## Authors

01/17/2021

### On Unimodality of Independence Polynomials of Trees

An independent set in a graph is a set of pairwise non-adjacent vertices...
11/15/2021

### Enumerating Minimal Separators in Ranked Order

Let G be an n-vertex graph, and s,t vertices of G. We present an efficie...
12/27/2019

### Transversals of Longest Cycles in Partial k-Trees and Chordal Graphs

Let lct(G) be the minimum cardinality of a set of vertices that intersec...
03/13/2020

### Harary polynomials

Given a graph property P, F. Harary introduced in 1985 P-colorings, grap...
09/11/2018

### Massively Parallel Dynamic Programming on Trees

Dynamic programming is a powerful technique that is, unfortunately, ofte...
01/12/2019

### On Huang and Wong's Algorithm for Generalized Binary Split Trees

Huang and Wong  proposed a polynomial-time dynamic-programming algori...
03/19/2018

### Table Based Detection of Degenerate Predicates in Free Space Construction

The key to a robust and efficient implementation of a computational geom...
##### This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.

## 1 Introduction

### 1.1 Definitions

Throughout this paper is a simple (i.e., a finite, connected, undirected, loopless and without multiple edges) graph with vertex set of cardinality and edge set of cardinality .

A set is independent if no two vertices in are adjacent. An independent set of maximum cardinality, named a maximum independent set, and its size is called the independence number and denoted . An independence polynomial of graph defined by Gutman and Harary in 1983 :

 I(G;x)=α(G)∑k=0skxk=s0+s1x+s2x2+...+sα(G)xα(G) (1)

where denotes the number of independent sets of cardinality in the graph . is the number of independent sets with minimal cardinality in (i.e empty set) .

A tree decomposition of a general graph is a tree of ”bags”, where if edge then and are together in same ”bag”, and the “bags” containing are connected in . The width of a tree decomposition equal to one less than the maximum bag size and the treewidth of equal to least width of all tree decompositions for .

### 1.2 Computing the independence polynomial

To compute the independence polynomials , as shown in Levit and Mandrescu survey  one can use the following recursive formula:

 I(G;x)=I(G−v;x)+x⋅I(G−N[v];x) (2)

where N[v] is the neighborhood of the vertex v including v itself.

To compute the independence polynomials of union of graphs the formula is [7, 2]:

 I(G1∪G2;x)=I(G1;x)⋅I(G2;x) (3)

### 1.3 Problem

Some facts on similar problems:

• Computing the Maximum Independent Set of a general graph is an NP-Complete problem.

• Computing the Independence Polynomial of a general graph is also an NP-Complete problem. The degree of the independence polynomial is equivalent to the Maximum Independent Set.

• There are families of graphs with a closed-form expression for their independence polynomial , but from what is known, trees are not one of them.

• Some families of graphs have a polynomial algorithm to compute their . Does it give us hope for a polynomial algorithm to compute their independence polynomials?

According to Bodlaender , many practical problems rely heavily on graphs with bounded treewidth. Tittmann  offers a way for the construction of an algorithm that computes the independence polynomial of a graph with bounded treewidth in polynomial time based on a specific partition.
Based on Tittmann, who described in acronyms how an algorithm for graphs with a bounded treewidth should look, we accurately investigated an actual algorithm for trees.

Yosef, Mizrachi, and K. developed an efficient approach for computing the independence polynomials of trees with vertices . This approach is based on an extensive database containing the independence polynomials of all the trees with up to vertices, and the induction step computing the independence polynomials of all the trees with vertices based on their counterparts. Although this approach works well with small-sized trees, big trees may require an enormous database to compute their independence polynomials.

## 2 Main idea of algorithm

The new algorithm is not based on a database nor requires one. Instead, it used the dynamic programming technique.

The independence polynomial represented in the algorithm as a list with cells in the following format:

 [sk=α(G),sk=α(G)−1,...,sk=1,sk=0]

From the computing process, the independence polynomial formula, as described in (2), says that every vertex can be calculated just after its children and grandchildren are calculated. Post-order-traversal validates that the children and grandchildren vertices will be computed before the father vertex.

To examine all tree graphs, we divided them into three cases:

1. :

• because has no vertices in , there is one independent set of cardinality zero (i.e., empty set).

• from the same reason above. so:

2. :

• because when vertex removed, the graph stay with only one vertex, and this sub-graph matches the previous case.

• because has no vertices in , there is one independent set of cardinality zero (i.e., empty set). so:

3. :

1. Start with traveling on the tree in post-order traversal. When reaching a leaf node, like case 1, it can calculate by A:

2. For an inner vertex that all its children were calculated, when vertex v is removed, the number of connected components can rise, and in such case, computation of sub-graphs union, as described in (3), is needed.

So in purpose to calculate , compute next parameters:

• parameter said that we remove the vertex v with its neighbors so we can use parameter of the children:

Finally use formula 2 to calculate .

## 3 Main Algorithm

The algorithm in FIP (find independence polynomial) function starts at selected root node of a tree and goes as far as it can down a given branch in FIPR (find independence polynomial recursion) function, then backtracks until it finds an unexplored path, and then explores it. The algorithm does this until the entire graph has been explored.

## 4 Proof of correctness

###### Lemma 4.1.

FIPR(T, root) is called exactly once for each vertex in the graph

###### Proof.

Clearly FIPR(T, root) is called for a vertex u only if it not discovered. The moment it’s called, FIPR(T, root) cannot be called vertex v again. Furthermore, because T is connected component, and FIPR(T, root) uses post order travesal in the implementation, it’s ensures that it will be called for every vertex in T. ∎

###### Lemma 4.2.

The body of the foreach loop that explore undiscovered vertices that are root-neighbors (lines 6-8) is executed exactly once for each edge (v,u) in the graph.

###### Proof.

FIPR(T, root) is called exactly once for each vertex root (Claim 1). And the body of the loop is executed once for all the unseen edges that connect to root. ∎

###### Corollary 4.1.

The algorithm can start from every vertex root such that
and get the same runtime.

###### Proof.

The order of walking on the tree is in post order travels. In this way, it go through each edge exactly twice so that is no matter which vertex v it start from, the running time will remain the same. ∎

Therefore, the running time of the FIPR(T, root) algorithm is , and the tested graphs are trees, so it summarise to .

## 5 Conclusion

In this article we have presented a linear algorithm that uses dynamic programming to find an independence polynomial of trees. The algorithm uses a post-order-travel over the graph. when it reaches the leaves it calculates them, and in the backtracking, when all children were calculated, there comes the father turn to compute.

## References

•  Gutman I. and Harary F., Generalizations of the matching polynomial, Utilitas Mathematica, Vol. 24, 97-106, 1983.
•  Levit V. E. and Mandrescu E., The independence polynomial of a graph - a survey Proceedings of the 1st International Conference on Algebraic Informatics, 231-252, 2005.
•  Yosef R., Mizrachi M., Kadrawi O. On unimodality of independence polynomials of trees, https://arxiv.org/pdf/2101.06744v3.pdf, 2021.
•  Hans L. B., A linear time algorithm for finding tree-decompositions of small treewidth, SIAM,
•  Tittmann P. Graph polynomials: The Ethernal Book, 2021.
•  Levit V. E. and Mandrescu E., On Unimodality of Independence Polynomials of some Well-Covered Trees, Discrete Mathematics and Theoretical Computer Science, Vol. 4, 237-256, 2003.
•  Hoede C. and Li X., Clique polynomials and independent set polynomials of graphs, Discrete Mathematics, Vol. 125, 219-228, 1994.
•  Ferrin G. M., Independence polynomials ,University of South Carolina, Master’s thesis, 2014.
https://scholarcommons.sc.edu/cgi/viewcontent.cgi?article=3632context=etd