# Multivariate Network Layout Using Force-Directed Method with Attribute Constraints
## 3 Methods
### Attribute Community Layout
#### 3.1.1 Spring Force  
Spring force acts on two attribute communities connected by edges, and its calculation formula is as follows:  
\[F_{a}(e_{c_{k}})=(d_{pq}-L_{pq})\cdot\alpha(t)\cdot strength_{a}(e_{c_{k}}) \tag{1}\]  
where \(e_{c_{k}}\) is the edge of calculating the spring force, and \(d_{pq}\) is the Euclidean distance between the centers \(v_{c_{p}}\) and \(v_{c_{q}}\) of the current two attribute communities \(p\) and \(q\), which are connected by \(e_{c_{k}}\). \(L_{pq}\) is the ideal distance between the two attribute communities, i.e., the ideal length of edge \(e_{c_{k}}\), and \(t\) represents time. In our method, it indicates the current iteration number of the algorithm. We set \(\alpha\) as the global temperature at time \(t\), which is used to implement the simulated annealing algorithm, whose function is to reduce the force on the node as the iteration proceeds, control the severity of the changes in the position of the node and finally achieve the convergence of the algorithm. \(strength_{a}\) is the elastic strength of this edge, just like the elastic coefficient. The formulas of \(\alpha\) and \(strength_{a}\) are as follows:  
\[\alpha(t)=\alpha(t-1)+(T-\alpha(t-1))\cdot\alpha_{decay} \tag{2}\]  
\[strength_{a}(e_{c_{k}})=\frac{1}{min(deg_{p},deg_{q})} \tag{3}\]  
where \(T\) is the target value of simulated annealing, \(deg_{p}\) and \(deg_{q}\) are the degrees of the centers \(v_{c_{p}}\) and \(v_{c_{q}}\) of the two attribute communities. The strength of edge \(e_{c_{k}}\) depends on the two connected nodes. \(\alpha_{decay}\) is the decay rate of the simulated annealing algorithm. When \(\alpha\) decreases to less than the threshold, the iteration is terminated.  
There are differences in the number of nodes in communities with different attributes. Therefore the ideal distance between communities \(L_{pq}\) is not static. The community radius should be determined according to the number of nodes in the community. The formula of \(L_{pq}\) is as follows:  
\[L_{pq}=L_{0}+L_{max}\cdot(\sqrt{\frac{n_{c_{p}}}{n}}+\sqrt{\frac{n_{c_{q}}}{n}}) \tag{4}\]  
where \(L_{0}\) is the basic distance between communities, \(n\) is the number of all nodes, \(n_{c_{p}}\) and \(n_{c_{q}}\) are the number of nodes contained in the two attribute communities \(p\) and \(q\). \(L_{max}\) is the maximum distance of the edge, depending on the size of the layout area. The calculation formula is as follows:  
\[L_{max}=\frac{1}{2}\sqrt{W^{2}+H^{2}} \tag{5}\]  
where \(W\) and \(H\) are the width and height of the layout area, respectively. According to the [PERSON] [1] integration algorithm of particle motion simulation, the velocity changes \(\Delta v_{ax}\) and \(\Delta v_{ay}\) of the attribute communities \(p\) and \(q\) in the horizontal and vertical directions under the action of the attractive force \(F_{a}\) can be calculated. The formulas are as follows:  
\[\Delta v_{ax}(q)=\frac{x_{pq}}{d_{pq}}\cdot F_{a}\cdot b_{pq} \tag{6}\]  
\[\Delta v_{ay}(q)=\frac{y_{pq}}{d_{pq}}\cdot F_{a}\cdot b_{pq} \tag{7}\]  
\[\Delta v_{ax}(p)=-\frac{x_{pq}}{d_{pq}}\cdot F_{a}\cdot(1-b_{pq}) \tag{8}\]  
\[\Delta v_{ay}(p)=-\frac{y_{pq}}{d_{pq}}\cdot F_{a}\cdot(1-b_{pq}) \tag{9}\]\[b_{pq}=\frac{deg_{p}}{deg_{p}+deg_{q}} \tag{10}\]  
where \(x_{pq}\) and \(y_{pq}\) are the distances between the attribute communities \(p\) and \(q\) in the horizontal and vertical directions, respectively. \(b_{pq}\) is determined by the degree of the center of the two attribute communities \(v_{c_{p}}\) and \(v_{c_{q}}\). This makes the node with the smaller degree at both ends of the same edge move more.