SNNDPC
Shared Nearest Neighbor-based Clustering by Fast Search and Find of Density Peaks
Install / Use
/learn @liurui39660/SNNDPCREADME
Shared-Nearest-Neighbor-Based Clustering by Fast Search and Find of Density Peaks
C++ and Python implementation of SNNDPC algorithm.
The Matlab version is moved to the branch MatlabImplementation.
Demo
If you use Windows:
- Open a Visual Studio developer command prompt
- Because of the toolchain paths
cdto project rootSNNDPC/cmake -DCMAKE_BUILD_TYPE=Release -G "NMake Makefiles" -S . -B build\releasecmake --build build\release --target Demobuild\release\Demo.exe
The demo runs on the S2 dataset.
If CMake complains about its version, modify SNNDPC/CMakeLists.txt:1 to fit your CMake version.
To use other datasets, see Customization
Environment
Some highlighted requirements.
- Python: 3.8, because of
:=syntax - IntelTBB: Optional, for parallelization
- OpenMP: Optional, for parallelization
Customization
Provided Dataset
To use other provided datasets in demo:
-
Modify variable
pathDataatSNNDPC/Demo.cpp:11.- Macro
SOLUTION_DIRis the absolute path toSNNDPC/.
- Macro
-
Modify variables
k,n,d, andncaccording to the paper| Variable | Reference | | -------- | --------------------------------- | |
k| Table 4, column Arg- | |n| Table 2, column No. of records | |d| Table 2, column No. of attributes | |nc| Table 2, column No. of clusters |
External Dataset + Demo.cpp
To use external datasets in Demo.cpp:
- Make sure your dataset has exactly 3 columns: x, y, and label.
- If you want to use more attributes, you need to edit the
fscanfcall atDemo.cpp:24.
- If you want to use more attributes, you need to edit the
External Dataset + Custom Runner
To use external datasets in a custom runner:
- Load your dataset into a (flattened) 1D C-style array
data, shape[n×d].- For the logical 2D array, each row is a record, and each column is an attribute.
- Include
SNNDPC.hpp. - Call the
SNNDPC()with parametersk,n,d,nc, anddata. - The function will return two pointers, the centroids and the assignment.
- Both are a 1D array.
- Both are created by
new, you need to manually delete them to prevent memory leak.
Contact
If you have any inquiries, please open an issue instead of sending emails directly to me. My email address on the paper is no longer frequently checked.
Related Skills
node-connect
350.8kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
110.4kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
350.8kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
350.8kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
