• 大小: 2KB
    文件类型: .cpp
    金币: 1
    下载: 0 次
    发布日期: 2021-05-26
  • 语言: C/C++
  • 标签: k-core  &  coreness  

资源简介

节点的核数可以表明节点在核中的深度。k-core是指反复去掉度小于或等于k的节点后剩余的子图

资源截图

代码片段和文件信息

/**  
 * Created on 2013-07-16  
 * Owen
 */   
#include“net.h“
extern char In_file;
void chushi_kcore(ALGraph *graph)
{
int i;
linkNode *l_p;
for(i=0;ivexnum;i++)
{
graph->adjlist[i].nodebet=0;
l_p=graph->adjlist[i].first;
while(l_p!=NULL)
{
l_p->edgebet=0;
l_p=l_p->next;
}
}
}
public class Coreness;
 {   
   
    /**  
     * 取得网络nt节点的核数  
     */   
    public static int[] get_core(Network nt);
{   
        int[] core=new int[nt.getNetworkSize()];   
        int[] degrees=nt.n_degrees();   
        int kcore=1;                    //当前的核数    
        boolean bcontinue;   
           
        while(true){   
            while(true)    //反复去掉度小于等于kcore的节点    
            { for(int i=0;i {if(degrees[i]<=kcore && degrees[i]>=0)      //去掉该节点    
{ degrees[i]=-1;   
                  core[i]=kcore;   
                  int[] nbr=nt.n_neighbors(i);     //i的邻居节点    
                  for(int j=0;j

评论

共有 条评论