• 大小: 203KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-19
  • 语言: Matlab
  • 标签: GN;聚类  

资源简介

聚类算法GN的MATLAB实现一个小应用,希望有所帮助

资源截图

代码片段和文件信息

function accuracy = Accuracy(community vertices)
col_limit = size(community2);
numbers = zeros(41);
i = 1;
while (i <= 4)
    c = 1;
    while (c <= col_limit && community(ic) > 0)
        numbers(i) = numbers(i) + 1;
        c = c + 1;
    end
    i = i + 1;
end
disp(numbers);
accuracy = 0;
step = 1;
example = zeros(432);
example(1:) = [1:32];
example(2:) = [33:64];
example(3:) = [65:96];
example(4:) = [97:128];
row = size(community1);
if row == 4
    s = zeros(44);
    while (step <= row)
        sort(community(step:));
        step = step + 1;
    end
    row1 = 1;   
    while(row1 <= 4)
        row2 = 1;
        while(row2 <=4)
            len1 = length(community(row1:));
            len2 = length(example(row2:));
            col_1 = 1;
            while(col_1 <= len1)
                col_2 = 1;
                while(col_2 <= len2)
                    if community(row1col_1) == example(row2 col_2)
                        s(row1row2) = s(row1 row2) + 1;
                    end
                    col_2 = col_2 + 1;
                end
                col_1 = col_1 + 1;
            end
            row2 = row2 + 1;
        end
        row1 = row1 + 1;
    end
    sum = 0;
    s_copy = s;
    times = 4;
    disp(s);
    while(times > 0)
        max = 0;
        p_row = 0;
        p_col = 0;
        row = 1;
        while (row <= times)
            col = 1;
            while(col <= times)
                if s(rowcol) >= max
                    max = s(rowcol);
                    p_row = row;
                    p_col = col;
                end
                col = col + 1;
            end
            row = row + 1;
        end
        sum = sum + max;
        s(p_row:) = [];
        s(:p_col) = [];
        times = times - 1;
    end
    accuracy = sum / vertices;
    fprintf(‘accuracy: %f‘accuracy);
else
    disp(‘There is not 4 communities terrible error!‘);
end

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2008-05-31 13:28  GN_FN\
     目录           0  2008-05-25 17:30  GN_FN\G_N&F_N\
     文件       33024  2008-05-18 15:31  GN_FN\G_N&F_N\0.1_1.gra
     文件       33024  2008-05-18 15:30  GN_FN\G_N&F_N\0.2_1.gra
     文件       33024  2008-05-18 15:29  GN_FN\G_N&F_N\0.3_1.gra
     文件       33024  2008-05-18 15:23  GN_FN\G_N&F_N\0.4_1.gra
     文件       33024  2008-05-14 10:56  GN_FN\G_N&F_N\0.5_1.gra
     文件       33024  2008-05-14 10:57  GN_FN\G_N&F_N\0.5_2.gra
     文件       33024  2008-05-14 11:01  GN_FN\G_N&F_N\0.5_3.gra
     文件       33024  2008-05-14 11:02  GN_FN\G_N&F_N\0.5_4.gra
     文件       33024  2008-05-14 11:03  GN_FN\G_N&F_N\0.5_5.gra
     文件       33024  2008-05-18 13:07  GN_FN\G_N&F_N\0.63_1.gra
     文件       33024  2008-05-18 13:10  GN_FN\G_N&F_N\0.64_1.gra
     文件       33024  2008-05-18 11:32  GN_FN\G_N&F_N\0.65_1.gra
     文件       33024  2008-05-14 11:07  GN_FN\G_N&F_N\0.6_1.gra
     文件       33024  2008-05-14 11:08  GN_FN\G_N&F_N\0.6_3.gra
     文件       33024  2008-05-14 11:09  GN_FN\G_N&F_N\0.6_4.gra
     文件       33024  2008-05-14 11:09  GN_FN\G_N&F_N\0.6_5.gra
     文件       33024  2008-05-14 11:10  GN_FN\G_N&F_N\0.7_1.gra
     文件       33024  2008-05-14 11:10  GN_FN\G_N&F_N\0.7_2.gra
     文件       33024  2008-05-14 11:11  GN_FN\G_N&F_N\0.7_3.gra
     文件       33024  2008-05-14 11:11  GN_FN\G_N&F_N\0.7_4.gra
     文件       33024  2008-05-14 11:12  GN_FN\G_N&F_N\0.7_5.gra
     文件       33024  2008-05-14 11:12  GN_FN\G_N&F_N\0.8_1.gra
     文件       33024  2008-05-14 11:13  GN_FN\G_N&F_N\0.8_2.gra
     文件       33024  2008-05-14 11:13  GN_FN\G_N&F_N\0.8_3.gra
     文件       33024  2008-05-14 11:14  GN_FN\G_N&F_N\0.8_4.gra
     文件       33024  2008-05-14 11:14  GN_FN\G_N&F_N\0.8_5.gra
     文件       33024  2008-05-14 11:15  GN_FN\G_N&F_N\0.9_1.gra
     文件       33024  2008-05-14 11:15  GN_FN\G_N&F_N\0.9_2.gra
     文件       33024  2008-05-14 11:16  GN_FN\G_N&F_N\0.9_3.gra
............此处省略62个文件信息

评论

共有 条评论

相关资源