## 4 Methodology
### Graph Generation and Location Recommendation Algorithms  
The modeling and training process of our attributed graph-based model are shown in this section. The construction of attributed bipartite graph is shown in Algorithm 1. The training process of the attributed-GCN is described in Algorithm 2. When training our model, we use Mean Squared Error (MSELoss) and Bayesian Personalized Ranking (BPRLoss) as loss functions and compare their performances [50]. The formula of MSELoss is  
\[L_{mse}=\frac{1}{\|\mathbf{I}_{F}\|_{0}}\Big{\|}\mathbf{I}_{F}\circ\Big{(} \mathbf{F}-\mathbf{U}\mathbf{L}^{\top}\Big{)}\Big{\|}_{2}^{2} \tag{14}\]  
where \(\mathbf{F}\) is the interaction matrix between users and locations. \(\mathbf{I}_{F}\) is the identity matrix of \(\mathbf{F}\). If \(\mathbf{F}_{ij}\
eq 0\), then each element of the corresponding position in \(\mathbf{I}_{F}\) is 1 otherwise 0. \"\(\circ\)\" means the dot product. \(\|\cdot\|_{F}^{2}\) stands for \(\ell_{2}\) norm of vectors.  
BPRLoss considers that positive samples might rank higher than negative samples. In our model, positive samples means the locations that user \(u\) have visited. The formula of BPRLoss is  
\[L_{bpr}=\sum_{(u,l,j,l_{j})\in\mathcal{S}}ln\sigma(\hat{x}_{u\vec{l}_{i}}-\hat {x}_{u\vec{l}_{j}})+\lambda_{\theta}\|\Theta\|_{2}^{2} \tag{15}\]  
where \((u,l_{i},l_{j})\) means user-location pair, \(l_{i}\) means positive sample that user has visited \(l_{j}\) means negative sample. \(\hat{x}_{u\vec{l}_{i}}\) means user \(u^{\prime}\)s rating score on location \(l_{i}\), \(\hat{x}_{u\vec{l}_{j}}\) means user \(u^{\prime}\)s rating score on location \(l_{j}\), \(\hat{x}_{u\vec{l}_{i}}=\mathbf{u}\cdot\mathbf{I}_{\vec{l}}\), \(\hat{x}_{u\vec{l}_{j}}=\mathbf{u}\cdot\mathbf{I}_{\vec{l}}\). \(\mathcal{S}\) means training samples set. \(\sigma(\cdot)\) means sigmoid function. \(\Theta\) means model parameters and \(\lambda_{\theta}\) means regularization parameters.  
```
Input: matrices of user-location, user-app and location-app Output: The attributed bipartite graph \(G\)
1 foreach\(u\in\mathcal{U}\)do
2 Get the maximum visit frequency of \(u\);
3 foreach\(l\in\mathcal{L}\)do
4 Calculate user's preference of location \(l\);
5 Calculate edge weight of node \(u\) to location \(l\);
6
7 end foreach
8 foreach\(u\in\mathcal{U}\)do
9 Get the maximum app usage frequency of \(u\);
10 foreach\(a\in\mathcal{A}\)do
11 Calculate user's preference of app \(a\);
12 Calculate attribute vector \(\mathbf{x}_{u}\) of user \(u\).
13
14 end foreach
15 foreach\(l\in\mathcal{L}\)do
16 Get the maximum app usage frequency in \(l\);
17 foreach\(a\in\mathcal{A}\)do
18 Calculate location's preference of app \(a\);
19 Calculate attribute vector \(\mathbf{x}_{l}\) of location \(l\);
20
21 end foreach
22
23 end foreach
24
25 Bipartite graph \(G\) constructed.
```  
**Algorithm 1**Constructing attributed bipartite graph  
```
Input: bipartite graph \(G\) Output: user representation \(\mathbf{U}\), location representation \(\mathbf{L}\)
1 Calculate the adjacency matrix \(\mathbf{A}\) and the degree matrix \(\mathbf{D}\) of \(G\);
2 while\(MSELoss\) not convergeddo
3 foreach\(u\in\mathcal{U},l\in\mathcal{L}\)do
4 Calculate user representation \(u_{p}\) and location representation \(l_{p}\) via (8)-(11);
5 Optimize Loss function (12);
6 Update parameters \(W_{k}\) by stochastic gradient descent.
7
8 end foreach
9
10 end while
```  
**Algorithm 2**Training process of our model