Code covered by the BSD License  

Highlights from
Maximal Cliques

3.5

3.5 | 2 ratings Rate this file 21 Downloads (last 30 days) File Size: 3.55 KB File ID: #19889

Maximal Cliques

by Ahmad

 

12 May 2008 (Updated 31 May 2010)

Finds all the maximal complete sub-graphs (maximal cliques) in a graph

| Watch this File

File Information
Description

The graph passed must be an upper rectangular square matrix. Each row of a matrix denotes the presence of an edge with 1, and an absence of it with 0. The row and col no. of an edge denotes the connecting nodes. Given this matrix, this function finds all the maximal complete sub-graph (a set of nodes amongst all the nodes which form a complete sub-graph i.e. every node connects to every other) also known as cliques. A maximal graph is returned since every complete sub-graph will also have smaller complete sub-graphs inside itself. NOTE: this function would not return single node sub-graphs, although every isolated node, in concept, also forms a complete sub-graph.

The function returns all the sub-graphs in a cell-array, where each row denotes a new sub-graph

Acknowledgements
This submission has inspired the following:
Bron-Kerbosch maximal clique finding algorithm
MATLAB release MATLAB 7.9 (2009b)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (3)
02 Dec 2008 Henry Wolkowicz

I have only tested the file a few times. It works well, but there should be a warning that it slows down quickly, i.e. 40 nodes can already be too much. Of course, finding all the cliques is an NP-hard problem so that is not a surprise. But, ... a warning would help.

07 Dec 2008 Ahmad

@Henry
Warning added and the no. of nodes can be set by WARNING_CONNECTING_NODES_LENGTH .... which defaults to 20.

I have done this since an NP-hard problem's actual computability would vary from machine to machine

26 Apr 2009 Yonit Marcus  
Please login to add a comment or rating.
Updates
14 Aug 2008

Fixed critical bug

02 Dec 2008

Bug in nchoosek, while looping to get connecting nodes.
Plus put a warning if a large computation is given for nchoosek

13 Feb 2009

Fixed bug ... was missing some maximal cliques whose nodes were part of some overlapping cliques. Thanks to

15 Feb 2009

Was missing some maximal cliques whose nodes were part of some overlapping cliques. Thanks to Matej

30 May 2010

Fixed some critical problems which didn't give the full set of maximal cliques (thanks Carlos). Although the code is now becoming slow - so tune in later for a revamp of the algo.

31 May 2010

Some speedups!

31 May 2010

Complete revamp of the algorithm. Affords computation on bigger graphs + on average 70% speedup on both sparse and dense adjacency graphs! Plus now the user can provide the maximum graph size wanted for maximal cliques.

Tag Activity for this File
Tag Applied By Date/Time
complete subgraph Ahmad 22 Oct 2008 10:00:51
clique Ahmad 22 Oct 2008 10:00:51
square Ahmad 22 Oct 2008 10:00:51
rectangular Ahmad 22 Oct 2008 10:00:51
graph Ahmad 01 Jun 2010 09:35:39

Contact us at files@mathworks.com