# Multivariate Network Layout Using Force-Directed Method with Attribute Constraints
## 3 Methods
### Node Layout
#### 3.2.3 Community Force  
Community force refers to the attraction that the center of the attribute community exerts on the nodes of the same attribute. Its function is to draw the nodes of the same attribute into the same attribute community. The formula for node i in the attribute community to be attracted by the community center \(v_{c_{p}}=(x_{c_{p}},y_{c_{p}})\) is as follows:  
\[F_{k}(i)=(d_{ip}-L_{max}\cdot\sqrt{\frac{n_{c_{p}}}{n}}\cdot\sigma)\cdot\alpha(t )\cdot strength_{k}(i,p) \tag{36}\]  
where \(d_{ip}\) is the Euclidean distance between the node \(i\) and the community center \(v_{c_{p}}\), \(\sigma\) is a parameter to control the ideal distance between the node and the community center, \(strength_{k}(i,p)\) is the strength of the community force. Its formula is as follows:  
\[strength_{k}(i,p)=S\cdot\sqrt{\frac{n_{i-d}}{n_{i-s}}} \tag{37}\]  
where \(S\) is the default value of community force strength, \(n_{i-d}\) is the number of nodes with different attributes connected to node \(i\), \(n_{i-s}\) is the number of nodes with the same attributes connected to node \(i\). In this way, nodes with more different types of nodes than nodes of the same type in the neighborhood can be closer to their own attribute communities to maintain discrimination. Further, under the influence of the community force, the velocity change of the node \(i\) in the horizontal and vertical directions is:  
\[\Delta v_{kx}(i)=\frac{x_{ip}}{d_{ip}}\cdot F_{k}\cdot b_{ip} \tag{38}\]  
\[\Delta v_{ky}(i)=\frac{y_{ip}}{d_{ip}}\cdot F_{k}\cdot b_{ip} \tag{39}\]  
\[b_{ip}=(\frac{deg_{p-max}}{deg_{i}+deg_{p-max}})^{2} \tag{40}\]  
where \(x_{ip}\) and \(y_{ip}\) are the distance between node \(i\) and the center of the attribute community \(v_{c_{p}}\) in the horizontal and vertical directions, respectively, and \(deg_{p-max}\) is the maximum value of the node degree in the attribute community \(p\).  
Finally, under the action of attractive force, repulsive force, collision force, central force, and attribute community force, the position of each node is calculated; the formula is as follows:  
\[\Delta v_{x}(i)=\sum_{a}\Delta v_{ax}(i)+\sum_{r}\Delta v_{rx}(i)+\sum_{c} \Delta v_{cx}(i)+\Delta v_{ox}(i)+\Delta v_{kx}(i) \tag{41}\]  
\[\Delta v_{y}(i)=\sum_{a}\Delta v_{ay}(i)+\sum_{r}\Delta v_{ry}(i)+\sum_{c} \Delta v_{cy}(i)+\Delta v_{oy}(i)+\Delta v_{ky}(i) \tag{42}\]  
\[x_{i}=x_{i}^{\prime}+(v_{x}^{\prime}(i)+\Delta v_{x}(i))\cdot\beta \tag{43}\]  
\[y_{i}=y_{i}^{\prime}+(v_{y}^{\prime}(i)+\Delta v_{y}(i))\cdot\beta \tag{44}\]  
Algorithm 1 is a flow chart of the entire algorithm process, which introduces the overall layout algorithm of the multivariate network with attribute constraints.  
```
Input:\(G=(V,E)\): a multivariate networks; \(T\): the target temperature; \(\alpha\): the current temperature \(V=\{v_{i},v_{2},...,v_{n}\}\): the position of nodes
1 Randomly initialize the attribute community center \(V_{C}=\{v_{c_{1}},v_{c_{2}},...,v_{c_{n}}\}\);
2 for every pair of nodes in \(G\)do
3 Generate edges \(E_{C}=(e_{c_{1}},e_{c_{2}},\ldots,e_{c_{m}})\) between communities according to the connection relationship between nodes;
4 while\(\alpha>T\)do
5 Update current temperature \(\alpha\);
6 for each node \(v_{c_{i}}\) in \(V_{C}\)do
7 Get the velocity change \(\Delta v_{a},\Delta v_{r},\Delta v_{c}and\Delta v_{o}\);
8 Get the total velocity change \(\Delta v\);
9 Update the position of \(v_{c_{i}}\);
10
11 while\(\alpha>T\)do
12 Update current temperature \(\alpha\);
13 for each node \(v_{i}\) in \(V\)do
14 Get the velocity change \(\Delta v_{a},\Delta v_{r},\Delta v_{c},\Delta v_{o}and\Delta v_{k}\);
15 Get the total velocity change \(\Delta v\);
16 Update the position of \(v_{i}\);
17
18 return\(V\);
```  
**Algorithm 1**Attribute Constraint Layout