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.



There are no comments yet.


page 1

page 2

page 3

page 4


On Unimodality of Independence Polynomials of Trees

An independent set in a graph is a set of pairwise non-adjacent vertices...

Enumerating Minimal Separators in Ranked Order

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

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...

Harary polynomials

Given a graph property P, F. Harary introduced in 1985 P-colorings, grap...

Massively Parallel Dynamic Programming on Trees

Dynamic programming is a powerful technique that is, unfortunately, ofte...

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

Huang and Wong [5] proposed a polynomial-time dynamic-programming algori...

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 [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) [6].

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 [2] one can use the following recursive formula:


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]:


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 [8], 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 [4], many practical problems rely heavily on graphs with bounded treewidth. Tittmann [5] 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 [3]. 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:

Graph Stored as
Table 1: Path graphs with 1,2 and 3 vertices and their representation in the algorithm.

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.

Input: Tree T as adjacency list
Output: A list IP that represents the independence polynomial of T
// Two base cases:
1 if  then
2      return [1,1]
3if  then
4      return [2,1]
// Select a root vertex that not a leaf:
// Call the recursive function:
6 FIPR(T, root)
// Return the independence polynomial of :
Algorithm 1 FIP(T)
Input: Tree T as adjacency list, root vertex
Output: Three lists: I(T; x), I(T-v; x), I(T-N[v]; x)
// Stop condition:
1 if root is a leaf then
2       I_of_T_minus_v(root) [1]
3       I_of_T_minus_Nv(root) [1]
4       I_of_T(root) [1, 1]
6 else
       // Explore undiscovered vertices that are root-neighbors:
7       foreach vertex u in N[root] that never explored do
             // Save the hierarchy:
8             vertex_children(root).append(u)
             // Call again recursively with u:
9             FIPR(T, u)
       // Neutral organ to multiply
       // Initialize as x
       // Calculate the union of sub-graphs
10       foreach u in vertex_Children do
             // polynomial multiplication
      // Set all lists in index
13       I_of_T_minus_v(root)
14       I_of_T_minus_Nv(root)
       I_of_T(root) // polynomial Addition
Algorithm 2 FIPR(T, root)

4 Proof of correctness

Lemma 4.1.

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


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.


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.


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.