File Exchange

image thumbnail

Fast and efficient spectral clustering

version (11.3 MB) by Ingo
Perform fast and efficient spectral clustering algorithms


Updated 13 Sep 2012

View License

SpectralClustering performs one of three spectral clustering algorithms (Unnormalized, Shi & Malik, Jordan & Weiss) on a given adjacency matrix. SimGraph creates such a matrix out of a given set of data and a given distance function.

UPDATE 09/13/2012

This major update to the final version includes
[+] Full GUI
[+] Several Plot Options: 2D/3D, Star Coordinates, Matrix Plot
[+] Save Plots
[+] Save and Load all kind of data (pure data, similarity graph, clustered data)
[+] Differentiates between already labeled and unlabeled data (see README).

The code has been optimized (within Matlab) to be both fast and memory efficient. Please look into the files and the Readme.txt for further information.

- Ulrike von Luxburg, "A Tutorial on Spectral Clustering", Statistics and Computing 17 (4), 2007

If there are any questions or suggestions, I will gladly help out. Just contact me at admin (at) airblader (dot) de

Comments and Ratings (23)

a a

It shows :
Error using kmeans (line 167)
Invalid data type. The first argument to KMEANS must be a real array.

(I tried using W= SpectralClustering([[0,0.1,0];[0.1,0.1,0.1];[0.1,0,0]],2,2)
The U matrix is imaginary

Amazing job, thank you so much, it helped a lot.


It gives the following error when dataset is loaded. I loaded .csv file

Error using csvread (line 34)
File not found.

Error in guiMain>btnLoadData_Callback (line 51)
handles.Data = csvread(fullfile(relativepath(handles.PathName), ...

Error in gui_mainfcn (line 95)

Error in guiMain (line 18)
gui_mainfcn(gui_State, varargin{:});

Error in @(hObject,eventdata)guiMain('btnLoadData_Callback',hObject,eventdata,guidata(hObject))

Error while evaluating uicontrol Callback

Please help

Zhou Yirong


It has a error when run it.

??? Error: File: D:\MATLAB7\work\SpectralClustering\files\GUI\guiMain.m Line: 22 Column: 38
Missing variable or function.
Error in ==> Main at 15
How should i do?

qiang shang

Fanxing Ji

Thank you very much



@Hanan That sure will be a test and I assume you need a good computer, but I think it should be possible. You would just have to test it, though.

does this package supports "large" datasets of 100,000 rows on 500 columns?


This program fails on Matlab's Linux version since the relativepadth() function returns the relative path in lower letters.

The solution is to use an improved version of relativepath such as this one:



@BD Knight: Take a look at the SpectralClustering.m and the SimGraph_xxx.m files. Those are really all you need and they are well documented.

Eric T

Instructions on using command line? I need clustering embedded deeply in other tasks, multiple times, so using a GUI is not an option.


@leile: The code supports data with any dimension. By the way, a major update will be released as soon as I handed my thesis in. This will include a fully functional GUI.


Does the code support 3d data?


Yo Yo

Jeff H

Nicely done; simple and efficient code.


Final update including full GUI and more. See description for details.

Included acknowledgements

- Fixed critical mistake when creating similarity graphs

- Restructured some of the code

Fixed critical bug when creating sparse matrices

Demo now plots similarity graph (only use for few data points!)

Minor changes

fixed wrong code in demo file

Got rid of redundant code

Minor updates

- Updated some files
- Included Demo

MATLAB Release Compatibility
Created with R2011b
Compatible with any release
Platform Compatibility
Windows macOS Linux