# Counting Independent Sets in Cocomparability Graphs

We show that the number of independent sets in cocomparability graphs can be counted in linear time, as can counting cliques in comparability graphs. By contrast, counting cliques in cocomparabilty graphs and counting independent sets in comparability graphs are #P-complete. We extend these results to counting maximal cliques and independent sets. We also consider the fixed-parameter versions of counting cliques and independent sets of given size k. Finally, we combine the results to show that both counting cliques and independent sets in permutation graphs are in linear time.

## Authors

• 9 publications
• 6 publications
• ### Counting independent sets in strongly orderable graphs

We consider the problem of devising algorithms to count exactly the numb...
01/06/2021 ∙ by Marc Heinrich, et al. ∙ 0

• ### Simple Counting and Sampling Algorithms for Graphs with Bounded Pathwidth

In this paper, we consider the problem of counting and sampling structur...
08/19/2020 ∙ by Christine T. Cheng, et al. ∙ 0

• ### On the complexity of counting feedback arc sets

In this note we study the computational complexity of feedback arc set c...
09/07/2019 ∙ by Kévin Perrot, et al. ∙ 0

• ### Performance Optimization of MapReduce-based Apriori Algorithm on Hadoop Cluster

Many techniques have been proposed to implement the Apriori algorithm on...
07/16/2018 ∙ by Sudhakar Singh, et al. ∙ 0

• ### Smoothed counting of 0-1 points in polyhedra

Given a system of linear equations ℓ_i(x)=β_i in an n-vector x of 0-1 va...
03/09/2021 ∙ by Alexander Barvinok, et al. ∙ 0

• ### Approximately counting independent sets of a given size in bounded-degree graphs

We determine the computational complexity of approximately counting and ...
02/09/2021 ∙ by Ewan Davies, et al. ∙ 0

• ### Linear Time Subgraph Counting, Graph Degeneracy, and the Chasm at Size Six

We consider the problem of counting all k-vertex subgraphs in an input g...
11/14/2019 ∙ by Suman K. Bera, et al. ∙ 0

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

Counting independent sets in graphs is known to be #P-complete in general [12], even for several restricted cases [13]. Even approximate counting is NP-hard, and unlikely to be in polynomial time for bipartite graphs [4]. However, smaller graph classes may permit polynomial time algorithms. For example, [9] gives a linear time algorithm for counting independent sets in bipartite permutation graphs. Here “linear time” means computable with a number of arithmetic operations and comparisons linear in the size of the graph. Similar results are known for chordal graphs [11] and tree-convex graphs [8]. For information on these and other graph classes, see [1].

Counting cliques in a graph is equivalent to counting independent sets in the complementary graph. Thus, for general graphs, these two problems have equivalent complexity. However, for graph classes the two problems may have very different complexity.

Here we consider the problems of counting independent sets and cliques in three classes of graphs: cocomparability graphs, comparability graphs and permutation graphs. See section 2 below for definitions. In each case we show that either the counting problem can be accomplished in linear time, or else counting is #P-complete.

In section 3 we present a simple linear time algorithm for counting independent sets in cocomparability graphs, and show that counting cliques is #P-complete. We extend this to counting maximal independent sets, and independent sets of a given size, and maximal independent sets of a given size. In section 4, we modify this to give linear time algorithms for counting cliques in comparability graphs, and show that counting independent sets is #P-complete.

Together, these results imply simple linear time algorithms for counting both cliques and independent sets in permutation graphs, as we discuss in section 5. Thus our results give strong generalisations of the algorithm of [9].

## 2 Preliminaries and notation

For integers and with the set of consecutive integers will be abbreviated as .

Let be a finite partial order, with . The cover relation of is its transitive reduction, defined by if and there is no with and . By we mean or .

A chain in is a set of pairwise comparable elements. That is, the restriction of to is a linear order. A chain with for all is tight if holds for all .

A linear extension of is a permutation of such that implies .

Let be a graph with vertex set , with and . Here all graphs are finite, undirected and simple, unless stated otherwise. We will denote the complementary graph by , where . Let , that is , and .

A clique in a graph is a set of pairwise adjacent vertices. A set of pairwise non-adjacent vertices is independent. Therefore a clique of is an independent set in the complement of and vice versa. A maximal clique or independent set is maximal with respect to set inclusion. By contrast, maximum refers to the largest cardinality.

A partial order can be considered as digraph with vertex set and arcs for all pairs such that . The comparability graph for is the underlying undirected graph of . That is, . Then a graph is a comparability graph if there is a partial order on the set such is the comparability graph of . Given a comparabity graph , a corresponding partial order and a linear extension can be computed in (linear) time [10]. Note, however, that this algorithm does not certify that is a comparability graph. Recognition is currently only known in time. We will sidestep these issues by assuming the input comparability graph is given with a transitive orientation and a linear extension of this.

The complements of comparability graphs are called cocomparability graphs, so these are the incomparability graphs of partially ordered sets. Again, recognition is not known in linear time, but a linear time algorithm can compute and a linear extension for the complementary comparability graph [5, 10]. Again,

A graph is a permutation graph if there is a permutation of such that if and only if implies . It is not difficult to show that is a permutation graph if and only if it is both a comparability graph and a cocomparability graph. Permutation graphs can be recognised, and a permutation ordering obtained, in linear time [6], so we need no assumptions on the input graph.

These are well-established classes of graphs, and are all subclasses of perfect graphs. Important subclasses of comparability graphs are bipartite graphs and cographs. Interval graphs are an important subclass of cocomparability graphs (they are graphs that are both chordal and cocomparability). Permutation graphs are an important subclass of both comparability and cocomparability graphs.

## 3 Cocomparability graphs

Let be a cocomparability graph and let be a partial order on , with linear extension . We will extend the poset by a unique minimal element and a unique maximal element . That is, we define and for all , and (if not enforced by transitivity) . Let , for any . Then we denote the extended partial order by , If is linear extension of , and , we write for such that ,

###### Lemma 1.

Let be a cocomparability graph which is the incomparability graph of a poset , and let be the above extension. Then

1. [label=(0),topsep=0pt,itemsep=0pt]

2. a set is independent in if and only if is a chain of ;

3. a set is maximally independent in if and only if is a tight chain of .

###### Proof.

Two vertices in are -comparable if and only if they non-adjacent in . The extra elements and are comparable to all vertices in . Together these imply property 1.

To see 2 we first consider an independent set of that is not maximal independent. Hence there is a vertex such that is still independent. By property 1 the set is a chain, and hence is also a chain, but not a tight one.

Now let be a maximal independent set of . So by property 1 the set is a chain of . Since is a maximal independent set of , for all the set is not independent in . By property 1 the set is not a chain, and therefore is a tight chain of . ∎

For every vertex let . Especially, and . Let . For every , the relation restricted to is a partial order with unique minimal element and unique maximal element .

### 3.1 Independent sets

For every vertex let be the set of independent sets of of with , and . That is, is the number of independent sets of . We can evaluate and recursively as follows:

 A(⊥)={∅} a(⊥)=1 A(vi)=⋃u≺vi{S∪{vi}∣S∈A(u)} a(vi)=∑u≺via(u) (i∈[1,n]) A(⊤)=⋃u≺⊤A(u) a(⊤)=∑u≺⊤a(u)

The sets can be exponential in size (for example if ), but the recurrence for can be evaluated efficiently. We use the linear extension of to evaluate the equations above in the order , as shown. At the end is the number of independent sets in .

We show that the recurrence above is correct by proving a sequence of lemmas, which themselves are proven directly or by induction on .

###### Lemma 2.

For all every set is independent in and implies .

###### Proof.

The base of the induction is for . Clearly is the unique independent set of .

Now let . Every set contains the vertex and vertices in for . By induction hypothesis is an independent set of some . Therefore only contains vertices of . Moreover is a chain in . By transitivity, and imply that is also a chain in and therefore an independent set of .

The latter argument also applies to . ∎

###### Lemma 3.

Every nonempty independent set of is contained in .

###### Proof.

Let be an independent set of . This implies that is a chain of and therefore has a unique maximal element . We have and, by induction hypothesis, for some . Consequently we have , and clearly . ∎

###### Lemma 4.

For different we have .

###### Proof.

If and are -incomparable then these are adjacent vertices of . Hence no independent set of can contain both and . By Lemma 2 for all and all we have and , that is, . Consequently holds.

Now let and be -comparable. By symmetry we may assume , especially . Again, Lemma 3 implies, for all and all , that holds. As before this means , and therefore . ∎

We can implement the above recurrences for directly, but it is clear that the time complexity is , not , since the summations are over the edges of . If , this clearly implies time, but otherwise we correct this as follows.

For all we define by

 t(⊥) =0 t(vi) =a(⊥)+i−1∑j=1a(vj) (i∈[1,n]) t(⊤) =a(⊥)+n∑j=1a(vj)

The values of and are mutually recursive:

 t(⊥) =0 a(⊥) =1 t(v1) =1 a(v1) =2 t(vi) =t(vi−1)+a(vi−1) a(vi) (i∈[2,n]) t(⊤) =t(vn)+a(vn) a(⊤) =t(⊤)

The recurrence for is obvious, and for we have

 t(vi)−∑j

as required. Now the summations are over the edges of , and the algorithm is time. Thus we have

###### Theorem 5.

Given a cocomparability graph on vertices, we can compute the number of its independent sets in time .

###### Proof.

Lemmas 2 and 3 imply that, for all , the sets defined by the recurrence contains all independent sets of , especially is the set of all independent sets of . It remains to show that . To see this we observe that the unions over all are always disjoint by Lemma 4.

Our algorithm just recurrences for for all in the order of linear extension of . Then is the number of independent sets of . Assuming additions can be performed in constant time, this takes time, since each edge or non-edge of is used exactly once in the recurrences. ∎

The alternative evaluation of the recurrences which leads to can be used in all the algorithms below, and we will not elaborate further on this.

On the other hand, we have the following.

###### Theorem 6.

It is #P-complete to count cliques in a cocomparability graph.

###### Proof.

Counting cliques in cocomparability graphs is equivalent to counting independent sets in comparabilty graphs. Bipartite graphs are a subclass of comparability graphs. It is #P-complete to count independent sets in bipartite graphs [12, 13]. ∎

In fact, even approximately counting cliques in cocomparability graphs appears to be hard, by the same argument, being equivalent to the canonical problem #BIS [4].

Finally, we note that counting independent sets in cocomparability graphs is equivalent to counting chains in partially ordered sets, and counting cliques is equivalent to counting antichains. See [12] and [4], where antichains are called downsets. Thus the results of this paper could be recast in the language of partial orders.

### 3.2 Maximal independent sets

Similarly we can compute the number of maximal independent sets. For every vertex let denote the set of maximal independent sets of with , and let . We can compute and as follows:

 B(⊥) ={∅} b(⊥) =1 B(vi) =⋃u≺⋅vi{S∪{v}∣S∈B(u)} b(vi) =∑u≺⋅vib(u) (i∈[1,n]) B(⊤) =⋃u≺⋅⊤B(u) b(⊤) =∑u≺⋅⊤b(u)

The only difference to and is that the partial order is replaced by its cover relation , as anticipated in Lemma 1. For all and all maximal independent sets of the set is maximal independent if and only if there is no that is -between and , hence if and only if .

The recurrence for and can be shown to be correct by arguments similar to the ones given above to justify the recurrence for and .

###### Lemma 7.

For all every set is a maximal independent set of and implies .

###### Proof.

The base of the induction is for . Clearly is the unique independent set of .

Now let . Every set contains the vertex and vertices in for . By induction hypothesis is a maximal independent set of some . Therefore only contains vertices of . Moreover is a tight chain in . Since implies and because is transitive, and imply that is also a tight chain in and therefore a maximal independent set of .

A similar argument proves the assertion for . ∎

###### Lemma 8.

For every every maximal independent set of satisfies and implies .

###### Proof.

Let be a maximal independent set of . By Lemma 1, is a tight chain of with minimal element and maximal element . Therefore implies . We show by induction. For we have . Otherwise, by induction hypothesis and the tightness stated above, for some . Consequently we have . ∎

###### Theorem 9.

Given a cocomparability graph on vertices, we can compute the number of its maximal independent sets in time.

###### Proof.

Lemmas 7 and 8 imply that, for all , the sets defined by the recurrence contains indeed all maximal independent sets of , especially is the set of all maximal independent sets of .

It remains to show that . Again, the unions over all are always disjoint because holds for all , and by Lemma 4.

The time analysis is essentially the same as in the proof of Theorem 5. ∎

Corresponding to Theorem 6, we also have the following

###### Theorem 10.

It is #P-complete to count maximal cliques in a cocomparability graph.

###### Proof.

By the same argument as Theorem 6, using that it is #P-complete to count maximal independent sets in bipartite graphs [7]. ∎

### 3.3 Independent sets of size k

Next we consider independent sets of size exactly for some fixed value of . For every vertex and every integer , the set of independent sets of with and , and size , satisfy the following recurrences:

 C(⊥,0) ={∅} c(⊥,0) =1 C(⊥,i) =∅ c(⊥,i) =0 (i∈[1,k]) C(vj,0) =∅ c(vj,0) =0 (j∈[1,n]) C(vj,i) =⋃u≺vj{S∪{vj}∣S∈C(u,i−1)} c(vj,i) =∑u≺vjc(u,i−1) (i∈[1,k], j∈[1,n]) C(⊤,i) =⋃u≺⊤C(u,i) c(⊤,i) =∑u≺⊤c(u,i) (i∈[0,k])

The correctness of these recurrences is again based on the fact that, for every and every , every independent set of with and there is an independent set of of size for some , where if and otherwise is the -maximal vertex in . For we have because . Then we have the following.

###### Lemma 11.

For all and all every set is a independent set of with and .

###### Lemma 12.

For every every independent set of size is contained in .

###### Theorem 13.

Given a cocomparability graph on vertices and a number , we can compute the number of its independent sets of size exactly in time . In time we can do this for all .

###### Proof.

Lemmas 2 and 3 imply that, for all , the sets defined by the recurrence contains indeed all independent sets of , especially is the set of all independent sets of . It remains to show that . To see this we observe that the unions over all are always disjoint by Lemma 4.

Our algorithm just evaluates the sums for for all in an order that is a linear extension of . Then is the number of independent sets of . Assuming additions can be performed in constant time, this takes time. ∎

As a by-product the algorithm of Theorem 13 computes the size of a maximum independent set of , which is , and the number of maximum independent set in , which is . Since every maximum independent set is also maximal, the algorithm from Theorem 17 can be used as well and should be faster on average.

Once the number of independent sets of size exactly has been determined for all we can evaluate the independent set polynomial for all values of .

We also have the following fixed-parameter hardness result for counting -cliques in cocomparability graphs.

###### Theorem 14.

It is #W[1]-complete to count -cliques in a cocomparability graph.

###### Proof.

By the same argument as Theorem 6, using that it is #W[1]-complete to count independent sets of size in bipartite graphs [3, Theorem 4]. ∎

### 3.4 Maximal independent sets of size k

For every vertex and every integer , let be the set of maximal independent sets of with and , and . We have

 D(⊥,0) ={∅} d(⊥,0) =1 D(⊥,i) =∅ d(⊥,i) =0 (i∈[1,k]) D(vj,0) =∅ d(vj,0) =0 (j∈[1,n]) D(v,i) =⋃u≺⋅v{S∪{v}∣S∈D(u,i−1)} d(v,i) =∑u≺⋅vd(u,i−1) (i∈[1,k],j∈[1,n]) D(⊤,i) =⋃u≺⋅⊤D(u,i) d(⊤,i) =∑u≺⋅⊤d(u,i) (i∈[0,k])

The following are proved similarly to the correponding results above.

###### Lemma 15.

For all and all every set is a maximal independent set of with and .

###### Lemma 16.

For every and every maximal independent set of size in is contained in , and implies .

###### Theorem 17.

Given a cocomparability graph on vertices and a number , we can compute the number of its maximal independent sets of size exactly in time . In time we can do this for all .

We have no corresponding hardness result in this case, since the complexity of counting maximal -independent sets in bipartite graphs appears to be open.

## 4 Comparability graphs

Counting independent sets in a cocomparability graph is equivalent to counting cliques in its complement . Since our algorithms are symmetrical between and , all the results of section 3 remain true by interchanging the words “cocomparability” and “cocomparability”, and the words “clique” and “independent set”. Therefore, we will not detail the modified results.

## 5 Permutation graphs

Permutation graphs are both comparability and cocomparability graphs, so the algorithms of section 3 are valid both for counting independent sets in permutation graphs and (with obvious modifications) for counting cliques in permutation graphs. The result of [9] for counting independent sets in bipartite permutation graphs is a special case.

## References

• [1] Andreas Brandstädt, Van Bang Le, and Jeremy P. Spinrad, Graph Classes: A Survey. SIAM Monographs on Discrete Mathematics and Application, Philadelphia (1999).
• [2] Derek G. Corneil, Stephan Olariu and Lorna Stewart, Asteroidal triple-free graphs. SIAM Journal on Discrete Mathematics 10 (1997), pp. 399-430.
• [3] Radu Curticapean, Holger Dell, Fedor V. Fomin, Leslie Ann Goldberg and John Lapinskas, A fixed-parameter perspective on #BIS, in Proc. 12th International Symposium on Parameterized and Exact Computation (IPEC 2017), Leibniz International Proceedings in Informatics (LIPIcs) 89 (2018), 13:1–13:13.
• [4] Martin Dyer, Leslie Ann Goldberg, Catherine Greenhill and Mark Jerrum, On the relative complexity of approximate counting problems, Algorithmica 38 (2003) 471–500.
• [5] Ekkehard Köhler and Lalla Mouatadid, Linear time LexDFS on cocomparability graphs, in: Algorithm Theory (SWAT 2014), Springer LNCS 8503 (2014) 319–330.
• [6] Dieter Kratsch, Ross Mcconnell, Kurt Mehlhorn and Jerry Spinrad, Certifying algorithms for recognizing interval graphs and permutation graphs, SIAM Journal on Computing 36 (2003), 326–353.
• [7] Min-Sheng Lin, Counting independent sets and maximal independent sets in some subclasses of bipartite graphs, Discrete Applied Mathematics, 2018.
• [8] Min-Sheng Lin and Chien-Min Chen, Counting independent sets in tree convex bipartite graphs. Discrete Applied Mathematics 218 (2017) 113–122.
• [9] Min-Sheng Lin and Chien-Min Chen, Linear-time algorithms for counting independent sets in bipartite permutation graphs. Information Processing Letters 122 (2017) 1–7.
• [10] Ross M. McConnell and Jeremy P. Spinrad, Linear-time modular decomposition and efficient transitive orientation of comparability graphs. Proceedings of the 5th Annual ACM-SIAM Symposium on Discrete Algorithms, (1994) 536–545.
• [11] Yoshio Okamoto, Takeaki Uno and Ryuhei Uehara, Counting the number of independent sets in chordal graphs. Journal of Discrete Algorithms 6 (2008) 229–242.
• [12]

J. Scott Provan and Michael O. Ball, The complexity of counting cuts and of computing the probability that a graph is connected.

SIAM Journal on Computing 12 (1983) 777–788.
• [13] Salil Vadhan, The complexity of counting in sparse, regular, and planar graphs, SIAM Journal on Computing 31 (2001), 398–427.