Code covered by the BSD License  

Highlights from
Bron-Kerbosch maximal independent set and maximal clique algorithms

Be the first to rate this file! 36 Downloads (last 30 days) File Size: 4.24 KB File ID: #24591

Bron-Kerbosch maximal independent set and maximal clique algorithms

by Berk Birand

 

29 Jun 2009 (Updated 18 Jan 2012)

Lists all the maximal independent sets and the maximal cliques of a graph

| Watch this File

File Information
Description

Maximal Independent Sets and Maximal Cliques are useful in many applications. The naive way of listing them can be very computationally intensive. This package contains two functions, BK_MaxIS and BK_MaxClique, that use the Bron-Kerbosch algorithm to list all the maximal independent sets and maximal cliques of a given graph, respectively.

The input to the functions is the adjacency matrix of the desired graph (http://mathworld.wolfram.com/AdjacencyMatrix.html).

The return value is a 0-1 matrix, where each column corresponds to a maximal matching, and each row to a vertex. The size of the matrix is thus m*n, where m is the number of vertices in the graph, and n is the number of maximal independent sets. A value of 1 in position (i,j) indicates that vertex i is active in the maximal independent set (or clique) indexed by column j.

Examples:

To find the maximal independent sets of a 3-path:

>> A = [0 1 0;1 0 1;0 1 0]
>> BK_MaxIS(A)

ans =

     1 0
     0 1
     1 0

To find the maximal cliques of a 4-cycle C_4:

>> A = [0 1 0 1;1 0 1 0;0 1 0 1;1 0 1 0];
>> BK_MaxClique(A)

ans =

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

Acknowledgements
This submission has inspired the following:
Bron-Kerbosch maximal clique finding algorithm
MATLAB release MATLAB 7.7 (R2008b)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (1)
19 Dec 2011 MIndaugas

can someone give exmaple how to write graph bicause i cant get it work

Please login to add a comment or rating.
Updates
16 Jul 2010

Removed the dependency on Matgraph. Only the adjacency matrix of the graph is now needed to compute the independent sets.

20 Oct 2010

Fixed the duplicates in the file.

18 Jan 2012

Fixed a small bug for obtaining the neighbors of a node. Also added the maximal clique function that uses the complement of a graph.

Tag Activity for this File
Tag Applied By Date/Time
graph theory Berk Birand 30 Jun 2009 13:10:35
maximal independent set Berk Birand 30 Jun 2009 13:10:35
matgraph Berk Birand 30 Jun 2009 13:10:35
bronkerbosch Berk Birand 30 Jun 2009 13:10:35
maximal stable set Berk Birand 30 Jun 2009 13:10:35
bronkerbosch Gavin 24 May 2010 04:17:22
maximal clique Berk Birand 19 Jan 2012 12:41:09

Contact us at files@mathworks.com