91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 6KB
    文件類型: .cpp
    金幣: 1
    下載: 0 次
    發布日期: 2021-06-08
  • 語言: C/C++
  • 標簽: graphchi??bfs??

資源簡介

Graphchi環境下的BFS算法實現,實現的具體描述請參考本人博客http://blog.csdn.net/codeera/article/details/46385711

資源截圖

代碼片段和文件信息


/**
?*?@file
?*?@author??Aapo?Kyrola?
?*?@version?1.0
?*
?*?@section?LICENSE
?*
?*?Copyright?[2012]?[Aapo?Kyrola?Guy?Blelloch?Carlos?Guestrin?/?Carnegie?Mellon?University]
?*?
?*?Licensed?under?the?Apache?License?Version?2.0?(the?“License“);
?*?you?may?not?use?this?file?except?in?compliance?with?the?License.
?*?You?may?obtain?a?copy?of?the?License?at
?*?
?*?http://www.apache.org/licenses/LICENSE-2.0
?*?
?*?Unless?required?by?applicable?law?or?agreed?to?in?writing?software
?*?distributed?under?the?License?is?distributed?on?an?“AS?IS“?BASIS
?*?WITHOUT?WARRANTIES?OR?CONDITIONS?OF?ANY?KIND?either?express?or?implied.
?*?See?the?License?for?the?specific?language?governing?permissions?and
?*?limitations?under?the?License.
?
?*
?*?@section?DEscriptION
?*
?*?Template?for?GraphChi?applications.?To?create?a?new?application?duplicate
?*?this?template.
?*/



#include?

#include?“graphchi_basic_includes.hpp“
#include?“util/labelanalysis.hpp“

using?namespace?graphchi;

/**
??*?Type?definitions.?Remember?to?create?suitable?graph?shards?using?the
??*?Sharder-program.?
??*/
typedef?unsigned?VertexDataType;
typedef?unsigned??EdgeDataType;


unsigned?single_source?=?1;
bool?converged?=?false;
unsigned?maxlevel?=?10000000;
bool?scheduler?=?true;
/**
??*?GraphChi?programs?need?to?subclass?GraphChiProgram?
??*?class.?The?main?logic?is?usually?in?the?update?function.
??*/
struct?bfs?:?public?GraphChiProgram?{
????
?
????/**
?????*??Vertex?update?function.
?????*/
????void?update(graphchi_vertex?&vertex?graphchi_context?&gcontext)?{

????????if?(gcontext.iteration?==?0)?{
????????????/*?On?first?iteration?initialize?vertex?(and?its?edges).?This?is?usually?required?because
???????????????on?each?run?GraphChi?will?modify?the?data?files.?To?start?from?scratch?it?is?easiest
???????????????do?initialize?the?program?in?code.?Alternatively?you?can?keep?a?copy?of?initial?data?files.?*/
????????????//?vertex.set_data(init_value);
// if(vertex.num_inedges()?==?0)
if(vertex.id()?==?single_source)
{
vertex.set_data(single_source);
for(int??id?=?0;?id? {
if(scheduler)
gcontext.scheduler->add_task(vertex.outedge(id)->vertexid);
vertex.outedge(id)->set_data(vertex.get_data());
}
}
else
{
vertex.set_data(maxlevel);
for(int?id??=?0;?id? {
vertex.outedge(id)->set_data(vertex.get_data());
if(scheduler)
{
gcontext.scheduler->add_task(vertex.outedge(id)->vertex_id());
}
}
}????????

????????}?else?{
????????????/*?Do?computation?*/?

????????????/*?Loop?over?in-edges?(example)?*/
????????????for(int?i=0;?i?????????????????//?Do?something
????????????//????value?+=?vertex.ine

評論

共有 條評論