資源簡介
節點的核數可以表明節點在核中的深度。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
- 上一篇:LIBCID.LIB
- 下一篇:串口通信C++源代碼
評論
共有 條評論