# Detailed Examples of Figure Preparation in the Two Most Common Graph Layouts
## 3 Fruchterman-Reingold Algorithm  
The first adaptation of the spring-electric algorithm proposed by [PERSON] [16] to create a fast and simple algorithm for the drawing of esthetic and two-dimensional graph drawings was carried out by [PERSON] and [PERSON] (1991) [6]. This algorithm is similar to the Eades algorithm in the sense that both algorithms compute the attraction forces between neighboring vertices and the repulsion forces between all pairs of vertices. However, the Fruchterman-Reingold algorithm adds a uniform distribution of vertices. The authors focused on esthetic criteria such as even vertex placement, minimizing the number of edge intersections, standardizing the edge lengths, creating symmetry, and fitting the drawing into the frame.  
In the Fruchterman-Reingold algorithm, we first calculate the optimal distance \(k\) between the vertices, where  
\[k=C\cdot\sqrt{\frac{\textit{display area}}{\textit{number of vertices}}} \tag{1}\]  
and the constant \(C\) is determined by experiments.  
The aim of the authors was to place the vertices evenly spaced in the display frame, where \(k\) was intended to be the radius of the empty area around the vertex. Thus, the further apart two connected vertices are, or the closer together non-adjacent vertices are,  
Figure 2: Illustration of [PERSON] spring-electric algorithm after [17]: starting from random positions, we treat the graph as a spring system and finish with a stable configuration.  
the more abruptly their positions should be adjusted. In the case where the vertices are in the same place, the algorithm acts as if the two vertices are within a small distance of each other in a random orientation, leading to a large repulsion effect that separates them. The algorithm is then able to adjust the positions of the vertices.  
In the Fruchterman-Reingold algorithm, we deal with two opposing forces. These are the attractive force \(f_{a}\) and the repulsive force \(f_{r}\). If \(d\) denotes the optimal distance between two vertices, then  
\[f_{a}(d)=\frac{d^{2}}{k},\qquad f_{r}(d)=\frac{-k^{2}}{d}.\]  
From the point of view of energy minimization, a \(k\) that optimizes the difference in the two forces is used.  
The largest component from the network in [12] was used to visualize the graphs obtained by the Fruchterman-Reingold algorithm. This network is a well-known collaboration graph created by [PERSON].  
This algorithm is one of the first algorithms used to visualize graphs, so it does not have any configurable settings. The Gephi program allows us to change the size of the graph display area (by default, Gephi treats the display area as a circle rather than a square) and to change the gravity power. Gravity is a force that attracts all nodes to the center to avoid the dispersion of components. The appropriate choice of space (Area option) and the choice of gravitational force (Gravity option) have a significant impact on the drawing of the graph. Figures 3-5 show the results of the visualization obtained with the Fruchterman-Reingold algorithm with various settings of these parameters. As can be seen, despite having only two options to set, we can obtain visualizations that appear different. The selection of a specific one depends on the particular application.  
Figure 3: Graph visualization with the Fruchterman–Reingold algorithm with area 800.0, gravity 1.0.