Label propagation algorithm LPA label propagation algorithm analysis and MATLAB code implementation

Source: Internet
Author: User

the idea of the LPA algorithm :

First, each node has its own unique label, the node will choose their neighbors the most occurrences of the label, if each label appears as many times, then randomly select a label to replace their original label, so back and forth, until each node label no longer change, then the node with the same tag is classified as a community.

Algorithm Advantages : Simple thinking, low complexity of time, suitable for large complex networks.

The disadvantage of the algorithm : It is known that the result of the division is not stable, the stochastic is strong is the fatal disadvantage of this algorithm.

Reflected in: (1) Update order. Node labels are updated in a random order, but it is clear that the more important nodes are updated sooner the convergence process is accelerated

(2) Random selection. If a node has the most occurrences of a neighbor tag more than one, randomly select a label as its own label. Obviously, in the case of the same number of label repetitions, the node is more likely to be selected by the node with a higher similarity to the nodes or the label of the neighbor node with greater influence on this node.

But these shortcomings do not hinder LPA's often used as a benchmark-contrast algorithm for paper, and this idea can be used in machine learning field

Here should be a small case support, first look at someone else's

The point is that the main function needs to load the classic data of the football club we used to use, unfortunately it can't be attached, and later I'll write a blog about data collection

%clc;clear;close all;load (' Footballclub.mat '); newlabels = LPA (footballclub); community = {};class_labels = unique ( Newlabels); class_size = size (class_labels,2); for i=1:class_size    Community{i} = Find (Newlabels==class_labels (i)) ;   endfprintf (' total%d communities \ n ', class_size) for I=1:class_size    if (IsEmpty (community{i}) = = 0)         fprintf ('%d community contains point: ', i)         fprintf ('%d ', community{i})         fprintf (' \ n ')    EndEnd

  

function [Labelnew] = LPA (Adjacent_matrix,label)    if nargin<2        label = 1:size (adjacent_matrix,2);    End    N = size (adjacent_matrix,2);       Label1 = label;    Label2 = Label1;    Labelnew = Label1;    flag=1;    while (1)        for i=1:n            nb_lables = labelnew (Adjacent_matrix (i,:) ==1),% finds the label of the neighbor subscript            if size (nb_lables,2) >0                x = tabulate (nb_lables);                Max_nb_labels = x (x (:, 2) ==max (x (:, 2)), 1);                Labelnew (i) = Max_nb_labels (Randi (Length (max_nb_labels));             End        End        % convergence condition, prevention jump        if All (Labelnew==label1) | | All (Labelnew==label2) break            ;        else            if flag==1                Label1 = labelnew;                flag=0;            else                Label2 = labelnew;                flag=1;            End End end    

  

Label propagation algorithm LPA label propagation algorithm analysis and MATLAB code implementation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.