# NodeVector: A Novel Network Node Vectorization with Graph Analysis and Deep Learning
## 3 Materials and Methods
### NodeVector
```
0: Network \(G=(V,E),\epsilon\)
0: Node embeddings of target network
1: /*Initial node representations*/
2: \(L_{1},L_{2},L_{3}\leftarrow\) calculate \(L_{1},L_{2},L_{3}\) level representations
3: \(cc_{adsim}=nn*\epsilon/100\)
4: /*Phase 1: Network enrichment*/
5: Levels \(\leftarrow[L_{1},L_{2},L_{3}]\)
6: Max_Level \(\leftarrow\) 3
7: \(CandidateEdges\gets Get\_Edges(G,Levels,Max\_Level,ccc_{adsim})\)
8: /*Phase II: Embed calculation*/
9: /*create dataset*/
10: \(S^{P}.append(GEdges,CandidateEdges)\)
11: /*negative sampling*/
12:for node pairs \((nx,ny)\) in \(S^{P}\)do
13: \(N^{S}_{xy}=N^{S}_{G^{\prime}}-(N^{T2}_{x}\cup N^{L2}_{y})\)
14: \(sample\leftarrow sample(N^{S}_{xy})\)
15: /*get random sample*/
16: \(S^{N}.append(nx,sample)\)
17: \(S^{N}.append(ny,sample)\)
18:endfor
19: /*create positive data*/
20:for node pairs \((n1,n2)\) in \(S^{P}\)do
21: \(target.append(L1(n1))\)
22: \(context.append(L1(n2))\)
23: \(label.append(true)\)
24:endfor
25: /*create negative data*/
26:for node pairs \((n1,n2)\) in \(S^{N}\)do
27: \(target.append(L1(n1))\)
28: \(context.append(L1(n2))\)
29: \(label.append(false)\)
30:endfor
31: /*create network and train*/
32: \(EmbeddingSize\gets 128\)
33: \(EmbedModel.append(InputLayer(len(G)))\)
34: \(EmbedModel.append(Dense(EmbeddingSize))\)
35: \(TargetModel.append(EmbedModel(target))\)
36: \(ContextModel.append(EmbedModel(context))\)
37: \(NetworkModel.append(\)\(Maks(TargetModel,ContextModel))\)
38: \(NetworkModel.append(Dense(1))\)
39: \(NetworkModel\) train on \(target,context,label\)
40: \(NodeEmbeddings\gets NetworkModel(G)\)
41: return\(NodeEmbeddings\)
```  
**Algorithm 2** NodeVector Calculation. In the initial step of the second phase within our algorithm, we create the training dataset containing positive and negative samples from the enriched network, \(G^{\prime}\). Let us denote positive samples and negative samples with \(S^{P}\) and \(S^{N}\), respectively. To generate positive samples \(S^{P}\) from enriched network \(G^{\prime}\), we consider the neighbors located one edge away from each node. We add all interactions matching the description to the positive sample list of the target node. We evaluate the repeating edges separately and do not delete them. So in total, we have as many positive samples as the number of edges in network \(G^{\prime}\). We generate a negative sample from network \(G^{\prime}\) so that our training dataset remains balanced. The disadvantage is that the dataset is a network rather than a sentence. The information contained in the sentences is not available on the network. In addition, networks have a high rate of false positives and false negatives (see Section 1). We narrow the sampling space to select the most accurate negative samples. As we move away from a given node, \(n_{x}\), in network \(G^{\prime}\), the probability of interaction with node \(n_{x}\) (false negative) decreases. Let us denote the edge between node \(n_{x}\) and node \(n_{y}\) in positive samples with \(e_{xy}\), the node sampling space of edge \(e_{xy}\) with \(N_{xy}^{S}\), all nodes in network \(G^{\prime}\) with \(N_{G^{\prime}}^{S}\), \(L2\) level neighbors of node \(n_{x}\) and \(n_{y}\) with \(N_{x}^{L2}\) and \(N_{y}^{L2}\), respectively. We create the negative sampling space for edge \(e_{xy}\) with the following Equation (4):  
\[N_{xy}^{S}=N_{G^{\prime}}^{S}-(N_{x}^{L2}\cup N_{y}^{L2}). \tag{4}\]  
To generate negative samples \(S^{N}\), we randomly select nodes from the negative sampling node set of the node pair for all nodes in the positive sample edge set. With our sampling algorithm, we generate balanced positive \(S^{P}\) and negative \(S^{N}\) datasets that represent the information contained in the target network, \(G\). We adopt skip-gram and a deep neural network with an unsupervised learning approach for our node vectorization algorithm, which creates node vectors that represent high-level information that each node has in target network \(G\) in a smaller dimensional space.