Skip to content

Commit

Permalink
adding time for each key
Browse files Browse the repository at this point in the history
  • Loading branch information
elro77 committed Dec 15, 2021
1 parent 4ec5248 commit 133f91f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
15 changes: 11 additions & 4 deletions DBSCAN_Main.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,18 @@
My clustering 44 seconds
for 10,000 points -> optimal clustering 2.72 seconds
My clustering 178 seconds
My clustering 178 seconds
== Version 1.03,
for 3000 points -> optimal clustering 0.287 seconds
My clustering 16.4 seconds
for 5000 points -> optimal clustering 0.605 seconds
My clustering 44 seconds
for 10,000 points -> optimal clustering 2.72 seconds
My clustering 178 seconds
"""

Expand Down Expand Up @@ -76,8 +85,6 @@
#============ my implementation =============
t = time.time()
dbscan = CMyDBSCAN(len(testArray), 3, 2)
elapsed = time.time() - t
print("creation: ",elapsed)
clusteringResult = dbscan.startClustering(testArray)
elapsed = time.time() - t
print("my clustering time: ",elapsed)
Expand Down
17 changes: 13 additions & 4 deletions MyDBSCAN.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
import math
import time

"""
t = time.time()
elapsed = time.time() - t
print("creating graph time: ",elapsed)
"""



class CMyDBSCAN:
def __init__(self, _size, _eps ,_minPoints):
#arrays
Expand All @@ -21,11 +29,7 @@ def __init__(self, _size, _eps ,_minPoints):


def startClustering(self, dataSet):
t = time.time()
self.createGraph(dataSet)
elapsed = time.time() - t
print("creating graph time: ",elapsed)

t = time.time()
for pIndex in range(len(dataSet)):
if(pIndex in self.connectionsDictionary) == False:
Expand Down Expand Up @@ -102,6 +106,8 @@ def initGridDictionary(self, data):

def initGraph(self, data):
for key in self.gridDictionary:
print("start key: ",key)
t = time.time()
for pIndex in range(len(self.gridDictionary[key])):
for qIndex in range(pIndex + 1, len(self.gridDictionary[key])):
p = self.gridDictionary[key][pIndex]
Expand All @@ -118,6 +124,9 @@ def initGraph(self, data):

self.connectionsDictionary[p].append(q)
self.connectionsDictionary[q].append(p)
elapsed = time.time() - t
print("time passed for key" ,key, ": ",elapsed)




Expand Down

0 comments on commit 133f91f

Please sign in to comment.