dbscan results
This commit is contained in:
@@ -2,17 +2,18 @@
|
||||
#include <atomic>
|
||||
#include <cmath>
|
||||
#include <iostream>
|
||||
#include <omp.h>
|
||||
|
||||
namespace HPC {
|
||||
|
||||
DBSCAN::DBSCAN(int minPts, double eps) : minPoints_(minPts), epsilon_(eps) {}
|
||||
|
||||
void DBSCAN::run(const std::vector<Point> &points) {
|
||||
void DBSCAN::run(const std::vector<Point> &points, int threadNum) {
|
||||
|
||||
dataset_ = points;
|
||||
const int n = dataset_.size();
|
||||
|
||||
initializeNeighbors();
|
||||
initializeNeighbors(threadNum);
|
||||
|
||||
int clusterIndex = 0;
|
||||
for (int i = 0; i < n; ++i) {
|
||||
@@ -52,8 +53,8 @@ bool DBSCAN::expandCluster(Point &p, std::set<int> &neighbours, int clusterID) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void DBSCAN::initializeNeighbors() {
|
||||
#pragma omp parallel for
|
||||
void DBSCAN::initializeNeighbors(int threadNum) {
|
||||
#pragma omp parallel for num_threads(threadNum)
|
||||
for (int i = 0; i < dataset_.size(); ++i) {
|
||||
Point &pointToCheckNeighborsFor = dataset_[i];
|
||||
for (int j = 0; j < dataset_.size(); ++j) {
|
||||
|
||||
@@ -12,13 +12,13 @@ class DBSCAN {
|
||||
public:
|
||||
DBSCAN(int minPts, double eps);
|
||||
|
||||
void run(const std::vector<Point> &points);
|
||||
void run(const std::vector<Point> &points, int threadNum);
|
||||
|
||||
const std::vector<Point> &getPoints() const { return dataset_; }
|
||||
|
||||
private:
|
||||
std::set<int> regionQuery(const Point &point) const;
|
||||
void initializeNeighbors();
|
||||
void initializeNeighbors(int threadNum);
|
||||
bool expandCluster(Point &point, std::set<int> &neighbours, int clusterID);
|
||||
|
||||
// void merge(std::vector<int>& n, const std::vector<int>& nPrime) const;
|
||||
|
||||
@@ -10,23 +10,25 @@ int main() {
|
||||
|
||||
std::vector<Point> points = readPointsFromFile("data");
|
||||
|
||||
// Zeitmessung starten
|
||||
auto start = std::chrono::high_resolution_clock::now();
|
||||
|
||||
|
||||
DBSCAN ds(5, 0.01);
|
||||
ds.run(points);
|
||||
for (int i = 1; i < 13; i++) {
|
||||
DBSCAN ds(5, 0.01);
|
||||
// Zeitmessung starten
|
||||
auto start = std::chrono::high_resolution_clock::now();
|
||||
|
||||
ds.run(points, i);
|
||||
|
||||
|
||||
// Zeitmessung beenden
|
||||
auto end = std::chrono::high_resolution_clock::now();
|
||||
// Zeitmessung beenden
|
||||
auto end = std::chrono::high_resolution_clock::now();
|
||||
|
||||
// Dauer berechnen in Millisekunden
|
||||
auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
|
||||
|
||||
std::cout << "Laufzeit: " << duration << " ms" << std::endl;
|
||||
|
||||
|
||||
writePointsToFile(ds.getPoints(), "clustered");
|
||||
// Dauer berechnen in Millisekunden
|
||||
auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
|
||||
|
||||
std::cout << "Laufzeit: " << duration << " ms" << std::endl;
|
||||
writePointsToFile(ds.getPoints(), "clustered");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
1
lab07/results/dbscna_results.csv
Normal file
1
lab07/results/dbscna_results.csv
Normal file
@@ -0,0 +1 @@
|
||||
6807,4929,3753,3380,3148,2864,2796,2655,2702,2494,2482,2414
|
||||
|
Reference in New Issue
Block a user