Force-based Layout
   HOME

TheInfoList



OR:

Force-directed graph drawing algorithms are a class of
algorithm In mathematics and computer science, an algorithm () is a finite sequence of rigorous instructions, typically used to solve a class of specific Computational problem, problems or to perform a computation. Algorithms are used as specificat ...
s for drawing graphs in an aesthetically-pleasing way. Their purpose is to position the nodes of a graph in two-dimensional or three-dimensional space so that all the edges are of more or less equal length and there are as few crossing edges as possible, by assigning forces among the set of edges and the set of nodes, based on their relative positions, and then using these forces either to simulate the motion of the edges and nodes or to minimize their energy. While graph drawing can be a difficult problem, force-directed algorithms, being physical simulations, usually require no special knowledge about graph theory such as planarity.


Forces

Force-directed graph drawing algorithms assign forces among the set of edges and the set of nodes of a
graph drawing Graph drawing is an area of mathematics and computer science combining methods from geometric graph theory and information visualization to derive two-dimensional depictions of graph (discrete mathematics), graphs arising from applications such a ...
. Typically,
spring Spring(s) may refer to: Common uses * Spring (season), a season of the year * Spring (device), a mechanical device that stores energy * Spring (hydrology), a natural source of water * Spring (mathematics), a geometric surface in the shape of a ...
-like attractive forces based on
Hooke's law In physics, Hooke's law is an empirical law which states that the force () needed to extend or compress a spring (device), spring by some distance () Proportionality (mathematics)#Direct_proportionality, scales linearly with respect to that ...
are used to attract pairs of endpoints of the graph's edges towards each other, while simultaneously repulsive forces like those of
electrically charged Electric charge is the physical property of matter that causes charged matter to experience a force when placed in an electromagnetic field. Electric charge can be ''positive'' or ''negative'' (commonly carried by protons and electrons respe ...
particles based on
Coulomb's law Coulomb's inverse-square law, or simply Coulomb's law, is an experimental law of physics that quantifies the amount of force between two stationary, electrically charged particles. The electric force between charged bodies at rest is conventiona ...
are used to separate all pairs of nodes. In equilibrium states for this system of forces, the edges tend to have uniform length (because of the spring forces), and nodes that are not connected by an edge tend to be drawn further apart (because of the electrical repulsion). Edge attraction and vertex repulsion forces may be defined using functions that are not based on the physical behavior of springs and particles; for instance, some force-directed systems use springs whose attractive force is logarithmic rather than linear. An alternative model considers a spring-like force for every pair of nodes (i,j) where the ideal length \delta_ of each spring is proportional to the graph-theoretic distance between nodes ''i'' and ''j'', without using a separate repulsive force. Minimizing the difference (usually the squared difference) between Euclidean and ideal distances between nodes is then equivalent to a metric multidimensional scaling problem. A force-directed graph can involve forces other than mechanical springs and electrical repulsion. A force analogous to gravity may be used to pull vertices towards a fixed point of the drawing space; this may be used to pull together different connected components of a disconnected graph, which would otherwise tend to fly apart from each other because of the repulsive forces, and to draw nodes with greater centrality to more central positions in the drawing; it may also affect the vertex spacing within a single component. Analogues of
magnetic field A magnetic field is a vector field that describes the magnetic influence on moving electric charges, electric currents, and magnetic materials. A moving charge in a magnetic field experiences a force perpendicular to its own velocity and to ...
s may be used for directed graphs. Repulsive forces may be placed on edges as well as on nodes in order to avoid overlap or near-overlap in the final drawing. In drawings with curved edges such as circular arcs or spline curves, forces may also be placed on the control points of these curves, for instance to improve their
angular resolution Angular resolution describes the ability of any image-forming device such as an optical or radio telescope, a microscope, a camera, or an eye, to distinguish small details of an object, thereby making it a major determinant of image resolution. ...
.


Methods

Once the forces on the nodes and edges of a graph have been defined, the behavior of the entire graph under these sources may then be simulated as if it were a physical system. In such a simulation, the forces are applied to the nodes, pulling them closer together or pushing them further apart. This is repeated iteratively until the system comes to a mechanical equilibrium state; i.e., their relative positions do not change anymore from one iteration to the next. The positions of the nodes in this equilibrium are used to generate a drawing of the graph. For forces defined from springs whose ideal length is proportional to the graph-theoretic distance, stress majorization gives a very well-behaved (i.e., monotonically convergent). and mathematically elegant way to minimize these differences and, hence, find a good layout for the graph. It is also possible to employ mechanisms that search more directly for energy minima, either instead of or in conjunction with physical simulation. Such mechanisms, which are examples of general
global optimization Global optimization is a branch of applied mathematics and numerical analysis that attempts to find the global minima or maxima of a function or a set of functions on a given set. It is usually described as a minimization problem because the max ...
methods, include simulated annealing and
genetic algorithm In computer science and operations research, a genetic algorithm (GA) is a metaheuristic inspired by the process of natural selection that belongs to the larger class of evolutionary algorithms (EA). Genetic algorithms are commonly used to gene ...
s.


Advantages

The following are among the most important advantages of force-directed algorithms: ; Good-quality results: At least for graphs of medium size (up to 50–500 vertices), the results obtained have usually very good results based on the following criteria: uniform edge length, uniform vertex distribution and showing symmetry. This last criterion is among the most important ones and is hard to achieve with any other type of algorithm. ; Flexibility: Force-directed algorithms can be easily adapted and extended to fulfill additional aesthetic criteria. This makes them the most versatile class of graph drawing algorithms. Examples of existing extensions include the ones for directed graphs, 3D graph drawing, cluster graph drawing, constrained graph drawing, and dynamic graph drawing. ; Intuitive: Since they are based on physical analogies of common objects, like springs, the behavior of the algorithms is relatively easy to predict and understand. This is not the case with other types of graph-drawing algorithms. ; Simplicity: Typical force-directed algorithms are simple and can be implemented in a few lines of code. Other classes of graph-drawing algorithms, like the ones for orthogonal layouts, are usually much more involved. ; Interactivity: Another advantage of this class of algorithm is the interactive aspect. By drawing the intermediate stages of the graph, the user can follow how the graph evolves, seeing it unfold from a tangled mess into a good-looking configuration. In some interactive graph drawing tools, the user can pull one or more nodes out of their equilibrium state and watch them migrate back into position. This makes them a preferred choice for dynamic and
online In computer technology and telecommunications, online indicates a state of connectivity and offline indicates a disconnected state. In modern terminology, this usually refers to an Internet connection, but (especially when expressed "on line" or ...
graph-drawing systems. ; Strong theoretical foundations: While simple ''ad-hoc'' force-directed algorithms often appear in the literature and in practice (because they are relatively easy to understand), more reasoned approaches are starting to gain traction. Statisticians have been solving similar problems in multidimensional scaling (MDS) since the 1930s, and physicists also have a long history of working with related
n-body In physics and astronomy, an ''N''-body simulation is a simulation of a dynamical system of particles, usually under the influence of physical forces, such as gravity (see ''n''-body problem for other applications). ''N''-body simulations ar ...
problems - so extremely mature approaches exist. As an example, the stress majorization approach to metric MDS can be applied to graph drawing as described above. This has been proven to converge monotonically. Monotonic convergence, the property that the algorithm will at each iteration decrease the stress or cost of the layout, is important because it guarantees that the layout will eventually reach a local minimum and stop. Damping schedules cause the algorithm to stop, but cannot guarantee that a true local minimum is reached.


Disadvantages

The main disadvantages of force-directed algorithms include the following: ; High running time: The typical force-directed algorithms are in general ''considered'' to run in cubic time (O(n^3)), where n is the number of nodes of the input graph. This is because the number of iterations is estimated to be linear (O(n)), and in every iteration, all pairs of nodes need to be visited and their mutual repulsive forces computed. This is related to the N-body problem in physics. However, since repulsive forces are local in nature the graph can be partitioned such that only neighboring vertices are considered. Common techniques used by algorithms for determining the layout of large graphs include high-dimensional embedding, multi-layer drawing and other methods related to
N-body simulation In physics and astronomy, an ''N''-body simulation is a simulation of a dynamical system of particles, usually under the influence of physical forces, such as gravity (see ''n''-body problem for other applications). ''N''-body simulations ar ...
. For example, the
Barnes–Hut simulation The Barnes–Hut simulation (named after Josh Barnes and Piet Hut) is an approximation algorithm for performing an ''n''-body simulation. It is notable for having order O(''n'' log ''n'') compared to a direct-sum algorithm which would b ...
-based method FADE. can improve the running time to be linearithmic, or n\log(n) per iteration. As a rough guide, in a few seconds one can expect to draw at most 1,000 nodes with a standard n^2 per iteration technique, and 100,000 with a n\log(n) per iteration technique. Force-directed algorithms, when combined with a graph clustering approach, can draw graphs of millions of nodes. ; Poor local minima: It is easy to see that force-directed algorithms produce a graph with minimal energy, in particular one whose total energy is only a
local minimum In mathematical analysis, the maxima and minima (the respective plurals of maximum and minimum) of a function, known collectively as extrema (the plural of extremum), are the largest and smallest value of the function, either within a given ran ...
. The local minimum found can be, in many cases, considerably worse than a global minimum, which translates into a low-quality drawing. For many algorithms, especially the ones that allow only ''down-hill'' moves of the vertices, the final result can be strongly influenced by the initial layout, that in most cases is randomly generated. The problem of poor local minima becomes more important as the number of vertices of the graph increases. A combined application of different algorithms is helpful to solve this problem. For example, using the Kamada–Kawai algorithm to quickly generate a reasonable initial layout and then the Fruchterman–Reingold algorithm to improve the placement of neighbouring nodes. Another technique to achieve a global minimum is to use a multilevel approach.


History

Force-directed methods in graph drawing date back to the work of , who showed that polyhedral graphs may be drawn in the plane with all faces convex by fixing the vertices of the outer face of a planar embedding of the graph into convex position, placing a spring-like attractive force on each edge, and letting the system settle into an equilibrium. Because of the simple nature of the forces in this case, the system cannot get stuck in local minima, but rather converges to a unique global optimum configuration. Because of this work, embeddings of planar graphs with convex faces are sometimes called
Tutte embedding In graph drawing and geometric graph theory, a Tutte embedding or barycentric embedding of a simple, 3-vertex-connected, planar graph is a crossing-free straight-line embedding with the properties that the outer face is a convex polygon and tha ...
s. The combination of attractive forces on adjacent vertices, and repulsive forces on all vertices, was first used by ;. additional pioneering work on this type of force-directed layout was done by .. The idea of using only spring forces between all pairs of vertices, with ideal spring lengths equal to the vertices' graph-theoretic distance, is from ..


See also

*
Cytoscape Cytoscape is an open source bioinformatics software platform for visualizing molecular interaction networks and integrating with gene expression profiles and other state data. Additional features are available as plugins. Plugins are available f ...
, software for visualising biological networks. The base package includes force-directed layouts as one of the built-in methods. *
Gephi Gephi ( ) is an open-source network analysis and visualization software package written in Java on the NetBeans platform. History Initially developed by students of the University of Technology of Compiègne (UTC) in France, Gephi has been select ...
, an interactive visualization and exploration platform for all kinds of networks and complex systems, dynamic and hierarchical graphs. * Graphviz, software that implements a multilevel force-directed layout algorithm (among many others) capable of handling very large graphs. * Tulip, software that implements most of the force-directed layout algorithms (GEM, LGL, GRIP, FM³). *
Prefuse Prefuse is a Java-based toolkit for building interactive information visualization applications. It supports a rich set of features for data modeling, visualization and interaction. It provides optimized data structures for tables, graphs, and tre ...


References


Further reading

* *


External links


Book chapter on Force-Directed Drawing Algorithms
by Stephen G. Kobourov

on force-directed graph layout {{DEFAULTSORT:Force-Based Algorithms (Graph Drawing) Graph algorithms Graph drawing