Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
splichte committed Sep 3, 2013
1 parent 75d4bb8 commit 66bac7b
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 67 deletions.
66 changes: 0 additions & 66 deletions T.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ def get_right_neighbor(self, p):
if self.root.value is None:
return None
return self.root.get_right_neighbor(p)
def get_neighbors(self, p):
if self.root.value is None:
return (None, None)
return self.root.get_neighbors(p)
def insert(self, key, s):
if self.root.value is None:
self.root.left = Node(s, None, None, self.root)
Expand Down Expand Up @@ -223,68 +219,6 @@ def get_right_neighbor(self, p):
return n
return neighbor

# gets neighbors of a point p; that point may or may not be in a segment in T
def get_neighbors(self, p):
neighbors = [None, None]
n = self
if n.left is None and n.right is None:
return neighbors
last_left = None
last_right = None
found = False
while not found:
c = n.compare_to_key(p)
if c < 1 and n.left:
n = n.left
last_left = n.parent
elif c==1 and n.right:
n = n.right
last_right = n.parent
else:
found = True
# now at a leaf node?
if (not n.left) and (not n.right):
c = n.compare_to_key(p)
if c==0:
if n is n.parent.right:
goleft = None
if last_left:
goleft = last_left.right
return self.get_lr(goleft, n.parent.left)
else:
goright = None
if last_right:
goright = last_right.left
return self.get_lr(n.parent.right, goright)
elif c==-1:
neighbors[1] = n
if n is n.parent.right:
neighbors[0] = self.get_lr(None, n.parent.left)[0]
else:
if last_right:
neighbors[0] = self.get_lr(None, last_right.left)[0]
else:
neighbors[0] = n
if n is n.parent.left:
neighbors[1] = self.get_lr(n.parent.right, None)[1]
else:
if last_left:
neighbors[1] = self.get_lr(last_left.right, None)[1]
else:
if c < 1:
goright = None
goleft = n.right
if last_right:
goright = last_right.left
return self.get_lr(goleft, goright)
else:
goleft = None
goright = n.left
if last_left:
goleft = last_left.right
return self.get_lr(goleft, goright)
return neighbors

# travels down a single direction to get neighbors
def get_lr(self, left, right):
lr = [None, None]
Expand Down
2 changes: 1 addition & 1 deletion lsi.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def handle_event_point(p, segs, q, t, intersections):

# means only L_p -> check newly-neighbored segments
if len(merge_UC) == 0:
neighbors = (t.get_left_neighbor(p), t.get_right_neighbor(p))#t.get_neighbors(p)
neighbors = (t.get_left_neighbor(p), t.get_right_neighbor(p))
if neighbors[0] and neighbors[1]:
find_new_event(neighbors[0].value, neighbors[1].value, p, q)

Expand Down

0 comments on commit 66bac7b

Please sign in to comment.