MCPcopy Create free account
hub / github.com/RocketMap/RocketMap / cluster

Function cluster

Tools/Spawnpoint-Clustering/cluster.py:98–114  ·  view source on GitHub ↗
(spawnpoints, radius, time_threshold)

Source from the content-addressed store, hash-verified

96 return True
97
98def cluster(spawnpoints, radius, time_threshold):
99 clusters = []
100 diameter = 2 * radius
101
102 for p in spawnpoints:
103 if len(clusters) == 0:
104 clusters.append(Spawncluster(p))
105 else:
106 c = min(clusters, key=lambda x: cost(p, x, time_threshold))
107
108 if check_cluster(p, c, radius, time_threshold):
109 c.append(p)
110 else:
111 c = Spawncluster(p)
112 clusters.append(c)
113
114 return clusters
115
116def test(cluster, radius, time_threshold):
117 assert cluster.max_time - cluster.min_time <= time_threshold

Callers 1

mainFunction · 0.85

Calls 4

appendMethod · 0.95
SpawnclusterClass · 0.85
costFunction · 0.85
check_clusterFunction · 0.85

Tested by

no test coverage detected