# A Graph Convolution Collaborative Filtering Integrating Social Relations Recommendation Method
## 4 Proposed Recommendation Method
### The Proposed SRRA Recommendation Algorithm  
In order to facilitate implementation, SRRA algorithm is proposed under the framework of SRGCF model, which is implemented in the form of matrix (see Algorithm 1 for details).  
The interactive matrix is denoted as \(R\in\mathbb{R}^{M\times N}\), \(M\) are the numbers of user and \(N\) are the numbers of item, \(R_{ui}\) equals to \(1\) if \(u\) have interaction with \(i\), if not \(R_{ui}\) equals to \(0\). Then the adjacency matrix \(A\) of \(G_{R}\) is:  
\[A=\begin{cases}0&R\\ R^{T}&0\end{cases} \tag{13}\]  
Let the embedding matrix of layer \(0\) be \(E^{(0)}\in\mathbb{R}^{(M+N)\times d}\), where \(d\) is the dimension of embedding vector, and the \((l+1)\)-th layer matrix can be computed as:  
\[E^{(l+1)}=(D^{-\frac{1}{2}}AD^{-\frac{1}{2}})E^{(l)} \tag{14}\]  
where \(D\) is the degree matrix of \(A\), which is a diagonal matrix and its dimension is \((M+N)\times(M+N)\). Each element \(D_{ii}\) represents the number of non-zero values of the \(i\)-th row vector in \(A\).  
```
Step1: calculate the embeddings of users and items Input:\(R\), \(S\), \(M\), \(N\), \(d\), \(l\) Initialize:\(E^{(0)}=C^{(0)}\), \(K\), \(\alpha=\beta=1/(l+1)\) calculate \(A\) and \(B\) by \(R\), \(S\), respectively calculate \(D\) and \(P\) by \(A\), \(B\), respectively \(E_{U}{}^{(0)},E_{U}{}^{(0)}\gets E^{(0)},\cdots\ C_{U}{}^{(0)}\gets C ^{(0)}\) \(\widetilde{E}_{U}\leftarrow E_{U}{}^{(0)},C_{U}{}^{(0)}\), set \(E_{I}{}^{*}=E_{I}{}^{(0)}\) For\(l\in L\):  calculate \(E^{(l+1)}\) and \(C^{(l+1)}\) by \(E^{(l)},\ C^{(l)}\), respectively  get \(E_{U}{}^{(l+1)},E_{I}{}^{(l+1)}\), \(C_{U}{}^{(l+1)}\) by split \(E^{(l+1)}\), \(C^{(l+1)}\), respectively \(\widetilde{E}_{U}{}^{(l+1)}\gets E_{U}{}^{(l+1)},C_{U}{}^{(l+1)}\) \(E_{U}{}^{*}+=\widetilde{E}_{U}{}^{(l+1)}\), \(E_{U}{}^{*}+=E_{I}{}^{(l+1)}\) End For\(E_{U}{}^{*}=\alpha E_{U}{}^{*}\), \(E_{I}{}^{*}=\beta E_{U}{}^{*}\) Step2: calculate the loss of SRRA set \(L_{BPR}=0\) For\(u\in U\): \(e_{u}{}^{(0)}=lookup\left(E_{U}{}^{(0)},u\right)\) // find the initial vector of user \(u\) from \(E_{U}{}^{(0)}\) \(L_{BPR}+=\left\|e_{u}{}^{(0)}\right\|^{2}\) // add the regularization item into loss For\(i\in R_{u}{}^{\frac{1}{2}}\) // iterate over the positive example item set for user \(u\) \(e_{i}{}^{*}=lookup\left(E_{I}{}^{*},i\right)\) // find the vector of item \(i\) from \(E_{I}{}^{*}\) \(\hat{y}_{ui}=e_{u}{}^{*}{}^{T}e_{i}{}^{*}\) // calculate the score of positive samples For\(j\in R_{u}^{*}\): // iterate over the negative example item set for user \(u\) \(e_{j}{}^{*}=lookup\left(E_{I}{}^{*},j\right)\) \(\hat{y}_{uj}=e_{u}{}^{*}{}^{T}e_{i}{}^{*}\) \(L_{BPR}+=(-\ln\sigma(\hat{y}_{ui}-\hat{y}_{uj}))//\) calculate the BPR loss End For Step3: generate recommendations  Train the algorithm until it converges
```  
**Algorithm 1**Social Relationship Recommendation Algorithm (SRRA).  
Similarly, the social matrix is denoted as \(S\in\mathbb{R}^{M\times M}\), where \(S_{uv}\) is 0 if \(u\) and \(v\) are friends, otherwise \(S_{uv}\) is 1. The adjacency matrix \(B\) of \(G_{S}\) is:  
\[B=\left\{\begin{array}{cc}0&S\\ S^{T}&0\end{array}\right\} \tag{15}\]  
Let the embedding matrix of layer 0 be \(C^{(0)}\in\mathbb{R}^{(M+M)\times d}\), and the user matrix of layer \(l+1\) can be obtained as shown in (16).  
\[C^{(l+1)}=(P^{-\frac{1}{2}}BP^{-\frac{1}{2}})C^{(l)} \tag{16}\]  
where \(P\) is the degree matrix of matrix \(B\).  
Then, due to \(E^{(l)}=stack(E_{U}{}^{(l)},E_{I}{}^{(l)})\), \(E^The final representations can be obtained through integrating the representation of each layer:  
\[E_{U}{}^{*}=\sum_{l=0}^{L}\alpha_{i}\widetilde{E}_{U}{}^{(l)},E_{I}{}^{*}=\sum_{l =0}^{L}\beta_{l}E_{I}{}^{(l)} \tag{18}\]  
We use inner-product to compute score:  
\[\hat{Y}=E_{U}{}^{*T}E_{I}{}^{*} \tag{19}\]