Approximation Algorithms for Finding Best Viewpoints Michael E. Houle and Richard Webber Department of Computer Science and Software Engineering University of Newcastle Callaghan 2308, Australia fmike,
[email protected] Abstract. We address the problem of nding viewpoints that preserve the relational structure of a three-dimensional graph drawing under orthographic parallel projection. Previously, algorithms for nding the best viewpoints under two natural models of viewpoint \goodness" were proposed. Unfortunately, the inherent combinatorial complexity of the problem makes nding exact solutions is impractical. In this paper, we propose two approximation algorithms for the problem, commenting on their design, and presenting results on their performance.
1 Introduction Since it was rst considered by the graph drawing community [6,10], there has been much research into three-dimensional graph drawing. There is some experimental evidence that three-dimensional graph drawings have advantages over their two-dimensional counterparts. It is claimed [16] that three dimensions allow users to work with larger graphs { the natural three-dimensional actions of rotation and translation allow a user to resolve ambiguities in large drawings while maintaining their overall mental map [12]. Ware et al. [16] conducted a series of experiments on nding paths between vertices in a three-dimensional graph drawing, under a variety of display and navigation combinations. They discovered that giving users control of bidirectional rotation results in lower error rates than continuous unidirectional rotation, but at the cost of increased decision time. In [7], we conjectured that this increase is partly due to the time taken to manually select good viewpoints. Most current systems leave the selection of good viewpoints entirely to the user. We propose that the user should be able to specify those parts of the graph drawing they wish to focus on, then the system should automatically move them to a good viewpoint. For interactive applications, the movement needed to maintain the illusion of three dimensions [3] can be achieved by continuously moving between several viewpoints, or by \rocking" around a single viewpoint. In graph drawing, Kamada and Kawai [11] model good viewpoints as those that preserve the \shape" of a three-dimensional wire-frame drawing, by excluding viewpoints from which edges appear collinear. They describe the bad
viewpoints of their model as a set of great circles on the unit sphere, and present an algorithm to nd the best viewpoints of a graph drawing (those viewpoints which are furthest by great-circle distance from the nearest bad viewpoint). Bose, Gomez, Ramos and Toussaint [2] model good viewpoints for wire-frame drawings as those from which no vertex-vertex or vertex-edge pairs occlude each other, and no three edges appear to cross at the same point. They describe the bad viewpoints of their model as an arrangement [8] of curves on the unit sphere. In computer graphics, aspect graphs [15] are used to describe sets of viewpoints from which the two-dimensional images of a three-dimensional polyhedral solid have the same topology. Aspect graphs can be used to nd viewpoints from which the maximal number of faces of a polyhedron are visible; in some sense, these viewpoints can be considered \best". In a previous paper [7], we presented three models of good viewpoints: one that distinguishes between good and bad viewpoints, and two that assign continuous measures of goodness to each viewpoint, leading to the notion of best viewpoints. Unfortunately, the complexity of the latter two models is too high for the calculation of theoretically-exact best viewpoints to be practical. In this paper, we address this problem by proposing fast approximation algorithms that yield \reasonably good" viewpoints. In Sect. 2, we brie y review the models of good viewpoints detailed in [7]. In Sect. 3, we consider several criteria which algorithms for nding best viewpoints should satisfy. In Sects. 4 and 5, we present two classes of approximation algorithms and discuss their relative merits. We conclude in Sect. 6 with a discussion of the experimental performance of these algorithms, and some examples of graph drawings viewed from their best viewpoints.
2 Good Viewpoints A three-dimensional straight-line drawing D : V ! IR3 of an abstract graph G = (V; E ) associates a three-dimensional position (xi ; yi ; zi ) 2 IR3 with each vertex vi 2 V . Each edge eij is drawn as a line-segment between its endpoints. We use V0 to denote the set of isolated vertices; for a wire-frame drawing, V0 = ;. A three-dimensional graph drawing is mapped to a two-dimensional image via a projection. In this paper, we consider only orthographic parallel projections [9]. An orthographic parallel projection is parameterised by its viewpoint direction { a vector from the origin in IR3 to a point p on the unit sphere. A two-dimensional image is formed by translating each point of the three-dimensional drawing, parallel to the vector p, onto a plane (the projection surface) that is perpendicular to p. The drawing can be clipped by a volume before projection { those portions of the three-dimensional graph drawing outside of this clipping volume do not appear in the resulting two-dimensional image. If a projection maps two three-dimensional points to the same two-dimensional point, then an occlusion occurs. We say the front point occludes the rear point. The concept of occlusion underlies many models of good viewpoints.
2.1 Bad Viewpoint Arrangements De nition 2.1: A good viewpoint is one from which the apparent abstract graph
of the two-dimensional image is identical to the abstract graph of the threedimensional graph drawing. For the purposes of this paper we assume that: a two-dimensional image is generated from a three-dimensional graph drawing using an orthographic parallel projection; there is no clipping; and all vertices and edges are mathematical ideals, with zero width for the purpose of calculating occlusions. Under these assumptions, the abstract graphs of a three-dimensional graph drawing and its two-dimensional image appear the same, if and only if there are no occlusions involving elements of the drawing. Viewpoints that result in occlusions are bad viewpoints; (a; b) denotes the set of bad viewpoints from which a occludes b. There are four main types of occlusions: vertex-vertex occlusions, vertex-edge occlusions, edge-vertex occlusions, and edge-edge occlusions. If vi and vj are both isolated vertices, then (vi ; vj ) is called an isolated-vertex occlusion. Edge-edge occlusions only aect the apparent abstract graph if the corresponding twodimensional edges overlap (intersect at more than one point). Observation 2.2: A good viewpoint is one that does not generate any isolatedvertex, vertex-edge, or edge-vertex occlusions. The set of bad viewpoints corresponding to a three-dimensional graph drawing can be represented by a collection of occlusion curves on the unit sphere. Using the techniques described in Bose et al. [2], we construct an arrangement [8] of the elements in . We refer to this structure as a bad viewpoint arrangement. Lemma 2.3: [2] For a given three-dimensional graph drawing, we can build the corresponding bad viewpoint arrangement S in O(j j log j j + k) time, where j j = jV0 j(jV0 j ? 1) + 2jV jjE j. The parameter k is the number of intersections between elements of , which is O(jV0 j2 + jV j2 jE j2 ) in the worst case. The size of S is O(j j + k).
2.2 Rotational Separation Diagrams
A bad viewpoint arrangement allows us to determine whether a given viewpoint results in an occlusion that aects the apparent abstract graph of a drawing. However, in itself, a bad viewpoint arrangement does not tell us from which points it would be best to view the drawing. To address this issue, we have developed two measures of goodness over the set of viewpoints. The rst of these is the rotational separation measure. Let (p; p ) denote the great-circle distance between two viewpoints p and p . We de ne Grsd (p; (a; b)) to be minp (a;b) (p; p ). The rotational separation Grsd (p; ) of p is min (a;b) Grsd (p; (a; b)). If this minimum value is achieved for (a ; b ), then we say that (a ; b ) determines the goodness of p. A rotational separation diagram is a variant of a Voronoi diagram [8] that uses rotational separation as its distance function. 0
0
02
2
0
0
0
0
0
Lemma 2.4: A rotational separation diagram can be constructed in O(jS j log jS j) time, where S is the corresponding bad viewpoint arrangement. The resulting diagram can be used to calculate Grsd (p; ) in logarithmic time. A rotational separation diagram can also be used to the nd best viewpoints of a three-dimensional graph drawing under the rotational separation measure. Clearly, the goodness value Grsd (p; S ) increases as p moves away from the nearest bad viewpoint(s) in S . This increase is maximised locally, either at a Voronoi vertex of the rotational separation diagram, or in some cases, at a unique internal point of a Voronoi edge. Theorem 2.5: Given a rotational separation diagram, we can nd all locallybest viewpoints in O(jS j) time, where S is the corresponding bad viewpoint arrangement. We can also nd a locally-best viewpoint, nearest by great-circle distance to a given viewpoint, in logarithmic time. Best viewpoints under the rotational separation measure maximise the amount by which the viewpoint can rotate before an occlusion is generated. This can be bene cial for interactive applications, especially those that use \rocking" to achieve the illusion of three-dimensions [3]. 2.3 Observed Separation Diagrams
Our second continuous measure of goodness is observed separation. We de ne Gosd (p; (a; b)) to be the minimum distance between the images of graph elements a and b when viewed from the viewpoint p. The observed separation Gosd (p; ) of p is min (a;b) Gosd (p; (a; b)). An observed separation diagram is a Voronoi diagram that uses observed separation as its distance function. A tight bound for the worst case size of an observed separation diagram is currently an open problem. An O(jS j2 2( S )) upper bound is known for the restricted case of three-dimensional point sets (E = ;), where is the inverse of Ackermann's function [1]. A bad viewpoint arrangement S exists which yields an
(jS j2 ) lower bound; however, it is not yet known whether such an arrangement can be derived from a three-dimensional graph drawing. Best viewpoints under the observed separation measure maximise the user's ability to resolve elements in the two-dimensional image of a three-dimensional drawing. Example drawings (such as those in Fig. 6) suggest that best viewpoints under observed separation are superior to those under rotational separation for the static display of three-dimensional graph drawings. 2
j
j
3 Approximate Solutions We propose that, for a viewpoint- nding algorithm to be useful, it should satisfy these criteria: Quality { The viewpoint found should be \equivalent" to a theoretically-exact best viewpoint. Exactly what it means for two viewpoints to be \equivalent" varies among applications and users.If our output device has nite resolution,
then equivalence can be quanti ed according to the threshold angle below which a given three-dimensional point is expected to map to the same pixel in both of the resulting two-dimensional images. This threshold angle is equivalent to half the minimum angle of rotation that would result in a vertex vi shifting from one edge of a pixel in the two-dimensional projection to the opposite edge of the same pixel. Hence, on an n n pixel display, two viewpoints can be considered \equivalent" when the angle between them is less than 2 = arcsin n2 . Locality { The viewpoint p found should be \close" to the user's speci ed viewpoint p. This criterion is important to help preserve the user's mental map of the three-dimensional graph drawing. One may set a tolerance radius for the change in viewpoint (p; p ). By restricting p to satisfy (p; p ) , we ensure that the user's mental map is preserved. Alternatively, if (p; p ) > , then the movement can be animated such that the change of viewpoint between two frames is always within the radius . This introduces the notion of two tolerance radii: 1 , the maximum change allowed over the entire animation; and 2 , the maximum change allowed in any step of the animation. The application of a viewpoint- nding algorithm occurs in two phases. In the rst phase, a three-dimensional graph drawing is preprocessed to build a data structure which identi es its best viewpoints. In the second phase, this data structure is repeatedly queried, to nd viewpoints that satisfy the above criteria. These two phases suggest two additional criteria. Preprocessing Speed { Preprocessing should be fast enough to allow access to the query algorithm within a \reasonable time". Ideally, the algorithm should be available as soon as the drawing is loaded into the application. To achieve this, preprocessing can be carried out when the drawing is generated, and the resulting data structures loaded into the application along with the drawing. However, applications that generate graph drawings interactively must still perform preprocessing \on the y". Query Speed { The query algorithm should return a viewpoint \quickly". Ideally, a viewpoint should be found in no more time than it takes to render the drawing. Rendering a graph as a simple line-drawing usually requires time linear in the number of graph elements jGj = jV j + jE j. The algorithms for nding best viewpoints given in Sects. 2.2 and 2.3 return best viewpoints within the precision used to build the corresponding diagrams. This easily satis es the quality criterion for any reasonable precision. These algorithms also satisfy the locality criterion, in the sense that they return the locally-best viewpoint nearest by great-circle distance to a given viewpoint. The query speed criterion is also satis ed { indeed over-satis ed { as these algorithms return a viewpoint in logarithmic time. However, these algorithms require extensive preprocessing before their query algorithms can be used. For a given graph G, preprocessing can require (jGj4 log jGj) time under the rotational separation measure, and even more under the observed separation measure. These time requirements are clearly too large for these algorithms to be useful in practice. 0
0
0
0
0
In order to reduce the computational cost associated with nding a locallybest viewpoint, we present algorithms that relax the quality criterion to nd \reasonably good" viewpoints, while satisfying the remaining criteria.
4 Iterative Improvement Algorithms Iterative improvement [14] is a simple search technique used to nd points in a given space that optimise a given function. An iterative improvement algorithm works by repeatedly selecting a trial point and evaluating the optimisation function, retaining the point which yields the best value. The choice of the optimisation function, the way in which a trial point is chosen, and the way in which the decision is made to terminate, all in uence the running time of the algorithm, and the quality of the solution produced. For the problem at hand, the optimisation function is either of the goodness measures, denoted G (p; ). Various methods can be used to choose a trial viewpoint. Choosing a viewpoint p at random from the set of all viewpoints (blind random search) does not satisfy the locality criterion, as the initial viewpoint has no eect on the nal viewpoint. A better method is to choose a trial viewpoint p from within the intersection of two limiting circles: one centred on the initial viewpoint, with radius 1; and one centred on the current viewpoint, with radius 2 (recall that 1 and 2 are the tolerance radii that preserve the user's mental map). Calculating G (p; ) requires O(jGj2 ) time. It follows that t should be in O(1=jGj2 ) to satisfy the query speed criterion. However, for large graph drawings, t may become too small to nd a \reasonably good" viewpoint within this time. This problem can be (partially) solved by animating the algorithm. Algorithm 1: Animated Iterative Approximation Inputs: initial viewpoint p; goodness function G ; occlusion curves ; limiting radii 1 ; 2 ; number of iterations t. Outputs: nal viewpoint. 1. Limiting centre c1 p. 2. While p is not \reasonably good": (a) Limiting centre c2 p. (b) For t iterations: i. Choose p 6= p, such that (c1 ; p ) 1 , and (c2 ; p ) 2 . ii. If G (p ; ) > G (p; ), then p p . (c) Display the graph drawing from the viewpoint p. 3. Return p. On each step of the animation, t trial viewpoints are assessed, requiring O(tjGj2 ) time; then the graph is displayed. Between steps, the centre of the inner limiting circle moves to the current viewpoint p. Alternatively, the inner limiting circle can be moved each time a better viewpoint is found. Explicitly calculating whether the current viewpoint p is \reasonably good" is dicult, as there is no ecient way of comparing p against the theoreticallyexact best viewpoints of the graph drawing. Instead, we use heuristics to decide 0
0
0
0
0
0
0
2
2
c2
PSfrag replacements PSfrag replacements
c2 PSfrag replacements
PSfrag replacements
(a)
c2 2
2
c2
(b)
(c)
(d)
Fig. 1. Regions of better viewpoints within a limiting circle. whether p is \reasonably good". Highly interactive applications can continue searching for a better viewpoint until the user interrupts the process, placing the burden of determining what is \reasonably good" on the user. Other applications can terminate the while-loop when the current viewpoint p does not change for a set number of trials. We use (c; ) to denote a lesser circle, centred on c, with radius . Let B be the region of viewpoints p within (c2 ; 2 ) such that G (p ; ) > G (p; ), let the variable R = (c2B;2 ) be the proportion of the area of (c2 ; 2 ) taken up by B , and let T be the random variable of the number of trials in which p has not changed. It can be shown that E [T ] = 1 ? 1 and Pr[T t j R k] (1 ? k)t : 0
j
0
j
R
j
j
If p is within a small distance of an occlusion curve, then R 0:5 (as illustrated in Figs. 1a and 1b). It follows that the iterative approximation algorithm moves the current viewpoint quickly away from bad viewpoints. However, as p approaches a locally-best viewpoint, R approaches 0, and the expected number of trials needed to improve on the current viewpoint increases dramatically. To avoid the situations in which R approaches 0, when the viewpoint p has not changed for a set number of trials, the inner limiting radius 2 is changed in an attempt to increase the value of R. There are two cases to consider: 1. If B is relatively small and is wholly contained within (c2 ; 2 ), then decreasing 2 makes (c2 ; 2 ) a tighter approximation to B (see Fig. 1c). 2. If the current viewpoint is on a \spike" of B , and B is a small part of a larger region of better viewpoints, then increasing 2 can increase the proportion of this region in (c2 ; 2 ) (see Fig. 1d). Obviously, these two cases con ict, and it cannot be determined with certainty which case applies for any given viewpoint. Our approach is to use a dynamic inner limiting radius 2 , initially set to 2 . At each step, if p does not change, then 2 is decreased. Otherwise, 2 is increased, but is never set higher than 2 . If 2 reaches a lower limit (determined by the \equivalence" angle of the quality criterion), then the algorithm decides that it has achieved a \reasonably good" viewpoint and terminates. 0
0
0
0
4.1 Pruning
The iterative improvement algorithm described so far is a practical method for approximating the best viewpoints of small three-dimensional graph drawings. However, for larger graph drawings, the O(j j) time taken to compute the goodness of each trial viewpoint becomes too great. One approach to this problem is to prune those occlusions curves which cannot possibly determine the goodness of a trial viewpoint. Let Gmin ( (a; b); (c; )) = minp (c;) G (p; (a; b)) and Gmax ( (a; b); (c; )) = maxp (c;) G (p; (a; b)). Initially, we prune to yield 2
1 =
2
(a; b) Gmin ( (a; b); (c1 ; 1 )) min Gmax ( (a ; b ); (c1 ; 1)) 0
(a ;b )2 0
:
0
0
The time taken to generate 1 is O(j j). This cost is paid at the beginning of each query, after which each viewpoint can be evaluated in O( 1 ) time. If 2 is signi cantly smaller than 1 , then a second stage of pruning can further improve the running time of our algorithm. At the start of each animation step, we can prune 1 by the inner limiting circle (c2 ; 2 ) to yield 2 . This second pruning is advantageous when 12 < 1 ? ( 1t ), where t is the number of trials per step. 0
0
j
j
j
j
4.2 Clipping
While calculating G (p; ), the bad viewpoint p that minimises G (p; ) is implicitly identi ed. It is natural to expect that, if a better viewpoint than p exists, then it should lie in the direction from p opposite to that of p . This intuition is supported by the observations in Fig. 1. A worthwhile heuristic then, is to restrict the choice of trial viewpoints to those viewpoints in that half-disc of (c2 ; 2 ) that lies furthest from p . This single-clipping heuristic potentially doubles the probability of generating a better viewpoint on any given trial. The probability of generating a better viewpoint may be further increased by also considering the bad viewpoint p that results in the second (possibly equally) minimal value of G (p; ). If the goodness values implied by p and p are approximately equal, then the choice of trial viewpoint is restricted to those viewpoints in the intersection of the two half-discs of (c2 ; 2 ) that lie furthest from p and p , respectively. This double-clipping heuristic is particularly eective at increasing the probability R when the current viewpoint is in a \spike" (Fig. 1d). Unfortunately, in some situations, these clipping heuristics can result in all viewpoints better than p being excluded from the set of trial viewpoints. To allow for this possibility, if no improvement in the current viewpoint occurs within a set number of trials, then the clipping heuristics are disabled, until such time as a better viewpoint is found. 0
0
0
0
00
0
00
0
0
00
5 Force-Directed Algorithms Force-direction is a well-established paradigm in the automatic layout of graph drawings [4,10]. Force-directed algorithms model graph drawings as physical systems { they calculate the forces applied to a vertex of the system by all other
vertices and edges, then moving the vertex in the direction resulting from the combination of these forces. Using force-directed methods to nd best viewpoints is somewhat simpler, as this only requires movement of the current viewpoint. The force calculations used to nd best viewpoints are based on the doubleclipping heuristic described earlier. The force applied by a bad viewpoint on the current viewpoint p is directed along the great-circle arc from the bad viewpoint through p. Let p and p be two bad viewpoints from distinct occlusion curves that determine the two smallest value of G (p; ), such that G (p; p ) G (p; p ). If G (p; p ) G (p; p ), then the movement of p is directed by the average of the forces applied by both p and p ; otherwise, only p is used. In the unlikely event that the forces applied by p and p exactly cancel each other out, the unwanted stability is avoided by means of a small random shift in viewpoint. Once a direction has been decided, we must determine the distance 3 2 by which to move the current viewpoint. We base our approach on that of Bru and Frick [4]. Initially, we use a small distance 3 . On all subsequent moves, we adjust the value of 3 : increasing it if the current move is in the same direction as the previous move, and decreasing it if the current move is in the opposite direction. The small initial value of 3 is chosen to prevent the viewpoint moving out of its cell in the bad viewpoint arrangement. This helps to satisfy the locality criterion, independent of the choice of an outer limiting radius 1 . If the viewpoint jumps outside its cell, then the algorithm can stabilise at a locally-best viewpoint far from the initial viewpoint (but still within 1 ). Algorithm 2: Force-Directed Approximation Inputs: initial viewpoint p; goodness function G ; occlusion curves ; limiting radii 1 ; 2 ; 3; ; number of moves t. Outputs: nal viewpoint. 1. Limiting centre c1 p; direction d 0; limiting radius 3 3 . 2. While 3 > : (a) Limiting centre c2 p. (b) For t moves: i. Find a bad viewpoint p 2 , that minimises G (p; p ). ii. Find a bad viewpoint p 6= p 2 , that minimises G (p; p ). iii. If G (p; p ) G (p; p ), then d direct(p; p ; p ), else d direct(p; p ). iv. p p + 3 d. v. Clip p by (c1 ; 1) and (c2 ; 2 ). vi. If d d , then 3 min(increase(3 ); 2 ). vii. If d ?d , then 3 min(decrease(3 ); 3 ). viii. d d. (c) Display the graph drawing from the viewpoint p. 3. Return p. 0
00
0
0
00
00
0
00
0
0
00
0
0
0
0
00
0
0
0
00
00
0
00
0
0
0
0
0
0
0
0
0
5.1 Randomised Force-Direction
Like the iterative improvement algorithm, the force-directed algorithm requires O( ) time to calculate each move. A rst stage of pruning can be used to decrease
the number of occlusion curves to be considered in each move; however, a second stage of pruning is seldom eective, as there are often only a few moves before the viewpoint reaches the edge of the inner limiting circle. Another approach, which proves to be highly eective in reducing the time taken to calculate each move, is randomisation [13]. When processing the initial viewpoint, rather than using all the occlusion curves in , we use a random sample s of occlusion curves chosen uniformly from . Of these, the occlusion curves that imply the worst w 2 goodness values are retained in a list w . After each move, a new random sample is taken from and used to update w . The randomised force-directed algorithm behaves identically to the deterministic version as long as the two bad viewpoints most restrictive to the current viewpoint are on occlusion curves contained in w . If we assume that the current viewpoint is static, then the expected number of moves until both of these occlusion curves are discovered is at most 2 s . If the current viewpoint moves, then the two most restrictive occlusion curves can change. In practice, even if w is chosen to be a constant such as 10, the two most restrictive curves are almost always found in w , due to the restriction imposed on each move by 2. The time required to calculate each move is O(j s j + w log w). If w is chosen to be a constant, then the expected work done to nd the two most restrictive occlusion curves is 2 s O(j s j) = O(j j)., after which the algorithm is expected to converge to a locally-best viewpoint. Ideally, to satisfy the query speed criterion, we would like j sj in O(jGj). However, the expected number of moves before the algorithm nds the two most restrictive bad viewpoints could then be 3 4 ); the expected number of as large as O(jGj). Rather, we choose j j in O( j j s p moves is then no larger than O( jGj). The time taken by each move is O(jGj 32 ) for sparse graphs (jE j in O(jV j)), and O(jGj 89 ) for dense graphs (jE j in (jV j2 )). j
j
j
j
j
j
j
j
6 Experimental Results In this section, we present some experimental results on the performance of our approximation algorithms. All results were obtained using a set of randomly generated three-dimensional graph drawings. Vertices were chosen uniformly at random within the unit sphere, and edges were then chosen uniformly at random from the set of all possible edges on these vertices. The algorithms were run several hundred times on each drawing, using randomly generated initial viewpoints, and the averages taken over these runs. In this paper, we limit ourselves to the rotational separation measure; initial results for the observed separation measure are similar. Figure 2 shows the time taken for the iterative approximation algorithm to terminate, plotted against jGj, and the number of trials in each animation step. These values were generated using 1 = 6 , 2 = 30 , and terminating when the viewpoint remained static for 54 trials; this number was chosen as it is the 2 ) when is reduced by 10% on number of trials needed to reduce 6 to arcsin( 1024 2 each unsuccessful trial. The time taken for the algorithm to terminate increases rapidly as the number of trials per step increases from 1. This increase peaks at 5, 0
16:0
15:0
PSfrag replacements
PSfrag replacements
12:0
10:0
8:0 time
time
4:0
5:0
0:0 125 3 1 0 25 50 75 100 trials/step jGj time v. trials per step v. jGj
0:0 0:990:8 0:6 0:4 125 0:20:01 0 25 50jG75j 100 k time v. k v. jGj
10
7 5
Fig. 2. Varying the trials per step.
Fig. 3. Varying convergence rate.
beyond which the time taken appears to be relatively independent of the number of trials per step. It follows that (if pruning is not used) the inner limiting circle should be updated as soon as a better viewpoint is found. Figure 3 shows the eects of altering the inner limiting radius on the time taken for the iterative approximation algorithm to terminate. These ?results were 2 . The generated using 1 = 2 = 6 , and terminating when 2 < arcsin 1024 inner limiting radius 2 was multiplied by the convergence parameter k on each unsuccessful trial, and multiplied by 2k2 on each successful trial. The parameter k was varied between 0:01 and 0:99. The time taken to terminate increases slightly super-linearly in terms of jGj, but exponentially in terms of k. Based on this gure, one might be tempted to choose a very low value for k. Unfortunately, as k decreases, the chance of the algorithm terminating before a \reasonably good" viewpoint is reached increases. Figure 4a shows the eectiveness of pruning, measured by the ratio 1 , plotted against 1 and jGj. These values were generated by pruning with a limiting circles of radius 1 , centred on viewpoints chosen uniformly at random from the unit sphere. The value of 1 was varied between 0:1 and 1:5. As expected, the eectiveness of pruning increases (the ratio 1 decreases) as 1 decreases. For small graph drawings, the eectiveness of pruning varies signi cantly, re ecting its dependence on the exact con guration of the occlusion curves. For larger drawings, the eectiveness of pruning appears to be independent of jGj. Figure 4b shows the eectiveness of pruning, measured by the time taken for the iterative approximation algorithm to terminate when two stages of pruning are used. These results were generated using 1 = 6 , 2 = 30 , and k = 0:9. The number of trials per step was varied between 1 and 10. As the number of trials per step increases, there is a corresponding decrease in the time taken for the algorithm to terminate, relative to the size of the graph. To understand this behavior, recall that the work done in each animation step is dominated by the 0
0
0
j
j
j
j
j
j
j
j
1:0
PSfrag replacements0:8
12:0
PSfrag replacements
8:0
j 1 j0:6 j j 0:4
time
4:0
0:2 0:00
0:8 25 50 75 100 125 0:1 1 jGj (a) 1 v. 1 v. jGj j
j
j
j
1:5
125100 75 50 jGj 25 0 10
0:0 7 5 3 1
trials/step (b) time v. trials per step v. jGj
Fig. 4. The eectiveness of pruning. second stage of pruning, which is amortised over the number of trials. It follows that the eective cost of pruning can be reduced, by increasing the number of trials per step. However, for small drawings, the number of trials per step needed to make pruning worthwhile can result in many of these trials being wasted. Finally, Figs. 5a and 5b show the time taken for the force-directed algorithm to terminate, using the deterministic and randomised approaches, respectively. , and terminating These results were using 1 = 6 , 2 = 30 , 3 = 300 ? generated 2 when 3 < arcsin 1024 . The distance functions were set such that decrease(3 ) = k 3 , and increase(3 ) = k3 . The convergence parameter k was varied between 0:1 and 0:99. The sample sizes were set to j sj = j j 43 , and w = 10. For large values of k , the time taken for these algorithms to terminate exhibits a slightly super-linear dependence on jGj. When jGj is xed, as k decreases from 1, the time taken decreases exponentially. This behaviour is analogous to that exhibited by iterative approximation in Fig. 3. However, for small graph drawings with k < 0:5, the performance of these algorithms degrades and becomes erratic { this is especially true of the randomised algorithm. This occurs because the low value of k causes the viewpoint to jump from cell to cell of the bad viewpoint arrangement. For small drawings, this behaviour can persist for many moves. For larger drawings, the cells of the bad viewpoint arrangement are usually too small for this behaviour to impact on the average performance. The results indicate that, as long as k1 is set to some small proportion of jGj, the force-directed algorithms provide a fast and reliable means of nding best viewpoints. To summarise, both the iterative improvement and force-directed approaches result in useful algorithms for nding \reasonably good" viewpoints for threedimensional graph drawings. Both approaches bene t from the use of a dynamic inner limiting radius, as long as the convergence parameters are set suciently close to 1 to ensure a \reasonably good" viewpoint is reached. When applied to large graph drawings, the iterative improvement approach can bene t from the use of pruning. Similarly, the force-directed algorithms can bene t from the use 0
0
0
0
0
0
0
0
0
0
0
0
0
10:0
PSfrag replacements
7:5
2:0
PSfrag replacements time 5:0
2:5 125100
75 jGj50 25
0 0:1
0:2 k 0
(a) deterministic
0:15:0
1:5
125 100 75 jGj 50 25
1:0time 0:5
0 0:1
0:2
(b) randomised
0:51:0 k 0
Fig. 5. The performance of force-directed approximation. of randomisation. Indeed, the randomised force-directed algorithm out-performs the other algorithms presented in this paper by a signi cant margin. We conclude with several examples of three-dimensional graph drawings, viewed from their best viewpoints.
Acknowledgements Thanks to Peter Eades for many helpful suggestions. Also thanks to Titto Patrignani, David Wood, Tiziana Calamoneri, Annalisa Massini and Mark Najork, for contributing three-dimensional graph drawings.
References 1. P. K. Agarwal (1991): Intersection and Decomposition Algorithms for Planar Arrangements; Cambridge University Press 2. P. Bose, F. Gomez, P. Ramos, G. Toussaint (1995): \Drawing Nice Projections of Objects in Space" in Proc. 3rd Int. Symp. Graph Drawing (Passau, Germany); Springer-Verlag, LNCS; 1027:52{63 3. M. L. Braunstein (1976): Depth Perception through Motion; Academic Press 4. I. Bru, A. K. Frick (1995): \Fast Interactive 3-D Graph Visualization" in Proc. 3rd Int. Symp. Graph Drawing (Passau, Germany); Springer-Verlag, LNCS; 1027:99{110 5. T. Calamoneri, A. Massini (1997): \On Three-Dimensional Layout of Interconnection Networks" in Proc. 5th Int. Symp. Graph Drawing (Rome); SpringerVerlag, LNCS; 1353:64{75 6. R. F. Cohen, P. D. Eades, T. Lin, F. Ruskey (1997): \Three-Dimensional Graph Drawing" in Algorithmica; 17(2):199{208
(a) Wood drawing of K7 [17]
(b) X-tree X16 [5]
(c) Buckminsterfullerene
(d) Caeine
Fig. 6. Some example graph drawings viewed from their best viewpoints. 7. P. D. Eades, M. E. Houle, R. Webber (1997): \Finding the Best Viewpoints for Three-Dimensional Graph Drawings" in Proc. 5th Int. Symp. Graph Drawing (Rome); Springer-Verlag, LNCS; 1353:87{98 8. H. Edelsbrunner (1987): Algorithms in Combinatorial Geometry; Springer-Verlag 9. J. D. Foley, A. van Dam, S. Feiner, J. Hughes (1990): Computer Graphics: Principles and Practice, 2nd ed.; Addison-Wesley 10. T. M. J. Fruchterman, E. M. Reingold (1991): \Graph Drawing by ForceDirected Placement" in Software { Practice and Experience; 21(11):1129{1164 11. T. Kamada, S. Kawai (1988): \A Simple Method for Computing General Position in Displaying Three-Dimensional Objects" in Computer Vision, Graphics and Image Processing; 41(1):43{56 12. K. Misue, P. D. Eades, W. Lai, K. Sugiyama (1995): \Layout Adjustment and the Mental Map" in J. Visual Languages and Computing; 6:183{210 13. R. Motwani, P. Raghavan (1995): Randomized Algorithms; Cambridge University Press 14. P. H. J. M. Otten, L. P. P. P. van Ginneken (1989): The Annealing Algorithm; Kluwer Academic 15. H. Plantinga, C. R. Dyer (1990): \Visibility, Occlusion, and the Aspect Graph" in Int. J. Computer Vision; 5(2):137{160 16. C. Ware, G. Franck (1996): \Evaluating Stereo and Motion Cues for Visualizing Information Nets in Three Dimensions" in ACM Trans. Graphics; 15(2):121{140 17. D. R. Wood (1998): \Two-Bend Three-Dimensional Orthogonal Grid Drawing of Maximum Degree Five Graphs"; in this proceedings