Then, we calculate and setK=3.According to theformula (5), weeasily acquirea node set {1,2,3}which is closest to the node 4.Lastly, we naturally assignthe label '1' to the node 4sincethe labels of majority nodes belong to'1' in the node set {1,2,3}. Fig.2 (b) shows the detected results by the KNN. As we see,node 4 has been clustered into a reasonable category.
Algorithm1describes theprocedures ofinitialization based on the ideology of KNN in detail as follows.
Algorithm 1. The framework of initialization by the KNN technique
Input: The information of a network: adjacent matrix A or node pairs A_pair, the number of nodes: n, the times of iteration: m_iter.
Output: The pre-partition of a network: pre_label.
Step 1. Set each node with a unique label, that is, label={1,2,…,n}.…show more content… Set t=1.
Step 3. Set i=1.
Step 4. Calculate the closeness of the current node with its adjacent nodes, then get the closeness in descending order: Si={Si1,Si2,…,Siq}(i=1,2,…,n), q denotes the number of adjacent nodesof node vi.
Step 5. Set . If K is an even number, reset K=K-1; then go to Step 6.
Step 6. Get the first K values in Si, and find the majority of labels which the K nodes correspond to. Update the label ofvi.
Step 7. Update i=i+1. If i≤n, go to Step 4. Otherwise, go to Step 8.
Step 8. Update t=t+1. Ift≤m_iter, go to Step 3. Else, go to Step 9.
Step 9. Output the results of Initialization: