Created
December 10, 2015 03:05
-
-
Save BrendanBenshoof/af5ddae03ac04784b2ff to your computer and use it in GitHub Desktop.
Implementation of DGVH algorithm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def getApproxDelaunayPeers(candidates,center): | |
""" | |
This is the Distrubuted Greedy Voronoi Heuristic. | |
center is some point in a space (we don't really care which) and the | |
heuristic decides which of the candidates are members of Delaunay | |
Triangulations with the center point. | |
This allows a node located at center to quickly figure out its | |
Voronoi region. | |
Error rate: Our heuristic underestimates approximately edge per node | |
""" | |
if len(candidates) < 2: | |
return candidates | |
sortedCandidates = sorted(candidates,key=lambda x: distance(x,center)) | |
peers = [sortedCandidates[0]] #create a new list, initialized closest peer | |
sortedCandidates = sortedCandidates[1:] | |
for c in sortedCandidates: | |
accept = True | |
for p in peers: | |
if distance(c,p) < distance(c,center): # if occluded by previous peer | |
accept = False | |
break | |
if accept: | |
peers.append(c) | |
return peers |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment