#
Faster Force-Directed Graph Drawing with the Well-Separated Pair Decomposition^{ †}

^{*}

^{†}

## Abstract

**:**

## 1. Introduction

#### 1.1. Previous Work

#### 1.2. Our Contribution

## 2. Algorithm

#### 2.1. Constructing a WSPD

#### 2.2. The Force-Directed Algorithm

Algorithm 1: WSPD-Based Force Computation for a Graph $G=(V,E)$. |

#### 2.3. Running Time

#### 2.4. Implementation

`+`WSPD.

#### 2.5. Improvements

## 3. Experimental Comparison

- (H1)
- The quality of the drawings produced by FR
`+`WSPD is comparable to that of FRLayout. - (H2)
- On sufficiently large graphs, FR
`+`WSPD is faster than FRLayout.

#### 3.1. Experimental Setup

`+`WSPD, we implemented the quadtree-based speed-up method of Barnes and Hut [4], which we call FR

`+`Quad, and a grid-based approach suggested already by Fruchterman and Reingold [2], which we call FR

`+`Grid. To widen the scope of our study, we included some algorithms implemented in C

`++`in OGDF [19]: GEM (short for Graph Embedder) of Frick et al. [12], FM${}^{3}$ (short for Fast Multipole Multilevel Method) of Hachul and Jünger [6], the

`FastMultipoleMultilevelEmbedder`of Gronemann (which is based on the idea of FM${}^{3}$ and Gronemann’s thesis [14]; we will call this variant simply FastMultipole), and FRExact (the exact FR implementation in OGDF; the corresponding class is called

`SpringEmbedderFRExact`). We combine FRExact and GEM with

`MultilevelLayout`in OGDF for our experiments. The other algorithms already include a multilevel implementation. Additionally, we use the

`ComponentSplitterLayout`, as some OGDF algorithms can handle only connected graphs.

`++`.

- (DS1)
`Rome:`The Rome graph collection [23] contains 11,528 undirected connected graphs with 10–100 vertices each.- (DS2)
`North:`The North graphs [24], a subset of the AT&T graph collection, contain 1277 directed connected graphs with 10–100 vertices each. We only consider the underlying undirected graphs.- (DS3)
`Rand-IncVtc-LoDens:`A set of 40 random graphs that we generated using the class`EppsteinPowerLawGenerator`[25] in JUNG, which yields graphs whose structure is similar to web graphs. We generated instances with 2500, $5000,7500,\dots $, 100,000 vertices and approximately 2.5-times as many edges. We considered only the largest connected component of each generated graph, which contains most of the original vertices.- (DS4)
`Rand-5000Vtc-IncDens:`A set of 40 random graphs generated as (DS3). We fixed the number of vertices to 5000 and generated approximately $1,1.5,2,\dots ,20,20.5$-times as many edges to be able to test graphs with different densities. We considered only the largest connected component of each generated graph. This affected only the graphs with less than 25,000 edges.- (DS5)
`Rand-1000Vtc-HiDens:`A set of 40 random graphs generated as (DS3). We fixed the number of vertices to 1000 and the number of edges to approximately $10,000$. Each of these graphs is connected.- (DS6)
`Hachul:`The set of artificial graphs generated by Hachul and Jünger [22]. We use a subset of 45 graphs containing up to 10,000 vertices and up to 22,402 edges for our experiments. Some of these graphs are not connected.

`+`WSPD for different values ($0.0001$, $0.001$, $0.01$, $0.1$, 1 and 10) of the separation constant s on (DS1). The performance of the algorithm is shown in Figure 2. The distribution of the results in the plot is roughly the same, that is the quality of the drawings did not strongly depend on s. The runtimes for different values of s are shown in Figure 3. Using $s=10$ or $s=1$ was slower than the other values, so we found $s=0.1$ to be the best choice, which we use in the following experiments.

`+`Quad has a parameter Θ that controls how finely the given point set is subdivided. Increasing Θ decreases the running time. Our experiments confirmed what Barnes and Hut [4] observed: only values of Θ close to one give results with a similar quality as the unmodified algorithm.

#### 3.2. Results of Comparison

`+`WSPD for the data sets (DS1), (DS2), (DS5) and (DS6) using a statistical test. More precisely, we want to show that the number of crossings produced by our FR

`+`WSPD algorithm is at most 10% worse, and the standard deviation of the edge lengths is at most 25% worse than the original FRLayout algorithm. To see this, we formulate the following null hypothesis: the number of crossings (resp., the standard deviation of the edge lengths) yielded by FR

`+`WSPD is more than $1.1$-times (resp., $1.25$) the value yielded by FRLayout. It turned out that we can reject this null hypothesis using a Wilcoxon signed rank test [26] with high significance (p-values of $0.01$ at most).

`+`WSPD algorithm to that of other graph drawing algorithms. In order to vary as few parameters as possible, we kept the size of the graphs constant in this part of the study. We used all Rome graphs with exactly 100 vertices. The 140 graphs have, on average, 135 edges.

`+`WSPD to the above-mentioned four OGDF algorithms. In terms of the uniformity of edge lengths, there are three clear clusters: FM${}^{3}$ is better and FastMultipole is worse than the rest (FRExact, GEM and FR

`+`WSPD). In terms of crossings, however, FastMultipole is best, followed by GEM, FRExact, FM${}^{3}$ and FR

`+`WSPD.

`+`Grid is clearly the worst in both measures. FR

`+`WSPD is in the mid-field according to both measures.

`+`Quad are slightly better than FR

`+`WSPD and FR

`+`Grid. FR

`+`Grid produces considerably more edge crossings than the other three variants. While FRLayout is somewhat better than FR

`+`WSPD in both measures, there is support for Hypothesis (H1).

`java.lang.management.ManagementFactory.get ThreadMXBean().getCurrentThreadCpuTime()`); this eliminates the influence of the garbage collector and the JIT compiler on our measurements. In C

`++`, we used the OGDF method

`ogdf::usedTime`for measuring the CPU time. For each graph size, we display the mean runtime over all graphs of that size.

`+`WSPD is much faster than FRLayout on larger graphs. We were surprised, however, to see that FR

`+`WSPD starts overtaking FRLayout already around $n\approx 100$. For the Java variants, we could isolate the part of the running time that is used for the computation of the repulsive forces, which is the part we have improved and in which we are most interested; see Figure 6 and compare the top plot that shows the total running times to the bottom plot that shows the times needed for computing the repulsive forces. To show more details in the bottom plot, note that we used a different scale on the y-axis. The plot clearly shows that, as expected, computing the repulsive forces dominates the total running time.

`+`WSPD turned out to be faster than all other algorithms in our comparison, except for FastMultipole for the very large, but low-density graphs in Rand-IncVtc-LoDens (DS3) and except for FR

`+`Grid in the other two data sets (DS4) and (DS5). Recall, however, that FR

`+`Grid tends to produce a much more edge crossings (Figure 5).

`++`, FRExact (in C

`++`) is roughly 2–3-times faster than FRLayout (in Java) for graphs of constant density; see Figure 5 (top and bottom). Increasing the number of edges slows FRLayout down much more than FRExact; see Figure 5 (middle). Of course, the comparison between different programming languages is not really fair because every language has its own advantages and disadvantages regarding efficiency. Still, our experiments show that the running times of FR

`+`WSPD are in the same order of magnitude as those of OGDF.

`+`WSPD is quite good in terms of edge crossings, while it is often worse in terms of edge length deviation. In terms of running time, FR

`+`WSPD is usually among the two or three fastest implementations in our comparison, regularly beaten only by FR

`+`Grid (which produces many more edge crossings).

## 4. Conclusions and Perspectives

`+`WSPD was usually in the mid-range, somewhat better in terms of the number of crossings and slightly worse in terms of the standard deviation of edge lengths; see Figure 5 and Figure 8. Considering the specific examples that we picked from the Hachul data set ((DS6); see Figure 9, Figure 10 and Figure 11), Hachul and Jünger’s FM${}^{3}$ and (to a slightly lesser degree) Gronemann’s FastMultipole tend to yield the aesthetically most pleasing drawings. It would be interesting to understand better which part of the FM${}^{3}$ approach causes this difference.

## Acknowledgments

## Author Contributions

## Conflicts of Interest

## References

- Eades, P. A heuristics for graph drawing. Congr. Numerantium
**1984**, 42, 146–160. [Google Scholar] - Fruchterman, T.M.J.; Reingold, E.M. Graph drawing by force-directed placement. Softw. Pract. Exp.
**1991**, 21, 1129–1164. [Google Scholar] [CrossRef] - Fink, M.; Haverkort, H.; Nöllenburg, M.; Roberts, M.; Schuhmann, J.; Wolff, A. Drawing Metro Maps Using Bézier Curves. In Graph Drawing; Springer: Heidelberg, Germany, 2013; pp. 463–474. [Google Scholar]
- Barnes, J.; Hut, P. A hierarchical O(N log N) force-calculation algorithm. Nature
**1986**, 324, 446–449. [Google Scholar] [CrossRef] - Walshaw, C. A Multilevel Algorithm for Force-Directed Graph-Drawing. J. Graph Algorithms Appl.
**2003**, 7, 253–285. [Google Scholar] [CrossRef] - Hachul, S.; Jünger, M. Drawing large graphs with a potential-field-based multilevel algorithm. In Graph Drawing; Springer: Heidelberg, Germany, 2005; pp. 285–295. [Google Scholar]
- Greengard, L.; Rokhlin, V. A fast algorithm for particle simulations. J. Comput. Phys.
**1987**, 73, 325–348. [Google Scholar] [CrossRef] - Hachul, S. A Potential-Field-Based Multilevel Algorithm for Drawing Large Graphs. Ph.D. Thesis, Universität zu Köln, Cologne, Germany, 2005. [Google Scholar]
- Godiyal, A.; Hoberock, J.; Garland, M.; Hart, J.C. Rapid Multipole Graph Drawing on the GPU. In Graph Drawing; Springer: Heidelberg, Germany, 2009; pp. 90–101. [Google Scholar]
- Bartel, G.; Gutwenger, C.; Klein, K.; Mutzel, P. An Experimental Evaluation of Multilevel Layout Methods. In Graph Drawing; Springer: Heidelberg, Germany, 2011; pp. 80–91. [Google Scholar]
- Brandenburg, F.J.; Himsolt, M.; Rohrer, C. An experimental comparison of force-directed and randomized graph drawing algorithms. In Graph Drawing; Springer: Heidelberg, Germany, 1996; pp. 76–87. [Google Scholar]
- Frick, A.; Ludwig, A.; Mehldau, H. A fast adaptive layout algorithm for undirected graphs. In Graph Drawing; Springer: Heidelberg, Germany, 1995; pp. 388–403. [Google Scholar]
- Callahan, P.B.; Kosaraju, S.R. A decomposition of multidimensional point sets with applications to k-nearest-neighbors and n-body potential fields. J. ACM
**1995**, 42, 67–90. [Google Scholar] [CrossRef] - Gronemann, M. Engineering the Fast-Multipole-Multilevel Method for Multicore and SIMD Architectures. Master’s Thesis, Technical University of Dortmund, Germany, 2009. [Google Scholar]
- Huang, W.; Eades, P.; Hong, S.H.; Lin, C.C. Improving multiple aesthetics produces better graph drawings. J. Vis. Lang. Comput.
**2013**, 24, 262–272. [Google Scholar] [CrossRef] - Lin, C.C.; Yen, H.C. A new force-directed graph drawing method based on edge–edge repulsion. J. Vis. Lang. Comput.
**2012**, 23, 29–42. [Google Scholar] [CrossRef] - Hu, Y. Efficient, High-Quality Force-Directed Graph Drawing. Math. J.
**2006**, 10, 37–71. [Google Scholar] - O’Madadhain, J.; Fisher, D.; White, S. Java Universal Network/Graph Framework (JUNG). Available online: http://jung.sourceforge.net (accessed on 2 September 2015).
- Chimani, M.; Gutwenger, C.; Jünger, M.; Klau, G.W.; Klein, K.; Mutzel, P. The Open Graph Drawing Framework (OGDF). In Handbook of Graph Drawing and Visualization; CRC Press: Boca Raton, FL, USA, 2014. [Google Scholar]
- Lipp, F.; Wolff, A.; Zink, J. Faster Force-Directed Graph Drawing with the Well-Separated Pair Decomposition. Available online: http://www1.pub.informatik.uni-wuerzburg.de/pub/data/frwspd/ (accessed on 27 July 2016).
- Narasimhan, G.; Smid, M. Geometric Spanner Networks; Cambridge University Press: New York, NY, USA, 2007. [Google Scholar]
- Hachul, S.; Jünger, M. Large-Graph Layout Algorithms at Work: An Experimental Study. J. Graph Algorithms Appl.
**2007**, 11, 345–369. [Google Scholar] [CrossRef] - Rome Graphs. Available online: http://graphdrawing.org/data.html (accessed on 2 September 2015).
- North, S. North Graphs. Available online: http://graphdrawing.org/data.html (accessed on 7 December 2015).
- Eppstein, D.; Wang, J.Y. A steady state model for graph power laws. In Proceedings of the 2nd International Workshop on Web Dynamics, Honolulu, HI, USA, 7 May 2002.
- Rumsey, D.J. Statistics II for Dummies; Wiley Publishing: Indianapolis, IN, USA, 2009. [Google Scholar]

**Figure 1.**Graph with 9843 vertices and 19,683 edges (sierpinski_08). This artificial graph was generated by Hachul and Jünger [22]; the above drawings were generated by two variants of our WSPD-based method. (

**a**) The WSPD is reconstructed in every iteration. Runtime: 3.70 s; standard deviation of edge lengths: 1.65; number of edge crossings: 4058. (

**b**) The WSPD is reconstructed every few iterations. Runtime: 1.97 s; standard deviation of edge lengths: 1.76; number of edge crossings: 3894.

**Figure 2.**Standard deviation of the edge lengths (y-axis) over the number of edge crossings (x-axis) for various values of s in our FR

`+`WSPD (Fruchterman and Reingold (FR)) algorithm, applied to all 140 Rome graphs with exactly 100 vertices, a subset of (DS1). For each value of s, a vertical and a horizontal line mark its median performance.

**Figure 3.**The runtimes for the algorithm FR

`+`WSPD with different values for s. Each point in the plots represents the mean value of the runtimes on all Rome graphs (DS1) with the given number of vertices. The markers are used only as a tool to identify the plots.

**Figure 4.**Standard deviation of the edge lengths (y-axis) over the number of edge crossings (x-axis) for various variants of the algorithm, applied to all 140 Rome graphs with exactly 100 vertices, a subset of (DS1). (

**Top**) Quality of the unmodified FRLayout algorithm and its variants FR

`+`WSPD, FR

`+`Quad and FR

`+`Grid; (

**Bottom**) FR

`+`WSPD and some algorithms implemented in OGDF. For each algorithm, a vertical and a horizontal line mark its median performance.

**Figure 5.**Standard deviation of the edge lengths (y-axis) over the number of edge crossings (x-axis) for various variants of the algorithm, applied to data set Rand-1000Vtc-HiDens (DS5). It shows the quality of the unmodified FRLayout algorithm and its variants FR

`+`WSPD, FR

`+`Quad, and FR

`+`Grid, together with some algorithms implemented in OGDF. For each algorithm, a vertical and a horizontal line mark its median performance. Note that the horizontal line for FRLayout is hidden behind that of FRQuad.

**Figure 6.**The runtimes for Rome (DS1) as a function of the number of vertices. The upper plot shows the total runtime, the lower plot only the time needed for computing the repulsive forces (which we could only measure for the Java implementations). Note that the y-axes use different scales. Each point in the plots represents the mean value of the runtimes on all graphs in the test set with the given number of vertices. The markers are used only as a tool to identify the plots.

**Figure 7.**(

**Top**) Data set Rand-IncVtc-LoDens (DS3); 40 random graphs with increasing number of vertices and average degree five; (

**Middle**) Data set Rand-5000Vtc-IncDens (DS4); 40 random graphs with 5000 vertices and average degree ranging from 2–41 (the graphs with less than $25,000$ edges actually consist of slightly less than 5000 vertices, as we only consider the largest connected component of each graph); (

**Bottom**) Data set Rand-1000Vtc-HiDens (DS5); 40 random graphs generated with the same parameters (1000 vertices and about $10,000$ edges). The x-axis displays the index of the instances. Each marker represents one instance.

**Figure 8.**Comparison of the quality and runtimes of the results for data set Hachul (DS6). We do not compare the results in absolute numbers as the input graphs are very different from each other. For each criterion, the best algorithm gets rank one, and the worst algorithm gets rank zero. If multiple algorithms yield the same result, they get the same rank. The x-axis displays the index of the instances. Instance size increases from left to right. The markers are used only as a tool to identify the plots. (

**Top**) Standard deviation of edge lengths; (

**Middle**) Number of crossings; (

**Bottom**) Running time.

**Figure 9.**Tree with 259 vertices and 258 edges (tree_06_03). For each result, the runtime of the algorithm, the standard deviation of the edge lengths and the number of edge crossings are shown in parentheses.

**Figure 10.**Planar graph with 9497 vertices and 17,849 edges (grid_rnd_100). For each result, the runtime of the algorithm, the standard deviation of the edge lengths and the number of edge crossings are shown in parentheses.

**Figure 11.**Graph with 9030 vertices and 131,241 edges (flower_050). For each result the runtime of the algorithm is shown in parentheses.

© 2016 by the authors; licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC-BY) license (http://creativecommons.org/licenses/by/4.0/).

## Share and Cite

**MDPI and ACS Style**

Lipp, F.; Wolff, A.; Zink, J. Faster Force-Directed Graph Drawing with the Well-Separated Pair Decomposition. *Algorithms* **2016**, *9*, 53.
https://doi.org/10.3390/a9030053

**AMA Style**

Lipp F, Wolff A, Zink J. Faster Force-Directed Graph Drawing with the Well-Separated Pair Decomposition. *Algorithms*. 2016; 9(3):53.
https://doi.org/10.3390/a9030053

**Chicago/Turabian Style**

Lipp, Fabian, Alexander Wolff, and Johannes Zink. 2016. "Faster Force-Directed Graph Drawing with the Well-Separated Pair Decomposition" *Algorithms* 9, no. 3: 53.
https://doi.org/10.3390/a9030053