Algorithm to generate all independent sets of an undirected graph?

1.3k Views Asked by At

We need an algorithm to generate all independent sets of an undirected graph.

For example:

enter image description here

We tried to use 'Bron-Kerbosch' algorithm, but do not understand how to interpret the result.

Input:

A = [1 2; 1 5; 2 3; 2 5; 3 4; 4 5; 4 6]

Desired Output:

B = [1 3 6; 1 4; 2 4; 2 6; 3 5 6]

How to interpret the result?

Thank you!

1

There are 1 best solutions below

0
On

Just realised how to solve it....

Input:

A = [1 2; 2 3; 3 4; 4 5; 4 6]

Convert to adjacency matrix:

 0     1     0     0     1     0
 1     0     1     0     1     0
 0     1     0     1     0     0
 0     0     1     0     1     1
 1     1     0     1     0     0
 0     0     0     1     0     0

BK_MaxIS Output:

 1     1     0     0     0
 0     0     1     1     0
 1     0     0     0     1
 0     1     1     0     0
 0     0     0     0     1
 1     0     0     1     1

Where row i of column j is 1, the vertex i participates in the maximal independent set indexed by column j.

That means:

B = [1 3 6; 1 4; 2 4; 2 6; 3 5 6]