Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Graph Louvain算法的Julia实现_Graph_Julia_Cluster Analysis - Fatal编程技术网

Graph Louvain算法的Julia实现

Graph Louvain算法的Julia实现,graph,julia,cluster-analysis,Graph,Julia,Cluster Analysis,我试图在朱莉娅身上实现这一点 本文将模块化增益描述为: 其中,Sum_in是C内链路的权重之和,Sum_tot是与C内节点关联的链路的权重之和,K_i是与节点i关联的链路的权重之和,K_i_in是与C内节点关联的链路的权重之和,m是网络中所有链路的权重之和 我的实施是: function linksIn(graph, communities, c)::Float32 reduce(+, map( e-> (communities[e.src

我试图在朱莉娅身上实现这一点

本文将模块化增益描述为:

其中,Sum_in是C内链路的权重之和,Sum_tot是与C内节点关联的链路的权重之和,K_i是与节点i关联的链路的权重之和,K_i_in是与C内节点关联的链路的权重之和,m是网络中所有链路的权重之和

我的实施是:

function linksIn(graph, communities, c)::Float32
    reduce(+,
        map(
            e-> (communities[e.src] == c && communities[e.dst] == c)
                ? e.weight
                : 0
            , edges(graph)
        )
    )
end

function linksTot(graph, communities, c)::Float32
    reduce(+,
        map(
            e-> (communities[e.src] == c || communities[e.dst] == c)
                ? e.weight
                : 0
            , edges(graph)
        )
    )
end

function weightsIncident(graph, node)::Float32
    reduce(+,
        map(
            n-> get_weight(graph, node, n)
            , neighbors(graph, node)
        )
    )
end

function weightsIncidentComunity(graph,communities, node, c)::Float32
    reduce(+,
        map(
            n-> (c == communities[n])
                ? get_weight(graph, node, n)
                : 0
            , neighbors(graph, node)
        )
    )
end

function modulGain(graph, communities, node, c)::Float32

    # Calculate the variables of the modularity gain equation
    wIn = linksIn(graph, communities, c);
    wTot = linksTot(graph, communities, c);
    k = weightsIncident(graph, node);
    k_com = weightsIncidentComunity(graph, communities, node, c);
    m = reduce(+, map(e->e.weight, edges(graph)));


    # return the result of the modularity gain equation

    return ((wIn +k_com) / (2*m) - ((wTot+k)/(2m))^2 )
        - ((wIn/(2m)) - (wTot/(2m))^2 - (k/(2m))^2 )
end
如果我比较function
modulegain
的结果以及模块性的差异,我会得到以下第一个过程的示例,其中每个节点都有自己的组件

  • 模增益(图,社区,1,1)->0.00010885417
  • 模差(图,社区,1,1)->0.0

  • 模增益(图,社区,1,3)->4.806646e-5
  • 模差(图,社区,1,3)->5.51432459e-5
当使用模块化增益方程运行算法时,它往往陷入无限循环。 我想避免使用模块化差异,因为使用模块化增益方程时,性能有明显的提高

有人能解释一下我的实现有什么问题吗? 多谢各位