![]() Volume 10, Issue 1 Articles Trott's Corner New Products New Publications Calendar News Bulletins New Resources Classifieds Download This Issue Editorial Policy Staff and Contributors Submissions Subscriptions Advertising Back Issues Contact Information |
Efficient, High-Quality Force-Directed Graph Drawing
3. Force-Directed AlgorithmsIn this section we present the basic force-directed algorithms and analyze the characteristics of the layout given by the spring-electrical model. We will propose a general repulsive force model, as well as an adaptive step control scheme. 3.1. Spring and Spring-Electrical ModelsForce-directed algorithms model the graph layout problem by assigning attractive and repulsive forces between vertices and finding the optimal layout by minimizing the energy of the system. The model of Fruchterman and Reigold [4], which we refer to as the spring-electrical model, has two forces. The repulsive force,
The combined force on a vertex
In these formulas,
where From a mathematical point of view, changing the parameters Theorem 1. Let Proof: This follows simply by the relationship
where
Even though the parameters One intrinsic feature of graph drawings by the spring-electrical model is that vertices in the periphery tend to be closer to each other than those in the center, even for a uniform mesh. We call this the peripheral effect. For example, Figure 1 shows a mesh of 100 vertices laid out using the spring-electrical model, with vertices near the outside boundary clearly closer to each other than those near the center.
Figure 1. A This peripheral effect is more profound for graphs with large diameter. We studied this effect for a line graph, with 100 vertices linked in a line. The vertices are numbered 1 to 100, with vertex 50 and 51 in the middle of the line. We find an accurate layout under the spring-electrical model by finding the root of a system of equations Figure 2 shows the distribution of edge lengths. As can be seen, the edge lengths of the 99 edges vary from 4.143 at the middle to 1.523 at the sides, with the ratio of the longest length to the shortest
Figure 2. Distribution of edge lengths for a line graph of 100 vertices and 99 edges, laid out using the spring-electrical model. The reason for this distortion effect at the periphery is the strong long-range force that decays slowly as the distance increases. While typically this strong long-range force does not interfere with the aesthetics of the layout, some applications, such as tree graphs, tend to suffer more. For these classes of graphs, the following general repulsive force model can be used.
The larger the parameter
Figure 3. A plot of the ratio between the largest and smallest edge lengths for line graphs of size 3 to 100 vertices. In the force model of Kamada and Kawai [7], which we will refer to as the spring model, springs are attached between any two pairs of vertices, with the ideal length of a spring proportional to the graph distance between these two vertices. Thus both the repulsive and attractive forces are expressed as
and the spring energy is
The spring model does not suffer from the peripheral effect of the spring-electrical model. It can, however, suffer from its relatively weak repulsive forces (see Section 6.3). Furthermore, as discussed later, in the spring-electrical model, the long-range force between all vertices can be well approximated by grouping vertices together using the octree/quadtree technique. This is, however, not possible in the spring model. 3.2. An Adaptive Cooling SchemeThe energy of both the spring-electrical and the spring models can be minimized iteratively by moving the vertices along the direction of forces exerted on them. The following force-directed algorithm iteratively minimizes the system energy, with Algorithm 1. An iterative force-directed algorithm. In the algorithm, As in [2], we update the layout of a vertex In Algorithm 1, it is necessary to update the step length
with In the preceding algorithm, Compared with the simple step length update scheme (6), the adaptive scheme is much better in escaping from local minimums. Figure 4 shows the result of applying 70 iterations of Algorithm 1 to the jagmesh1 graph with 936 vertices from MatrixMarket (math.nist.gov/MatrixMarket). The adaptive scheme is clearly much better and is able to untangle the graph a lot further than the simple scheme.
Figure 4. Comparing adaptive and simple step length update schemes on jagmesh1 after 70 iterations: simple scheme (left); adaptive scheme (middle); what the layout should look like (right).
|
||||||||
About Mathematica | Download Mathematica Player © 2006 Wolfram Media, Inc. All rights reserved. |