ORTHANT NEIGHBORHOOD GRAPHS
A Decentralized Approach for Proximity Queries in Dynamic Point Sets
Tobias Germer and Thomas Strothotte
Department of Simulation and Graphics, Otto-von-Guericke University of Magdeburg, Germany
Keywords:
Dynamic Point Sets, Proximity Queries, Range Searching, Geometric Spanners, Particle Systems.
Abstract:
This work presents a novel approach for proximity queries in dynamic point sets, a common problem in com-
puter graphics. We introduce the notion of Orthant Neighborhood Graphs, yielding a simple, decentralized
spatial data structure based on weak spanners. We present efficient algorithms for dynamic insertions, dele-
tions and movements of points, as well as range searching and other proximity queries. All our algorithms
work in the local neighborhood of given points and are therefore independent of the global point set. This
makes ONGs scalable to large point sets, where the total number of points does not influence local operations.
1 INTRODUCTION
In computer graphics, many methods rely on dynamic
point sets. One example are particle systems, where
individual particles can be considered as points mov-
ing through space (Reeves, 1983). A more com-
plex example are multi-agent systems, where each ob-
ject has some complex behavior (Schlechtweg et al.,
2005). A common task in these systems is to find
all neighbors in a defined neighborhood or the nearest
neighbor for a particle or agent. This paper introduces
a novel method to efficiently handle such proximity
queries in dynamic point sets.
Our goal is to develop a simple and efficient data
structure that maintains dynamic point sets. It should
provide fast access to the local neighborhood for each
point. Moreover, it should support big point sets com-
monly occurring in particle or agent systems. Popu-
lar approaches for this problem include (hierarchical)
space partitioning techniques like octrees or bucket
grids. However, these methods are either inflexible,
do not perform well in dynamic settings, or do not
scale well for large point sets.
We present an alternative paradigm which pro-
vides a flexible, decentralized approach for proxim-
ity queries in dynamic point sets. The main idea is to
use a very simple, graph-based data structure with low
memory footprint. We provide efficient algorithms
which act in the local neighborhood of the points.
This makes them input and output sensitive, as well as
scalable to large point sets. Therefore, local changes
in the point configuration only result in local changes
in the data structure. Local operations like searching
all neighbors in a given radius or moving a point a
small (local) distance do not depend on the total size
of the point set. This makes our approach suitable
for dynamic particle or agent systems, where typical
movements are relatively small and local.
Our approach is novel and poses many unresolved
questions. The goal of this paper is to introduce the
basic ideas and to describe the principles of our al-
gorithms. Due to space constraints, we have to omit a
thorough analysis here. We also have to leave an eval-
uation and the application of our approach for future
work. Finally, we restrict our problem in this paper to
the 2D case, i.e., to planar point sets.
2 BACKGROUND
Tasks like locating points, finding their neighbors or
maintaining dynamic point sets are a common prob-
lem in computer graphics and computational geome-
try. Numerous approaches have been introduced and
analyzed, making spatial data structures an elaborate
area of research. We restrict our treatment of related
work to the most established techniques used in com-
puter graphics.
Uniform space subdivision: A simple way to speed
up proximity queries (Schlechtweg et al., 2005) or
collision detection (Kim et al., 1998) is to divide the
85
Germer T. and Strothotte T. (2007).
ORTHANT NEIGHBORHOOD GRAPHS - A Decentralized Approach for Proximity Queries in Dynamic Point Sets.
In Proceedings of the Second International Conference on Computer Graphics Theory and Applications - GM/R, pages 85-93
DOI: 10.5220/0002082800850093
Copyright
c
SciTePress
Figure 1: A complex example of an ONG for a point set with ca. 750 points.
space into equally sized buckets. Although simple
and often effective, this technique has a relatively
large memory footprint and doesn’t work well in set-
tings with varying search radius or inhomogeneous
point distributions.
Quad- and octrees: A widely used technique to
overcome these problems is to adaptively subdivide
space by quad-trees (resp. octrees). An overview of
different variations gives (Samet, 1990). (Boubekeur
et al., 2006) present a new approach combining quad-
and octrees.
BSP- and kd-trees are another class of popular tech-
niques, supporting very flexible space subdivision and
also working in higher dimensions (Bentley, 1990).
Bounding volume hierarchies: Instead of subdi-
viding space, bounding volume hierarchies like OBB-
Trees (Gottschalk et al., 1996) or BD-Trees (James
and Pai, 2004) approximate the input data hierarchi-
cally to accelerate collision detection, for example.
Although providing fast (logarithmic) access to
arbitrary leaf objects, all these tree-based approaches
have a global (centralized) structure and therefore de-
pend on the total number and structure of points. In-
stead, we seek for a data structure where local op-
erations do not depend on the global structure. In
general, tree-based approaches have also difficulties
maintaining dynamic objects like moving point sets.
Often the trees become inefficient or large parts have
to be rebuild after a series of insertions or deletions.
3 ONGS
The main inspiration for our approach are the prin-
ciples of swarm behavior and swarm intelligence
(Bonabeau et al., 1999). In biology, there are vari-
ous examples of large groups of animals like flocks
of birds or schools of fish which rapidly move
in global formations without collisions (Reynolds,
1987). However, a single animal has neither the
mental nor physical ability to track all other animals
and maintain a global view on the swarm as it steers
through space. Instead, every animal only knows its
local neighborhood, i.e., nearby animals and the lo-
cal environment. Every animal acts solely based on
this local information. However, the whole swarm
is connected through various neighborhoods. This
way, global information can be distributed using lo-
cal structures. Therefore, global patterns can emerge.
We adopt this principle to build a data structure
for point sets where each point tracks a limited, lo-
cal neighborhood. This results in a decentralized data
structure which provides local information. In addi-
tion, each point must have access to arbitrary large
(global) neighborhoods, if needed. This way, every
point indirectly knows the total point set. Thus, we
have two main requirement:
each point has a constant number of neighbors
each point must have access to every other point
To meet the first requirement, we store pointers
to all local neighbors for each point. The result is
a directed geometric graph, where the vertices corre-
spond to the points of the point set, and arcs represent
the neighborhood relationships.
The second requirement implies that the graph has
to be strongly connected. There must be a path (i.e.,
a chain of neighbors) connecting each vertex with ev-
ery other vertex. To meet this requirement, we have
to consider which vertices exactly are neighbors and
how many neighbors are required for each vertex.
To answer this question we use results about “t-
spanners” and “weak spanners” from (Fischer et al.,
1997; Fischer et al., 1998; Fischer et al., 1999). We
first review the relevant concepts. Geometric spanners
are important data structures in computational geome-
try, because they approximate the complete graph us-
ing only O(n) edges, where n denotes the number of
vertices (Arya et al., 1995). In our context, this means
that we can approximate global information about the
GRAPP 2007 - International Conference on Computer Graphics Theory and Applications
86
point set with local neighborhood relationships. A ge-
ometric graph G = (V, E) is called t-spanner, if for
each pair of vertices (u, v) V there exists a path in
E, which is no longer than t times the direct distance
between u and v. Thus, the (relative) length of the
path of any pair of vertices is bounded by the stretch
factor t. The complete graph is obviously a t-spanner
with t = 1. However, it has an out-degree of n 1 and
therefore takes O(n
2
) space. Instead, we need a low
and constant out-degree for our data structure to be
output sensitive.
One way to construct a t-spanner is to divide the
space around each vertex p into k cones and to create a
directed edge from p to the closest vertex in each cone
(Yao, 1982). It can be proved that the resulting graph
is a t-spanner for k > 6 cones (Ruppert and Seidel,
1991). Fischer et al. improve this value to k 4 by
introducing “weak spanners”. However, these graphs
only satisfy a weak spanner property. Here, not the
path length between any vertex pair is bounded, but
the distance from any vertex on the path to the start
vertex. Note that this graph must be strongly con-
nected. In the prove of this property for k 4, Fischer
et al. also show a way how to actually find a short path
between any two vertices.
We use the weak spanner construction from Fis-
cher et al. in a slightly adapted version. We divide the
(planar) space around each point p into the four quad-
rants Q
p
j
, j {NE, NW, SE, SW} defined by the coor-
dinate axes. We have to take care about the coordinate
axes themselves and assign them to unique quadrants.
Fischer et al. introduced a consistent scheme for this,
as illustrated in figure 2(a). We assume that there are
no coincident vertices. We use the Manhattan-metric
d
M
(p, v) = |p
x
v
x
| + |p
y
v
y
| to find the nearest
points v
j
Q
p
j
. The motivation to use the Manhattan-
metric is explained in section 4.5. Finally, we store
each v
j
as a local neighbor for p. Figure 2(a) illus-
trates this concept. The resulting structure also gen-
eralizes to higher dimensions. Therefore, we call it
“Orthant Neighborhood Graph” (ONG)
1
. This graph
has appealing properties:
Constant Outdegree: Each vertex has at most four
local neighbors. A graph with n vertices has at
most 4n edges.
Quadrant-based partition: By aligning the cones
with the four quadrants we can easily assign
points to cones using coordinate comparisons.
Employing only simple comparisons of constant
numbers also makes our approach robust.
Simple metric: The Manhattan-metric is simple
1
The concept of quadrants and octants generalized to ar-
bitrary dimensions is called “Orthant”.
p
Q
p
NE
Q
p
SE
Q
p
SW
Q
p
NW
(a) p links to the nearest
neighbor for each quadrant
Q. The coordinate axes
are assigned to Q
p
NW
respec-
tively Q
p
SE
s
Q
s
t
t
B
t
(b) t is located in quad-
rant Q
s
t
of s. The box B
t
contains all points nearer to
t than s according the the
Manhattan-metric.
Figure 2: Basic construction of ONGs.
and cheap to compute.
Weak spanner: The resulting graph is strongly
connected and has the weak spanner property.
To verify that ONGs are strongly connected, we
briefly sketch the main argument from the prove pre-
sented in (Fischer et al., 1998). Consider two vertices
s and t as illustrated in figure 2(b). To construct a
path from s to t, we consider the quadrant Q
s
t
of s, to
which t belongs. By definition, s must have a neigh-
bor n for this quadrant. If this neighbor is t, we are
done. Otherwise, there must be a neighboring vertex
n closer to s than t. We show, that by recursively fol-
lowing the neighbor n, we incrementally get closer to
t, until we reach t. Let B
t
= {x R
2
: d
max
(t, x)
d
max
(t, s)} be the square defined by the maximum-
metric d
max
(u, v) = max(
|
u
x
v
x
|
,
|
u
y
v
y
|
) (see fig-
ure 2(b)). Then, the neighbor n must be contained in
B
t
. There are three cases:
1. d
max
(t, n) < d
max
(t, s): The neighbor is inside B
t
and therefore closer to t. (see figure 3(a))
2. d
max
(t, n) = d
max
(t, s) and Q
s
t
= Q
n
t
: s is on the
border of B
t
and t is in the same quadrant with
respect to n
s
t
. Then, n is still nearer to t according
to the Manhattan-distance. (see figure 3(b))
3. d
max
(t, n) = d
max
(t, s) and Q
s
t
6= Q
n
t
: s is on the
border of B
t
and t has changed the quadrant with
respect to n. Then, we do not come closer to t
and B
t
stays the same. However, in the next step
of the path, the neighbor of n cannot be longer
on the border of B
t
, because our assignment of
coordinate axes to quadrants does not permit this.
Therefore, B
t
will get smaller in the next step. (see
figure 3(c))
This shows that the square B
t
gets smaller or stays
the same with each step along the path. However,
cases 2 and 3 ensure that B
t
can only stay constant
for a finite number of steps. Therefore, the path will
ORTHANT NEIGHBORHOOD GRAPHS - A Decentralized Approach for Proximity Queries in Dynamic Point Sets
87
s
t
n
B
t
B'
t
(a)
s
n
t
B
t
(b)
s
B
t
n
t
(c)
Figure 3: Cases for the location of neighbor n for vertex s.
finally reach t. We conclude this section with the fol-
lowing property of ONGs, which is important for the
algorithms presented in the next section:
Corollary 1 Given a vertex s in an ONG, any vertex
t in this ONG can be reached by recursively following
the neighbor of the quadrant, in which t is located.
4 ALGORITHMS
Having introduced the fundamental structure of
ONGs in the previous section, we now describe al-
gorithms for the dynamic construction of ONGs. We
first present the high level algorithms, then the low
level procedures and finally an efficient algorithm for
(localized) range searching using ONGs.
4.1 Insertion
First, we introduce two notations:
neigh
p
q
denotes the neighbor of vertex p saved for
quadrant q
quadrant
p
(s) returns the quadrant of p in which
vertex s is located
To insert a new vertex in an ONG, we have to insert
and change certain arcs of the graph, so that the ONG
stays consistent. We use the following algorithm:
Procedure
Insert(
Vertex s, Vertex p
)
.
Input: a starting vertex s, already inserted
Input: the new vertex p
if ONG is empty then1
insert p as the first vertex;2
return3
for each quadrant q of p do4
s
q
= search some point in q, starting at s;5
neigh
p
q
= nearest neighbor in q, starting at s
q
;6
if neigh
p
q
6=
/
0 then s = neigh
p
q
;7
search all vertices r
i
for which p is the new nearest8
neighbor;
for each r
i
do9
Quadrant q = quadrant
r
i
(p);10
neigh
r
i
q
= p;11
We first check if the ONG is empty. In this case,
p is the only vertex and there is nothing to change
(lines 1-3). Otherwise, we search the nearest neigh-
bors for each quadrant of p using the algorithm of
section 4.4, and save them as neighbors (lines 4-7).
By searching the nearest neighbors, we actually local-
ize p, i.e., we determine its local neighborhood. Note
that we need a given vertex s, where we begin our
search for start vertices s
q
in every quadrant, which
are then used to initialize the nearest neighbor search.
If we found a nearest neighbor, we use it as the start-
ing point for the next quadrant, because it is probably
close to the nearest neighbor in this quadrant.
Afterwards, we have to find all vertices r
i
in the
ONG, which have p as their new nearest neighbor
(line 8). Section 4.5 describes an algorithm for this.
Finally, we update these vertices and store p as their
nearest neighbor in the according quadrant. Note
that we first find all vertices r
i
before changing the
topology of the existing graph. If we would change
the topology (i.e., store p as the new nearest neigh-
bor) immediately after we found one r
i
, the topol-
ogy wouldn’t be consistent anymore, breaking the
assumptions for subsequent queries. Therefore, we
strictly separate queries using the ONG from chang-
ing the ONG.
4.2 Deletion
To delete a vertex p from the ONG, we have to change
all arcs pointing to p. We do this with the following
algorithm:
Procedure
Remove(
Vertex p
)
.
search all vertices r
i
for which p is a nearest1
neighbor;
for each r
i
do2
q
i
= quadrant
r
i
(p);3
s
i
= search second nearest neighbor in q
i
;4
for each r
i
do5
neigh
r
i
q
i
= s
i
;6
Note that we don’t have to localize p this time, be-
cause the local neighborhood (i.e., the nearest neigh-
bors) are already known. We first find all vertices r
i
,
for which p is a nearest neighbor (line 1). This is simi-
lar to line 8 of the insert algorithm and also detailed in
section 4.5. For all vertices r
i
we have to remove p as
a neighbor and store the second nearest neighbor in-
stead. Again, we have to separate the queries for the
second nearest neighbor (lines 2-4) from the change
of topology (lines 5-6). This results in a consistent
ONG where no arc points to p anymore. Therefore, p
can be removed.
GRAPP 2007 - International Conference on Computer Graphics Theory and Applications
88
4.3 Movement
Our goal for ONGs was to design a spatial data struc-
ture which can be used to maintain particle or agent
systems. A typical property of such systems is that the
entities (i.e., the vertices) are moving. We handle this
action by simply deleting the vertex and re-inserting
it at the new position:
Procedure
Move(
Vertex p, Vector v
)
.
Vertex s = some neighbor from p;1
Remove
(p);2
move p according to v;3
Insert
(s,p);4
This algorithm benefits from small movements of
vertices. We take some (old) neighbor of vertex p
(line 1) as the starting point for the re-insertion in
line 4. If the new position of p is relatively close to
the old position, the localization step of the insert pro-
cedure will be cheap (see next section). This way, the
algorithm becomes input sensitive: local movements
only traverse and change local parts of the ONG. The
downside is that chaotic, global movements traverse
very large parts of the ONG, degrading performance.
However, particle and agent systems mostly exhibit
small movements. Therefore, ONGs will be suitable
for such systems.
4.4 Neighbor Searching
One of the first steps of the insert algorithm is the lo-
calization of the new point p, where we search for the
nearest neighbors for each of its quadrants. This sec-
tion presents a simple and effective algorithm for this.
In contrast to centralized data structures like quad-
or kd-trees, ONGs do not provide a mechanism to
quickly locate arbitrary points in the point set. In-
stead, we have to iteratively traverse the local neigh-
borhood of certain vertices until we find the nearest
neighbor for p. The idea is to take a starting vertex s
and then “walk across” the graph in the direction of
p, until no closer vertex can be found anymore. We
need two more concepts for this algorithm:
Search regions: A search region is a rectangu-
lar region representing the “undiscovered” space.
Only in the search region new results can be
found. If the search region is empty, we have
found all result points. We can find all vertices in
a search region by using corollary 1: given a ver-
tex p, we can find all vertices in the search region
by recursively following all neighbors assigned to
the quadrants which intersect the search region.
Vertex flags: To avoid loops when traversing the
graph, we mark visited vertices with a flag, de-
noted as flag
p
for vertex p. Before finishing the
algorithm, we have to clear the flags again.
We now present our algorithm
NearestNeigh
for
finding the nearest neighbor to a point p (which is
not yet inserted) in the quadrant according to s, start-
ing at s. First, we save the quadrant q, for which
we search the nearest neighbor (line 1). Then, we
save the distance d of the nearest neighbor yet found
(which is s, at the beginning the starting point). After-
wards, we set up a search region R, where all possible
nearer neighbors to p could be found (line 4). Note
that R {x : x q d
M
(x, p) <= d
M
(x, s)}. We then
search for nearer neighbors by calling
nnInternal
for each quadrant q
i
of s. Note that we don’t have
to search in quadrant q, because all points in this
quadrant must have a greater distance to p than s. If
nnInternal
finds a new neighbor, it returns true and
we start our search again with the new, reduced search
region. If no new nearer neighbor could be found, we
are finished and return the last result point s.
Function
NearestNeigh(
Point p, Vertex s
)
.
Output: nearest Vertex to p in the quadrant of s
Quadrant q = quadrant
p
(s);1
float d = d
M
(p, s) ;
// init distance
2
repeat3
SearchRegion R = (square centered at p with4
side length 2d) q;
set flag
s
;5
for each quadrant q
i
6= q do6
Vertex n = neigh
s
q
i
;
7
if
nnInternal
(n) then break;
// for
8
clear all flags;9
until no nearer neighbor found ;10
return s11
Local Function
nnInternal
( Vertex n ):12
if n =
/
0 flag
n
is set then return false13
Quadrant q
n
= quadrant
p
(n);14
if q
n
= q d
M
(p, n) < d then15
s = n;
// new nearest vertex
16
d = d
M
(p, n);17
return true18
set flag
n
;19
for each quadrant q
i
6= q
n
do20
if R cuts q
i
nnInternal
(neigh
n
q
i
) then
21
return true22
return false23
The function
nnInternal
first checks if the cur-
rent vertex n is in the right quadrant and is nearer to p
than the current nearest vertex s (lines 15-17). If this
is not the case, it recursively performs a simple depth-
first search to find other vertices. Note that we only
have to search in quadrants that cut the search region.
The algorithm described above can be improved
ORTHANT NEIGHBORHOOD GRAPHS - A Decentralized Approach for Proximity Queries in Dynamic Point Sets
89
by a simple heuristic. Given the current vertex s (or
n in
nnInternal
), chances are high that a new near-
est neighbor can be found by following the opposite
quadrant of q
s
(respectively q
n
), because in this quad-
rant the target point p is located. Therefore, we first
search in these quadrants before searching in the re-
maining ones. This way, we quickly reduce the search
region and follow a roughly linear path to the target
point p (see figure 4).
If the initial starting point s is already close to the
nearest neighbor, this path will be very short and only
points in a local neighborhood of s resp. p will be
traversed. Thus, our algorithm benefits from small
movements and local insertions.
In line 4 of the remove algorithm (section 4.2),
we search for the second nearest neighbor in a given
quadrant. This can be done with a slightly adapted
version of
nnInternal
. We only have to extend the
condition in line 15 to neither accept p nor neigh
p
q
as
a new nearest vertex. This way, the search is aborted
after the second nearest neighbor has been found.
We also use a similar algorithm to find (arbitrary)
points in a given quadrant, as required in line 5 of
the insert algorithm. In this case, we set the search
region to match the quadrant and use a search similar
to
nnInternal
to find a point in this region.
4.5 Reverse Neighbor Searching
One step of the insert algorithm of section 4.1 is
to search for all vertices r
i
, for which a point p is
the new nearest neighbor. We say that the vertices
r
i
will reference to p after the insertion. We use a
similar step in line 1 of the remove algorithm (sec-
tion 4.2), where we search all vertices which are ref-
erencing to a given vertex p. In general, this problem
is called “reverse nearest neighbor searching” (Ma-
heshwari et al., 2002). Here, we adapt the problem
to report all vertices r
i
, which have p as their nearest
neighbor in one of their quadrants.
In the context of ONGs, the number of such ver-
tices can be arbitrary large and depends on the vertex
Figure 4: The black dots highlight the points visited during
a nearest neighbor search. The path between the start point
in the lower left and the target point in the upper right is
roughly linear.
p
q
s
s
(a)
p
s
(b)
Figure 5: p cannot be the nearest neighbor for vertices in the
shaded areas. The blue line in (b) marks the Voronoi-edge
between s and p for the Manhattan-metric.
distribution in the local neighborhood around p (con-
sider a vertex surrounded by a circle of other vertices).
However, the average number of referencing vertices
for each vertex in an ONG is (at most) four, since the
out-degree of every vertex is (at most) four.
The idea for our reverse nearest neighbor algo-
rithm is to use a breadth-first search (BFS) con-
strained by corollary 1 and the two following obser-
vations:
Corollary 2 Let s be a vertex located in quadrant q
s
of vertex p. Then, every vertex in the same quadrant
q
s
of s must be closer to s than to p (see figure 5(a)).
Therefore, no vertex in this area can reference to p.
Corollary 3 Let s and p be two vertices and v = s p
the difference between them. Without loss of general-
ity, we assume that s is in the upper-right quadrant
of p. If
|
v
x
|
<
|
v
y
|
, then all vertices in the upper-left
quadrant of p above s are closer to s than to t. Anal-
ogously, if
|
v
x
|
>
|
v
y
|
, then all vertices in the lower-
right quadrant of p on the right of s are closer to s
than to t.
This observation can be easily verified by consid-
ering the Voronoi diagram for the Manhattan-metric,
as illustrated in figure 5(b), where all points above s
are also above the Voronoi edge. Note that this ob-
servation is only possible with the Manhattan-metric,
which was the main reason to use it for ONGs.
We can now present our reverse nearest neighbor
algorithm (
ReverseNN
), reporting all vertices which
have p as their nearest neighbor.
The algorithm begins by creating a search region
for every quadrant (line 2). Initially, every search
rectangle is equivalent to its quadrant and therefore
on two sides open. Then, all neighbors of p are in-
serted into the BFS queue (lines 4-9). In addition,
the search regions are reduced by calling the func-
tion
clipSearchReg
for every neighbor. This func-
tion employs corollary 3 to clip the search rectangles.
Afterwards, we process every vertex s from the
queue (lines 10-21): If s has p as its nearest neighbor,
it is reported as a result (line 14). Note that p can only
GRAPP 2007 - International Conference on Computer Graphics Theory and Applications
90
Procedure
ReverseNN(
Vertex p
)
.
List Q = empty vertex list;1
SearchRegion R[4] = four open rectangles2
corresponding to the quadrants of p;
set flag
p
;3
for each quadrant q
i
do4
Vertex n = neigh
p
q
i
;5
if n 6=
/
0 then6
set flag
n
;7
clipSearchReg
(n);8
append n to Q;9
repeat10
Vertex s = pop front element from Q;11
Quadrant q
s
= quadrant
p
(s);12
Quadrant ˆq
s
= opposite(q
s
);13
if neigh
s
ˆq
s
= p then report s as a result;
14
for each quadrant q
i
do15
Vertex n = neigh
s
q
i
;
16
if n 6=
/
0 flag
n
is not set17
q
i
6= q
s
R[1...4] cuts q
i
then
set flag
n
;18
clipSearchReg
(n);19
append n to Q;20
until Q is empty ;21
clear all flags;22
Local Function
clipSearchReg
( Vertex n ):23
Quadrant q
n
= quadrant
p
(n);24
Vector v = n p25
if
|
v
x
|
<
v
y
then
26
Quadrant q = q
n
inverted in x-direction;27
clamp R[q] in y-direction;28
else29
Quadrant q = q
n
inverted in y-direction;30
clamp R[q] in x-direction;31
be the neighbor for s in the opposite quadrant of q
s
.
Then, we consider all neighbors of s which have not
been visited yet and which correspond to quadrants
intersecting one of the search regions (R[1...4]). Fol-
lowing corollary 2, we don’t have to consider neigh-
bors in q
s
(line 17). After clipping the search re-
gions, we include each such neighbor into the BFS
queue (lines 18-20). We repeat these steps until the
BFS queue is empty and no more referencing vertices
could be found. The visited and resulting vertices for
a typical example are illustrated in figure 6(a).
We use a variation of the algorithm above to
search all vertices which will reference to a new ver-
tex p after insertion. The only differences are line 5,
where we take the nearest neighbors for p found by
NearestNeigh
, and line 14, where we check, if p is
nearer than the current neighbor.
(a) (b)
Figure 6: The black dots highlight the points visited during
a reverse nearest neighbor search (a) and range searching
(b) for the red point. The shaded square in (b) represents
the query region.
4.6 Range Searching
Finally, the main purpose of ONGs is to provide prox-
imity queries. The nearest neighbor for any vertex
(according to the Manhattan metric) can be simply
found by comparing the four neighbors of each quad-
rant. Another common query in particle or agent sys-
tems is to find all points in a given radius. We for-
mulate this as a (circular) range searching problem:
given a vertex p, find all vertices nearer than a certain
distance r. We approximate this problem by finding
all neighbors in a square centered at p and having a
side length of 2r:
Procedure
RangeSearch(
Vertex p, float r
)
.
List Q = empty vertex list;1
SearchRegion R = square centered at p with side2
length 2r;
set flag
p
;3
while p 6=
/
0 do4
if p R then report p as a result;5
for each quadrant q
i
do6
Vertex n = neigh
p
q
i
;7
if n 6=
/
0 flag
n
is not set R cuts q
i
then8
set flag
n
;9
append n to Q;10
p = pop front element from Q;11
clear all flags;12
This algorithm implements a simple breadth-first
search (BFS), starting at p. Using BFS for range
searching with (weak) spanners was introduced by
(Fischer et al., 1998). They use the (weak) span-
ner property to constrain the BFS to a certain region
around p. In contrast to this approach, we use corol-
lary 1 to constrain the BFS: we only have to continue
the search in quadrants which intersect the search re-
gion R. This results in much fewer vertices we have to
visit. In typical examples, there are only few visited
vertices which are not contained in the query rectan-
gle (see figure 6(b)).
ORTHANT NEIGHBORHOOD GRAPHS - A Decentralized Approach for Proximity Queries in Dynamic Point Sets
91
Table 1: Timings for experiments with ONGs for point
sets of different size. The timings in ms are averaged over
10 000 iterations.
Point set 1 000 10 000 100 000
Incremental build 0.031 s 0.367 s 6.141 s
Remove all points 0.027 s 0.309 s 5.694 s
Point movement 0.055 ms 0.059 ms 0.058 ms
Range searching 0.109 ms 0.111 ms 0.110 ms
Using this algorithm, we can also provide prox-
imity queries for other metrics. For example, the
Euclidean nearest neighbor to p can be found by
searching all vertices nearer than the nearest neigh-
bor n
M
based on the Manhattan metric. We do this
by performing a range search around p with radius
d
M
(p, n
M
) and comparing the distances of the result
points according to the Euclidean metric.
5 DISCUSSION
In the following we give preliminary results for our
approach. We have implemented all presented algo-
rithms and data structures in C++. Figure 1 shows a
complex ONG generated with our system.
Table 1 gives timings of some experiments on
a 3GHz PC using our prototypical implementation,
where the code was not optimized for speed. First,
we inserted a large number of points with random
distribution in arbitrary order. The table shows that
these can be quickly incrementally inserted into an
ONG. The incremental removal of all points is even
faster, because no localization step (as explained in
section 4.4) is needed. In the next experiment we
compare the cost of locally moving a point in small
and large point sets consisting of 1 000, 10 000, and
100 000 points. The timings for all three cases are
nearly equal. Finally, we do a range search in small
and large point sets. We adapt the radius, so that 100
points are found each time. Again, the timings are
nearly equal. Therefore, the total number of points in
the ONG does not influence the cost of local opera-
tions like local movements or range searching. This
confirms the scalability of ONGs.
5.1 Conclusion
We have introduced ONGs, a new spatial data struc-
ture that supports proximity queries in dynamic point
sets. The basis for ONGs are weak spanners, which
ensure that storing the nearest neighbor for each quad-
rant results in a strongly connected graph. ONGs
are decentralized in that all information is distributed
on the whole point set. We presented different algo-
rithms that work on the local neighborhood of given
points. This allows dynamic insertions, deletions and
movements of points as well as range queries inde-
pendent of the size of the point set. Our algorithms are
input and output sensitive: The cost of moving a point
is low for small movements, but grows as it moves
farther. Also, the cost of range queries depends of
the number and the neighborhood of the result points.
These properties make ONGs applicable to systems
consisting of a large number of points, like particle or
agent systems.
5.2 Future Work
There are many areas of future work and open ques-
tions for ONGs. The approach and the presented algo-
rithms have to be analyzed and evaluated in more de-
tail. A comparison with other techniques (like quad-
or kd-trees) will show the usability of ONGs.
We want to adopt ONGs to 3D and higher dimen-
sions. In principle, the presented algorithms and data
structures also work in higher dimensions. However,
the number of orthants grows exponentially with the
number of dimensions, resulting in drawdowns in per-
formance. The lowest known bound of the number
of neighbors required for weak spanners in 3D is 8.
However, this bound is not tight (Fischer et al., 1999).
ONGs would benefit from a scheme that requires less
cones and still produces weak spanners.
Another direction of future work is the kinetiza-
tion of ONGs. Kinetic data structures store dynamic
objects and explicitly model their motion (Basch
et al., 1997). The idea is to only change the underly-
ing structure if certain predicates change. This could
save unnecessary updates of ONGs for small motions
which do not change the graph topology.
Finally, we want to apply ONGs to different prob-
lems in computer graphics. For example, higher di-
mensional ONGs could be used for the broad phase
of collision detection.
REFERENCES
Arya, S., Das, G., Mount, D. M., Salowe, J. S., and Smid,
M. (1995). Euclidean spanners: short, thin, and lanky.
In STOC ’95: Proc. 27th annual ACM symposium on
Theory of computing, pages 489–498.
Basch, J., Guibas, L. J., and Hershberger, J. (1997). Data
structures for mobile data. In SODA ’97: Proc. 8th an-
nual ACM-SIAM symposium on Discrete algorithms,
pages 747–756.
Bentley, J. L. (1990). K-d trees for semidynamic point sets.
In SCG ’90: Proc. 6th annual symp. on Computa-
tional geometry, pages 187–197.
GRAPP 2007 - International Conference on Computer Graphics Theory and Applications
92
Bonabeau, E., Dorigo, M., and Theraulaz, G. (1999).
Swarm Intelligence : From Natural to Artificial Sys-
tems. Oxford University Press, USA.
Boubekeur, T., Heidrich, W., Granier, X., and Schlick, C.
(2006). Volume-surface trees. Computer Graphics Fo-
rum (Proceedings of Eurographics 2006), 25(3):399–
406.
Fischer, M., Lukovszki, T., and Ziegler, M. (1998). Ge-
ometric searching in walkthrough animations with
weak spanners in real time. In ESA ’98: Proc. 6th An-
nual European Symposium on Algorithms, pages 163–
174.
Fischer, M., Lukovszki, T., and Ziegler, M. (1999). Parti-
tioned neighborhood spanners of minimal outdegree.
In Proc. 11th Canadian Conf. on Computational Ge-
ometry (CCCG’99), pages 47–50.
Fischer, M., Meyer auf der Heide, F., and Strothmann,
W.-B. (1997). Dynamic data structures for real-
time management of large geometric scenes. In ESA
’97: Proc. 5th Annual European Symposium on Algo-
rithms, pages 157–170.
Gottschalk, S., Lin, M. C., and Manocha, D. (1996). OBB-
Tree: A hierarchical structure for rapid interference
detection. Computer Graphics, 30(Annual Confer-
ence Series):171–180.
James, D. L. and Pai, D. K. (2004). BD-Tree: Output-
sensitive collision detection for reduced deformable
models. ACM Transactions on Graphics (SIGGRAPH
2004), 23(3):393–398.
Kim, D.-J., Guibas, L. J., and Shin, S. Y. (1998). Fast colli-
sion detection among multiple moving spheres. IEEE
Transactions on Visualization and Computer Graph-
ics, 4(3):230–242.
Maheshwari, A., Vahrenhold, J., and Zeh, N. (2002). On
reverse nearest neighbor queries. In Proc. 14th Cana-
dian Conf. on Computational Geometry, pages 128–
132.
Reeves, W. T. (1983). Particle Systems A Technique for
Modeling a Class of Fuzzy Objects. Computer Graph-
ics (Proceedings of ACM SIGGRAPH 83), 17(3):359–
376.
Reynolds, C. W. (1987). Flocks, Herds, and Schools: A
Distributed Behavioral Model. Computer Graphics
(Proceedings of ACM SIGGRAPH 83), 21(4):25–34.
Ruppert, J. and Seidel, R. (1991). Approximating the d-
dimensional complete euclidean graph. In Proc. 3rd
Canadian Conf. on Computational Geometry, pages
207–210.
Samet, H. (1990). The design and analysis of spatial data
structures. Addison-Wesley Longman Publishing Co.,
Inc., Boston, MA, USA.
Schlechtweg, S., Germer, T., and Strothotte, T. (2005).
RenderBots—Multi Agent Systems for Direct Image
Generation. Computer Graphics Forum, 24(1):137–
148.
Yao, A. C.-C. (1982). On constructing minimum spanning
trees in k-dimensional spaces and related problems.
SIAM J. Comput., 11(4):721–736.
ORTHANT NEIGHBORHOOD GRAPHS - A Decentralized Approach for Proximity Queries in Dynamic Point Sets
93