Introduction

This contribution aims to bring together two strands of research: latent space approaches to network analysis and force-directed layout algorithms (FDLs). FDLs are used ubiquitously for network exploration, illustration, and analysis in a wide variety of disciplines [2, 16, 17, 19, 24, 43, 51, 56, 61, 62]. While often producing intuitively compelling and aesthetic layouts, FDLs remain a double-edged sword. Two different families of approaches are subsumed under the term—both suffer from certain shortcomings. For FDLs that build on an electric-spring metaphor (e.g., Ref. [35]), it is unclear how to precisely interpret node positions and corresponding patterns, such as clusters (discussed recently in Refs. [34, 62]). FDLs that are instances of stress models, on the other hand, are simply directed towards the preservation of certain topological features of the network, such as geodesic distance between node pairs (see, e.g., Ref. [36]). They also tend to perform poorly on scale-free networks, a network type often found in social networks [14]. Besides, appropriate algorithm choice from the variety of FDLs available remains arbitrary in both cases.

We argue and show that explicit interpretability can be provided by latent space approaches, which have the goal of embedding a network in an underlying latent space, and where link probabilities are related to proximity in said space.

This contribution combines different approaches to embed networks in a meaningful space. It also makes the differences between several force-directed algorithms that embed networks clearer, especially for scientists who do not have an overview of the vast literature in graph drawing with FDLs. To this end, we first briefly sketch different types of FDLs in Sect. 2. We distinguish between FDLs based on electric-spring models, and stress models which are based on multidimensional scaling (MDS).Footnote 1 We sketch the approaches and show differences in terms of what their layouts mediate in low-dimensional spaces. Specifically, the former have a tight connection to modularity, while the latter usually aim at arriving at uniform edge lengths rather than conveying community structure. In Sect. 3, we introduce latent space approaches to network analysis, and subsequently show how force terms of a new type of FDL can be derived from said latent space models, where the forces move nodes towards positions and parameters which maximise the likelihood for the network under the given model. Especially for social networks, latent space models can serve as a plausible probabilistic models of social behavior and, in principle, can also be used for link prediction. We derive force equations for three types of networks (Sect. 4): unweighted networks, multi-tie networks (such as the much-studied Twitter retweet networks), and weighted networks. We present an implementation of the FDL, which we call Leipzig Layout, as well as a number of real-world networks spatialised with it in Sect. 5; we also show that the existing algorithms, specifically ForceAtlas2 [35], Fruchterman Reingold [23], and Yifan Hu [32], differ from the presented FDL. Section 6 concludes with a summary and an outlook.

Force-directed layout algorithms

In the graph drawing literature, force-directed network layouts encase two different families of approaches. On the one hand, they include layout techniques that mimic a physical system in which forces that depend on the distance between nodes act on them until the system is at rest. This is what we will refer to as electric-spring models. On the other hand, layout algorithms have been developed that are types of MDS. While not actually simulating physical forces, they are referred to as ‘force-directed’ algorithms in the graph drawing community [38].Footnote 2 MDS is an approach to dimensionality reduction: information contained in a (high-dimensional) distance matrix is sought to be embedded in a low-dimensional space while keeping distances as truthful to the high-dimensional ones as possible. These approaches minimise an underlying objective function called stress function, which is why they are also referred to as stress models.Footnote 3

Electric-spring models

Initially, force-based network visualization algorithms, both based on electric-spring and stress models, had been conceived to facilitate graph reading. They were supposed to make small networks readable in the sense that paths and nodes in the network were clearly accessible, that the edges had similar lengths and that the network was drawn as symmetric as possible [21].Footnote 4 These readability criteria were also referred to as ‘aesthetic’ (see, e.g., Refs. [8, 12, 20, 32, 58]). Progress in network science and the sudden availability of very large network data sets at the end of the millennium—for which a comprehension of individual node positions and paths was illusory—shifted focus: now, networks needed to be drawn such that community structure and topological features were mediated in the layout. Electric-spring models (partly having been developed already before this complex turn, notably in Refs. [21, 23]) turned out to be useful and efficient tools for this task. The algorithms have in common that all nodes repel each other, while connected nodes are additionally drawn together by their edges. The repulsive force \(F_r\), \(F_r \propto d^r\) (d is the distance between nodes), has a smaller exponent than the attractive force \(F_a\), \(F_a \propto d^a\), such that \(a > r\).

Noack, in a seminal work [47], connected electric-spring models to modularity, one of the most central measures of clustering in networks in use today. Roughly speaking, modularity Q compares the proportion of links connecting nodes within a group of nodes with the proportion expected if the edges in the network were randomly rewired [45]. Community detection algorithms, such as the Louvain algorithm [9], aim to find partitions of a network that maximise this value. Noack showed that, under certain constraints, modularity can be transformed into an expression that equals the energy function of electric-spring layouts. Constraints for the equivalence are as follows:

  1. (i)

    Nodes can only be placed either at the same position (then, they belong to the same cluster) or at distance 1 from each other (if they are not in the same cluster).

  2. (ii)

    The algorithms operate in a space of (at least) \(k-1\) dimensions, where k is the number of modularity clusters (usually, FDLs embed networks in a two-dimensional space).

  3. (iii)

    The exponents of attractive and repulsive force should be non-negative. (Obviously, if the repulsive force has a negative exponent, placement of nodes at the same position would be impossible.)

For electric-spring layouts, this means that if they fulfill (ii) and (iii), their energy-minimal states are relaxations of modularity maximization: They make community structure in networks visible without constraint (i) of having to sort nodes into different, fixed partitions with distance 0 or 1 from each other. They can assign continuous positions in space. Or, phrased the other way round: modularity is then a special case of their energy function.

However, Noack’s finding is diluted by the fact that network visualizations with FDLs are commonly restricted to two (or at most three) dimensions; and moreover, most electric-spring models in use today employ a negative exponent for the repulsive force. Noack also gave qualitative observations of which algorithms, even if they do not exactly fulfill the constraints above, tend to produce results that resemble modularity clusterings. Exponents in the forces should be characterized by \(a\ge 0\) and the closer to 0, the better, \(r\le 0\), and \(a-r\approx 1\).Footnote 5

The connection to modularity—which, notably, had not been intended in the design of the algorithms—helped give additional credibility to FDLs in general. They were not only used for illustrative purposes [2, 16, 17], but also to explore and analyse network data [19, 43, 51, 61, 62]. It is, however, unclear what information electric-spring models add to modularity clustering by placing the nodes in a continuous space. It has been stressed that while they have been widely used, a thorough assessment of what exactly is entailed by the produced layouts has not been provided yet [35].Footnote 6 Moreover, many different types of FDLs have been developed, several of which at least approximately subsume modularity clustering.Footnote 7 But which one of them constitutes an appropriate choice for a certain data set at hand?Footnote 8

Stress models

A separate branch of graph drawing is constituted by the so-called stress approaches, which are a type of MDS. They are commonly also subsumed under the term ‘force-directed layout algorithms’. They relate a good graph drawing to good isometry with respect to higher dimensional node distances [38]. That is, uniform edge length is aspired. Stress approaches can generally be used for any data where distances between data points are given. In the special case of networks, they seek to embed a network in a low-dimensional space (for visualization, dimensions should obviously be at most three) and distances between nodes are typically given by the geodesic shortest path between two nodes [13, 36, 38]. This is achieved via a stress function which is supposed to be minimised. A typical stress function is of the form

$$\begin{aligned} \sum _{i<j} w_{ij} \left( \left\Vert \textbf{x}_i - \textbf{x}_j \right\Vert - \text {dist}(i,j)\right) ^2. \end{aligned}$$
(1)

\(\textbf{x}_i\) and \(\textbf{x}_j\) refer to node positions in the low-dimensional space, \(\text {dist}(i,j)\) is the (graph-theoretical) distance between i and j, and \(w_{ij}\) can be given by a term such as \(w_{ij} = \text {dist}(i,j)^{-\alpha }\) and serves as a normalization constant [38]. The stress function was introduced by Kruskal and Seery [39], and popularized by the graph drawing algorithm of Kamada and Kawai [36]. Kamada and Kawai used the Newton–Raphson method to minimise the stress function iteratively. Other, more efficient approaches, such as stress majorization, have also been conceived [25]. Electric-spring models only differentiate between connected and disconnected nodes. Stress models encode different target distances between nodes based, e.g., on the shortest path between them. Hence, the former are of lower descriptive complexity [38].

As has been stated already, MDS approaches to network visualization are types of dimensionality reduction. They simply try to preserve graph-theoretic distances as well as possible. This is why the literature on FDLs appears to have split in two different directions: Electric-spring approaches mediate tightly connected clusters and are evaluated on that basis [34, 47, 62]. The graph drawing community has oriented towards MDS models, since they have an explicit objective function and there are powerful techniques allowing efficient low-dimensional embeddings [13, 14, 25, 38].

Scientists might seek to interpret their layout based on a reasonable interaction mechanism between nodes. For example, what is often sought by social scientists is a plausible account of human behavior which forms the basis of the embedding. Stress models do not provide this. They do optimize an explicit objective function which has a clear interpretation.Footnote 9 However, their objective function aims at preserving a specific topological feature of a network which has been translated into a distance matrix.Footnote 10 Moreover, stress models tend to yield “poor results on certain classes of graphs, which include small worlds and other graphs with many shortcuts or low diameter, and scale-free graphs with highly skewed degree distributions, large 1-shells, or other forms of structural imbalance” [14, p. 228]. Since, for example, social networks often have scale-free properties, this is rather problematic. All in all, it is clear what network embeddings with stress models mean, but this meaning does not point beyond network-immanent topological features.

Latent space models

FDLs are often implemented in easily accessible tools, such as Gephi [7].Footnote 11 Not all researchers using the tools possess the methodological training to assess the mechanics behind them. However, the problems sketched above give an additional explanation for the fact that the limits or benefits of a chosen FDL are usually not discussed and “tools such as Gephi [are often treated as] as black boxes” [15]. As we have seen above, while being heavily used, layouts produced with FDLs are either ambiguous (in the case of electric-spring models) or aim at enforcing uniform edge length.

We propose to base a new type of FDL grounded in latent space models, with which network layouts can be interpreted explicitly in terms of a probabilistic model of node interactions. The approach is general, but as we show, it is especially fruitful for social networks. The distances between nodes can then be given a rigorous interpretation, and forces can be chosen that are suitable to the network data one wants to analyse.

Latent space approaches to network analysis have been developed to infer latent positions from their interactions. They represent a class of models based on the assumption that the probability that two actors establish a relation depends on their positions in an unobserved social space [28, 31]. The social space can be constituted by a continuous space, such as an Euclidean space, or a discrete latent space, where each node is in one of several latent classes [42]. Models of this type have also been introduced under the name of spatially embedded random networks [6]. Under this umbrella term, the Waxman model [65] and random geometric graphs [18, 50] were recognized as specific examples. Recently, latent space models have been employed in the estimation of continuous one-dimensional ideological positions from social media data [4, 5, 33], specifically from Twitter follower networks. These works covered large quantities of users and showed good agreement with, e.g., party registration records in the United States [5]. The estimation of positions in the latent space was achieved with correspondence analysis in [5], while in [4], the posterior density of the parameters was inferred via Markov Chain Monte Carlo methods. Latent space models have also been used to embed dynamic networks [53, 54], and have recently been extended to additionally include attribute information or multiple relationships in one shared embedding [64, 66].

This is where the present work intersects: We attempt to take an alternative route to arrive at a specific form of force equations for FDLs. We obtain the forces on the basis of latent space models. The positions of the nodes in an assumed latent space influence the probability of ties between them—the closer their positions, the more probable it is that they form a tie. We derive an FDL as a maximum-likelihood estimator of such a model. This approach clarifies the underlying assumptions of our layout algorithm and makes the resulting layout interpretable. We derive three different forces for three different types of networks, specifically adapted to the task of embedding them in a political space: unweighted, multi-tie, and weighted networks. Moreover, alternative interaction models can in principle be used to develop force-directed layouts in a completely analogous way. For this, the present work can serve as a blueprint.

While some might claim that the visualization of a network only serves illustrative purposes, their wide-spread use, not only for exploration and illustration, but also visual analysis of networks [17, 19, 43, 61, 62] underscores the necessity of this enterprise: Exploration and interpretation are, in practice, guided by force-directed layouts for many researchers from a variety of disciplines. And especially in the (computational) social sciences, where network data are abundant and exploration and analysis are tied closely to readily implemented algorithms, algorithms that make their assumptions explicit and are suitable to the data that is supposed to be analysed are needed.

From latent space models to force equations

In this section, we show how force terms in a force-directed layout algorithm can be derived from latent space models of node interactions. Central to this procedure is the assumption that nodes tend to form ties to others that are close to them in a latent social space. The closer two nodes, the higher the probability that one forms a tie to the other. Since none of the positions (as well as none of the additional parameters of the statistical model which will be introduced in the corresponding subsections) are directly observed, the statistical problem posed here is their inference. Given the latent space model, one can determine the likelihood function L(G) for any observed network. The positions and parameters are then inferred via maximum-likelihood estimation. In our approach, this is done by treating the negative log-likelihood as a potential energy. The minima of this potential energy are the local maximisers of the likelihood. Its derivatives with respect to the positions and parameters of the nodes can be considered as forces that move the nodes towards positions that maximise the likelihood.

We will cover three different types of directed networks: unweighted networks, such as the follower networks covered by Barberá and colleagues [4, 5], multi-tie networks (which include Twitter retweet networks), and weighted networks. Undirected networks are implicitly included as a special case where \(a_{ij} = a_{ji}\) and each node only has one additional parameter \(\alpha\). We will present the derivation of the forces for the unweighted case in detail. The complete derivations for the other two cases are given in Appendices 7 and 8.

Unweighted networks

Consider an unweighted graph \(G=(V,E)\) with nodes \(i \in V\) and edges \((i,j) \in E\). The graph can be described by an adjacency matrix \(A=\{a_{ij}| a_{ij}=1 \, \text {if} \, (i,j) \in E\}\). Now, let us assume that the nodes are represented by vectors \(\textbf{x}_i \in \mathbb {R}^n\) and \(d_{ij}=d(\textbf{x}_i,\textbf{x}_j)\) denotes the Euclidean distance between \(\textbf{x}_i\) and \(\textbf{x}_j\).Footnote 12 For the probability of a tie between two nodes, we choose (see [31])

$$\begin{aligned} p(a_{ij} = 1) = \text {logit}^{-1}\left( \alpha _{i} + \beta _{j} - d_{ij}^2\right) = \frac{\text {exp}\left( \alpha _{i} + \beta _{j} - d_{ij}^2\right) }{1+\text {exp}\left( \alpha _{i} + \beta _{j} - d_{ij}^2\right) }. \end{aligned}$$
(2)

The probability is dependent on the squared Euclidean distance between the two node positions.Footnote 13 That the probability is dependent on the squared distance is also assumed in [4], while in [5, 31], the linear distance is used. \(\alpha\) and \(\beta\) are additional parameters that also influence the probability of a tie. \(\alpha _i\) can be interpreted as an activity parameter related to the out-degree of node i: The higher \(\alpha _i\), the higher the probability of a tie from i to others. \(\beta _j\) influences the probability of ties to j, i.e., the in-degree of node j. The parameters allow nodes that occupy the same position in space to have different degrees—as an example, there might be people with roughly the same political position as, say, a state leader, but it is generally unreasonable to expect that these users have the same amount of followers on social media. On the other hand, some users might simply be more active than others, hence forming more ties, while sharing a political position.

The model introduced here has already been well established in the literature [4, 5, 31]. However, alternative models can be posited that might be more fitting for certain network types. In that case, the derivation lined out below can be carried out analogously.

For a given graph G, the likelihood function L(G) can be written as the product of the probability of an edge if there exists an edge between two nodes, and the probability of there not being an edge if not

$$\begin{aligned} L(G)&=\prod _{(i,j) \in E} p\left( a_{ij} = 1\right) \prod _{(i,j) \notin E} \left( 1- p\left( a_{ij} = 1\right) \right) \nonumber \\&= \frac{\prod _{(i,j) \in E} \exp {\left( \alpha _i+\beta _j-d_{ij}^2\right) }}{\prod _{\begin{array}{c} i,j \\ i \ne j \end{array}} \left( 1+\exp {\left( \alpha _i+\beta _j-d_{ij}^2\right) }\right) }. \end{aligned}$$
(3)

The logarithm of the likelihood is given by

$$\begin{aligned} LL(G):&=\log L(G) \nonumber \\&=\sum _{(i,j) \in E} \left( \alpha _i+\beta _j-d_{ij}^2\right) - \sum _{\begin{array}{c} i,j \\ i \ne j \end{array}} \log \left( 1+\exp \left( \alpha _i+\beta _j-d_{ij}^2\right) \right) . \end{aligned}$$
(4)

If we consider the negative log-likelihood as a potential energy, its minimas are the local maximisers of the likelihood. Its (negative, once again) derivatives with respect to the positions \(\textbf{x}_i\) of the nodes can be considered as forces that move the nodes towards positions that maximise the likelihood. For a concrete node \(i'\), an attractive force is generated by node \(j'\) if \(i'\) establishes a tie to \(j'\)

$$\begin{aligned} F_{\text {att}, i'}^{j'} = \frac{\partial }{\partial \textbf{x}_{i'}} \left( \alpha _{i'}+\beta _{j'}-d_{i'j'}^2\right) = -2\left( \textbf{x}_{i'}-\textbf{x}_{j'}\right) . \end{aligned}$$
(5)

If \(j'\) also establishes a tie to \(i'\), the same attractive force is applied again. On the other hand, a rejecting force is always present for each possible tieFootnote 14

$$\begin{aligned} F_{\text {rej}, i'}^{j'} = - \frac{\partial }{\partial \textbf{x}_{i'}} \log \left( 1+\exp \left( \alpha _{i'}+\beta _{j'}-d_{i'j'}^2\right) \right) = \frac{1}{1+\text {exp}\left( -\alpha _{i'}-\beta _{j'}+d_{i'j'}^2\right) } 2 \left( \textbf{x}_{i'} - \textbf{x}_{j'}\right) . \end{aligned}$$
(6)

Another repulsive force on \(i'\) appears for this node pair for the potential tie from \(j'\) to \(i'\).

The derivative of Eq. (4) with respect to \(\alpha _{i'}\) and \(\beta _{i'}\) gives us the forces on the parameters of node \(i'\), such that

$$\begin{aligned} F_{\alpha _{i'}}^{j'} = a_{i'j'} - \frac{1}{1+\text {exp}\left( -\alpha _{i'} - \beta _{j'} + d_{i'j'}^2\right) } = a_{i'j'} - p\left( a_{i'j'} = 1\right) \end{aligned}$$
(7)

and

$$\begin{aligned} F_{\beta _{i'}}^{j'} = a_{j'i'} - \frac{1}{1+\text {exp}\left( -\alpha _{j'} - \beta _{i'} + d_{i'j'}^2\right) } = a_{j'i'} - p\left( a_{j'i'} = 1\right) . \end{aligned}$$
(8)

The sum over all forces on the single parameters yields the difference between the actual and the expected in-/out-degree. In the equilibrium state, where this sum yields 0, the observed in-/out-degree of nodes equals the one expected under the model of Eq. (2)

$$\begin{aligned}{} & {} \sum _{j'} F_{\alpha _{i'}}^{j'} = d_i^{\text {out}} - \left\langle d_i^{\text {out}} \right\rangle , \end{aligned}$$
(9)
$$\begin{aligned}{} & {} \sum _{j'} F_{\beta _{i'}}^{j'} = d_i^{\text {in}} - \left\langle d_i^{\text {in}} \right\rangle . \end{aligned}$$
(10)

Multi-tie networks

Force equations can also be derived for networks which are constituted by a number of binary signals between nodes—for example, when users of an online platform create several posts, each of which can be taken up by others (e.g., through liking or sharing the respective post). A much-studied case are Twitter retweet networks, which are frequently employed to investigate opinion groups on the platform [16, 17].

We consider, for each action k initiated by a node j (e.g., a tweet), an unweighted graph \(G_{j}^k=(V,E_{j}^k)\) with nodes \(i \in V\) and edges \((i,j) \in E_{j}^k\), where an edge means that i has formed a tie to j upon action k. The graph for each k can be described by an adjacency matrix \(A_{j}^k=\{a_{ij}| a_{ij}=1 \, \text {if} \, (i,j) \in E_{j}^k\}\). This constitutes an m-star graph with \(m=|E_j^k|\).Footnote 15

Analogously to the unweighted case, we assume the probability of establishing a single tie upon action k from user i to user j with

$$\begin{aligned} p(a_{ij}^k = 1) = \frac{1}{1+\text {exp}\left( -\alpha _i - \beta _{jk}+d_{ij}^2\right) }, \end{aligned}$$
(11)

where each action k of j has its own parameter \(\beta _{jk}\) which affects the in-degree of j.

The log-likelihood for the multi-tie network can be written as

$$\begin{aligned} LL(G) = \sum _{j} \sum _{k=1}^{m_j} \left( \sum _{(i,j)\in E_{jk}}\left( \alpha _i + \beta _{jk} - d_{ij}^2\right) - \sum _{\begin{array}{c} i \\ i\ne j \end{array}} \text {log}\left( 1+e^{-\alpha _i -\beta _{jk}+d_{ij}^2}\right) \right) . \end{aligned}$$
(12)

Here, in addition to user pairs, we sum over all actions k. The derivation of forces for this case is largely analogous to the unweighted case and can be found in Appendix 7, along with the concrete force equations.

Weighted networks

So far, we have assumed a binary signal between node pairs—e.g., whether an individual follows another one or not, or whether someone shares certain content of another individual or not. Extending the model to the non-binary case can be achieved by exchanging the ordinary logit model [Eq. (2)] with an ordered logit or proportional odds model.

There, a response variable has levels 0, 1, ..., n (e.g., people rate their relationships to others on a scale from 0 to 6, or similar). We consider the general case of weighted networks with finite weights that can be transformed into natural numbers (including 0), i.e., an adjacency matrix \(A=\{a_{ij}=k | k \in \mathbb {N}_0\}\). The probability of the variable being greater than or equal to a certain level k is given by [29, 37]

$$\begin{aligned} p(a_{ij} \ge k) = \frac{1}{1 + \text {exp}\left( -c_k - \alpha _i-\beta _j+d_{ij}^2\right) }, \end{aligned}$$
(13)

where \(k = 0,1,...,n.\) (\(c_0 = \infty\), \(c_{n+1} = -\infty\).) The probability of \(a_{ij}\) equal to a certain k is given by

$$\begin{aligned} p\left( a_{ij} = k\right) = P\left( a_{ij} \ge k\right) - P\left( a_{ij} \ge k+1\right) . \end{aligned}$$
(14)

The likelihood L(G) is given by

$$\begin{aligned} L(G) = \prod _{i,j} \left( \frac{1}{1 + \text {exp}\left( -c_{a_{ij}} - \alpha _i-\beta _j+d_{ij}^2\right) } - \frac{1}{1 + \text {exp}\left( -c_{a_{ij}+1} - \alpha _i-\beta _j+d_{ij}^2\right) }\right) , \end{aligned}$$
(15)

and the log-likelihood by

$$\begin{aligned} LL(G) = \sum _{\begin{array}{c} i,j\\ i\ne j \end{array}} \text {log}\left( \frac{1}{1 + \text {exp}\left( -c_{a_{ij}} - \alpha _i-\beta _j+d_{ij}^2\right) } - \frac{1}{1 + \text {exp}\left( -c_{a_{ij}+1} - \alpha _i-\beta _j+d_{ij}^2\right) }\right) . \end{aligned}$$
(16)

The force equations derived from the log-likelihood (for the case of a three-point scale) can be found in Appendix 8. Potential applications of a visualization with these forces are manifold. In smaller data sets, a non-binary signal between nodes, e.g., rating of the relationships between individuals of a social group, might be given between all node pairs. But often, there might be cases for which a subset of individuals (say, politicians, public figures, etc.) or items (e.g., the importance of political goals, technologies, etc.) are rated by others, such that they form a bi-partite network. Then, only the rating individuals receive an \(\alpha\), while the rated just have a \(\beta\)-parameter. The interpretation of the parameters \(\alpha\) and \(\beta\) might need adjustment: They now rather refer to the tendency of individuals to give/receive rather high/low ratings.

Real-world networks

The force-directed layout algorithm was implemented in JavaScript, building upon the d3-force library [10]. There, force equations are simulated using a velocity Verlet integrator [57, 63]. A ready-to-use implementation, which we call Leipzig Layout, is available under https://github.com/pournaki/leipzig-layout.Footnote 16 It builds upon the force-graph library [3] to interactively display the graph and the evolution of node positions in the simulation of forces. Note that at the current state, this layout tool works reasonably fast for networks below 10,000 links. We include a performance benchmark for convergence speed in Appendix 9. Validation is included in Appendix 10.

We use Leipzig Layout to spatialise several real-world networks: Undirected Facebook friendship networks, the directed Twitter follower network of the German parliament, the Twitter retweet network of a debate surrounding the publication of a letter on free speech by Harper’s magazine, and a survey on different types of energy-generating technologies.

Facebook100: Haverford & Caltech

The Facebook100 data set consists of online social networks collected from the Facebook social media platform when the platform was only open to 100 universities in the US [59]. The data set contains social networks of students of particular universities with quite rich metadata (e.g., gender, year, residence, or major). We analyse friendship networks—undirected networks where a tie between users represents that both have agreed to connect with each other as ‘friends’ on the platform. We spatialise the friendship network of Haverford University in Fig. A, B (links have been omitted for better accessibility). On the left, it is visible that students are spatially layered according to their year by the layout algorithm. The first-year students are visually separated from the others. The layout becomes denser for students who have been at the university for a longer time. The layers are ordered chronologically. It seems that if students form cross-year ties, they tend to connect to others from adjacent cohorts. The local assortativity distribution with respect to residence of the students of Haverford has been analysed in detail in [49]. There, it was found that first-year students tend to form ties to other students from their dorms, while students from higher years show less of a tendency to mix only with others they share residence with. This behavioral pattern can also be discerned in the spatialisation (Fig. 1B): For the first-year students, the students sharing a dorm tend to be placed rather close to each other, while for students from higher years, this is not the case. As a complement, we spatialise the network for the university with the highest overall assortativity with respect to dormitory in the data set: Caltech. There, the students’ years do not influence Facebook friendship to a large extent; rather, students’ friendships are more strongly guided by their residences [52]. This is reproduced by Leipzig Layout: Fig. 1 D shows that students that share residence are visibly placed close to each other. On the other hand, students are less strongly grouped according to their university year (C).

Fig. 1
figure 1

Friendship network of students of Haverford University (top) and California Institute of Technology (bottom), colored by year (left), and residence (right). The spatialisation of the former layers students by year (A, chronologically ordered from top to bottom, with first-year students colored pink, second-year students colored green, etc.; dark grey nodes correspond to students whose year is unknown). First-year students are visually separated from the others, while the layout becomes denser if students have been at university for a longer time. In (B), it is also visible that first-year students show a higher tendency to mix with others they share residency with (dark grey: dorm unknown). For Caltech, the network out of the Facebook100 data set with the highest assortativity with respect to residence, nodes are visibly placed according to dorm membership (D, dark grey: year/dorm unknown), and less so with respect to year (C)

German parliament: Twitter follower network

While [4, 5] aim for the estimation of one-dimensional ideological positions of politicians (and their followers), the FDL proposed here embeds nodes in a two-dimensional space. We spatialise the Twitter follower network of all then-members of the German parliament that had an active Twitter account in Fig. 2 as of July 2021. The parties (members colored according to their typical party color) are quite visibly separated. They are located along a circle that quite accurately mirrors the political constellation in federal German politics. The center-left to center-right parties (SPD, Bündnis 90/Die Grünen (Green party), CDU/CSU) are positioned between Die Linke (left party) and the market-liberal FDP. The AfD (blue), a right-wing populist party with which collaboration has been ruled out by all other parties, accordingly occupies a secluded area. Interestingly, within parties, a one-dimensional arrangement is visible (except for the Greens). This mirrors the amount of cross-party ties, as well as the users’ activity on Twitter: The further out on an axis between the innermost and outermost party member users are placed (outliers excluded), the smaller their share of ties to other parties (Fig. 2C). The densely packed placement of the Greens can be explained by the fact that they tend to use Twitter quite homogeneously (see Appendix 12) in the sense that there are no users which are inactive or lack followers: Each of them (except one) has an in-/out-degree of at least 50. Moreover, the party members are followed by and follow all other parties (except for the AfD) in a well-balanced fashion. \(\alpha\) and \(\beta\) are generally correlated with out and in-degree of the nodes (again, see Appendix 12). They exhibit a very pronounced linear correlation for the Greens.

Fig. 2
figure 2

Leipzig layout of the follower network of all German deputies that have a Twitter account (A). Members are colored according to their party and node size corresponds to overall node degree. Clear division between parties, as well as a stronger division between the right-wing party AfD and the other parties is visible. All parties except the Greens are arranged on a one-dimensional axis. This is explained by a difference in cross-party ties between politicians of the same party: The further out a member on the party-internal axis, the fewer cross-party ties to and from them have been established (except for the AfD, which does not receive many ties from other parties no matter where the users are placed) (C, colored according to parties, linear fits included). ForceAtlas2, in comparison, has a stronger separation of nodes within party clusters due to its rejecting force being proportional to \(d^{-1}\) (B)

This layout also illustrates the difference between ForceAtlas2 (see (B) in Fig. 2) and the layout algorithm at hand here: ForceAtlas2 incorporates a rejecting force between node pairs proportional to \(d_{ij}^{-1}\), which leads to a stronger separation of nodes within clusters. Hence, while the overall arrangement of parties is similar to Leipzig Layout, parties themselves are more strongly spaced out. A comparison to spatialisations with the algorithms Yifan Hu and FruchtermanReingold can also be found in Appendix 12.

Moreover, we observe that several minima are inferred by both Leipzig Layout and the other FDLs—depending on the initial positions of the nodes. While the existence of different local minima is a general problem of FDLs, one can simply select the outcome with the highest likelihood with the present approach. A different, but less likely local minimum inferred with Leipzig Layout is also presented in Appendix 12. The more likely minimum, which is displayed in Fig. 2, is also the politically more plausible one: In Appendix 12, SPD is placed closer to FDP than CDU/CSU, while the latter two parties have more commonalities (especially when it comes to economic policy).

Retweet network: Harper’s letter

In July 2020, Harper’s magazine published an open letter signed by 153 public figures defending free speech which they saw endangered by ‘forces of illiberalism.’ Not only Donald Trump was denounced as contributing to illiberalism, but also some groups who advancing “racial and political justice,” who had “intensified a new set of moral attitudes and political commitments that tend to weaken our norms of open debate and toleration of differences in favor of ideological conformity” [1]. On Twitter, the letter was controversially discussed (see also https://blog.twitterexplorer.org/post/harpers_letter/). The layout of the retweet network reproduces a division between critics and supporters of the letter: On the left side of Fig. 3, the account of Harper’s magazine as well as prominent signees such as Thomas Chatterton Williams and Joanne K. Rowling are visible, while the right pole includes critics of the letter and its signees, such as Judd Legum, Astead W. Herndon, and Julia Serano. Serano, a transgender activist, criticized that what the signees referred to as ‘free speech’ has prevented marginalized groups from speaking out, and accused Rowling of having spread disinformation about trans children. That she was voicing rather specific criticism which aimed towards certain signatories of the letter is mirrored in her position close to the margin of the inferred space. Legum and Herndon are placed closer to the center: Legum noted in a relatively nuanced critique that the signees of the letter are not silenced in any way, while Herndon published several ironical tweets about the letter. Interestingly, the division of clusters visible in the layout is not as pronounced as in the spatialisation of the network with ForceAtlas2 and Yifan Hu (see Fig. 11 in Appendix 12), a finding that calls for further systematic investigation.

Fig. 3
figure 3

Retweet network of Twitter debate about a letter on free speech published by Harper’s magazine (node size proportional to in-degree). A two-camp division is visible, where the left pole includes the magazine as well as prominent signees, while the right pole contains critics

Survey data

With the weighted layout, not only generic network data can be spatialised, but also surveys: There, evaluated items as well as respondents are nodes, and forces only exist between items and individuals.

In Fig. 4, we visualize a survey where respondents were asked about their attitude towards six different energy-generating technologies [55]. The responses represent the initial attitudes of respondents with respect to the technologies before being confronted with several pro and counter arguments. Responses were initially given on a nine-point scale, which was aggregated to a three-point scale for visualization. The presented technologies were gas and coal power stations, onshore and offshore wind stations, biomass power stations, and open-space photovoltaics (which we refer to as solar in Fig. 4).

Fig. 4
figure 4

Visualization of a survey on six different energy-generating technologies. The distribution of respondents is plotted as a density in the background (the lighter, the denser they are distributed in an area). Respondents are distributed close to gas, renewable energy-generating technologies, and between them. Two technological axes are visible: One from coal and gas to the renewables, and one among technologies using renewable sources of energy, with onshore and solar occupying central positions, while offshore and biomass are located opposite of each other

The distribution of respondents over the inferred space, given by a density plot (the lighter the color, the more respondents lie in a region of the layout), shows that the vast majority of respondents are located between gas and onshore, solar and offshore energy-generating technologies, while coal is placed far away from most respondents.

Several density peaks exist which correspond to respondents with similar response profiles: one between gas and biomass, one placed rather centrally between gas, offshore, solar, onshore and biomass, two between biomass and solar/onshore, and one at the margin of the space, but closest to offshore and solar/onshore technologies. Even more interesting is the arrangement of technologies themselves, since it shows that collectively, response profiles of individuals create two orthogonal axes along which technologies are placed: One axis is visible from renewables towards technologies relying on fossil sources of energy (gas and coal). On the other hand, renewable sources of energy are distributed along an perpendicular axis. Onshore and solar occupy central positions there, while offshore and biomass are located opposite of each other. The respondents’ distribution and the arrangement of technologies are in line with the average ratings and rating correlations between individuals (see Appendix 13). Average ratings for coal are reported to be significantly lower than for any other technology in [55], gas receives a neutral rating, and renewable technologies (offshore, onshore, solar, and biomass) are rated positively on average. Biomass receives the lowest average rating of the renewables, which is reflected in the distribution of respondents. Biomass has, among the renewables, the weakest correlations with the other renewables. On the other hand, ratings are not negatively correlated with coal or gas. This is mirrored by its placement in Fig. 4.

Outlook

FDLs are frequently employed for network visualization across a variety of scientific disciplines. However, the algorithms are either based on forces whose explicit interpretation is still unclear or on techniques dimensionality reduction which seek to preserve network-immanent topological features.

We have presented a path towards interpretable FDLs based on latent space models. We have derived force equations for Leipzig Layout, a FDL that serves as a maximum-likelihood estimator of said models. We have posited three variants of the FDL, which are applicable to unweighted, multi-tie, and weighted networks, respectively. Exemplary spatialisations of several real-world networks show that important properties of the networks (assessed through different network measures) are reflected by node placement. Moreover, commonalities with, but also differences to the existing FDLs have been pointed out: The latter tend to exhibit a stronger separation of nodes within tightly connected clusters, and, for retweet networks, also between each other.

The new type of FDL presented here makes the assumptions it is based on—the underlying latent space model—explicit, and hence constitutes an attempt to put FDLs on a plausible model of node interactions. Latent space models are well established in the estimation of ideological positions on the basis of (social) networks. In most cases, the ideology estimates have been carried out on a one-dimensional axis. Leipzig Layout infers a two-dimensional latent space.

The model chosen here can, if found necessary for certain network types, be replaced by alternative interaction models. For this purpose, the derivation of forces above can serve as a blueprint. The present approach might also be used to motivate parameter choices for the existing FDLs, such as ForceAtlas2: The degree of influence of edge weights there, for example, can be chosen freely. However, the choice could be guided by agreement with the weighted case of the algorithm implemented here.

The spatialisation of survey data presented above points beyond traditional usage of FDLs, an avenue which should be explored further. Moreover, embeddings produced on latent space models can be used for link prediction, for example, if data are incomplete or if future behavior is supposed to be prognosticated.

Recently, approaches have been developed which assist or replace the force-directed algorithm with neural networks, especially graph neural networks (GNNs) [11, 40]. This might potentially increase convergence speed considerably and might form a possible route to make a layout with the energy (i.e., loss) function above more efficient. We note here that recent work in machine learning also used force-directed layouts that were derived as gradients of an objective function: stochastic neighbor embedding (SNE) [30] and t-SNE [44, 60] used this technique to embed a graph in a lower dimensional space. In these cases, the objective function was not the likelihood of a statistical model but the KL-divergence between two probability distributions.

Limitations remain: The convergence of FDLs to local minima is a problem that cannot be solved by the present approach. The follower network presented in Fig. 2, for instance, possesses several equilibria for which the parties were allocated in different order, both for Leipzig Layout as well as the three algorithms it was compared with. Nevertheless, the underlying model of Leipzig layout allows a comparison of the log-likelihood of several equilibria, out of which the most likely can then be chosen. Minor design options which serve readability could be included in the algorithm in the future. For example, allowing nodes to overlap allows a precise representation of the inferred space. However, if individual nodes are supposed to be discerned, an option that prevents node overlap could be introduced.

Moreover, the role of dimensionality for the outcomes of latent space inference in general has not been studied systematically [42]. For network visualization, an extension to a three-dimensional latent space would be of interest in comparison to the two-dimensional case studied here.