File Exchange

image thumbnail

k-clique algorithm

version 1.3 (2.68 KB) by

k-clique community detection algorithm

18 Downloads

Updated

View License

k-clique algorithm as defined in the paper "Uncovering the overlapping community structure of complex networks in nature and society" - G. Palla, I. Derényi, I. Farkas, and T. Vicsek - Nature 435, 814–818 (2005)

[X,Y,Z] = k_clique(k,A)

Inputs:
k - clique size
A - adjacency matrix

Outputs:
X - detected communities
Y - all cliques (i.e. complete subgraphs that are not parts of larger complete subgraphs)
Z - k-clique matrix

Comments and Ratings (8)

Fan Zhang

Hi,

In line 61, why only the 'i = size(C,1)' clique is recorded? Is it supposed to be 'for i = 1:size(C,1)'?

thanks!!!

Shukai Ni

Shukai Ni

SAMUEL HEROY

I am confused. I created an adjacency matrix that generates a 2x4 scaffold with 8 pairwise adjacent 3-cliques. (My adj matrix is
0 1 1 1 0 0 0 0
1 0 0 1 0 0 0 0
1 0 0 1 1 0 0 0
1 1 1 0 1 1 0 0
0 0 1 1 0 1 1 1
0 0 0 1 1 0 0 1
0 0 0 0 1 0 0 1
0 0 0 0 1 1 1 0
).
However, the cliques output only returns four entries when I query for 3-cliques and associated communities:
[1,3,4]
[3,4,5]
[4,5,6]
[5,7,8]
By my understanding of this algorithm's intention, shouldn't there be four more entries here--and one large community that spans the network?

learn learn

i found after execute the code source this result. but i can't well understand what's mean.
M

M =

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

>> m=4;
>> [X,Y,Z] = k_clique(m,M)

X =

[1x7 double]
[1x4 double]

Y =

[1x5 double]
[1x4 double]
[1x4 double]
[1x4 double]
[1x3 double]
[1x3 double]

Z =

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

>>

The result is correct. In fact, the algorithm first extracts all complete subgraphs that are not parts of larger complete subgraphs. These maximal complete subgraphs are called "cliques". I'll modify the description. Thank you.

YANG

YANG (view profile)

I have a question
if A is 4*4 complete graph
[X,Y,Z] = k_clique(3,A);
Y is [1 2 3 4] and not find all cliques of size 3

Updates

1.3

description changed

1.2

add comments

MATLAB Release
MATLAB 7.10 (R2010a)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Win prizes and improve your MATLAB skills

Play today