本文整理汇总了C++中graph_t::vertices_end方法的典型用法代码示例。如果您正苦于以下问题:C++ graph_t::vertices_end方法的具体用法?C++ graph_t::vertices_end怎么用?C++ graph_t::vertices_end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类graph_t
的用法示例。
在下文中一共展示了graph_t::vertices_end方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dc
//==============================================================//
void dc(graph_t& g, gBenchPerf_event & perf, int perf_group)
{
perf.open(perf_group);
perf.start(perf_group);
#ifdef SIM
SIM_BEGIN(true);
#endif
vertex_iterator vit;
for (vit=g.vertices_begin(); vit!=g.vertices_end(); vit++)
{
// out degree
vit->property().outdegree = vit->edges_size();
// in degree
edge_iterator eit;
for (eit=vit->edges_begin(); eit!=vit->edges_end(); eit++)
{
vertex_iterator targ = g.find_vertex(eit->target());
(targ->property().indegree)++;
}
}
#ifdef SIM
SIM_END(true);
#endif
perf.stop(perf_group);
}// end dc
示例2: degree_analyze
void degree_analyze(graph_t& g,
uint64_t& indegree_max, uint64_t& indegree_min,
uint64_t& outdegree_max, uint64_t& outdegree_min)
{
vertex_iterator vit;
indegree_max=outdegree_max=0;
indegree_min=outdegree_min=numeric_limits<uint64_t>::max();
for (vit=g.vertices_begin(); vit!=g.vertices_end(); vit++)
{
if (indegree_max < vit->property().indegree)
indegree_max = vit->property().indegree;
if (outdegree_max < vit->property().outdegree)
outdegree_max = vit->property().outdegree;
if (indegree_min > vit->property().indegree)
indegree_min = vit->property().indegree;
if (outdegree_min > vit->property().outdegree)
outdegree_min = vit->property().outdegree;
}
return;
}
示例3: reset_graph
void reset_graph(graph_t & g)
{
vertex_iterator vit;
for (vit=g.vertices_begin(); vit!=g.vertices_end(); vit++)
{
vit->property().indegree = 0;
vit->property().outdegree = 0;
}
}
示例4: output
void output(graph_t& g)
{
cout<<"Results: \n";
vertex_iterator vit;
for (vit=g.vertices_begin(); vit!=g.vertices_end(); vit++)
{
cout<<"== vertex "<<vit->id()<<": edge#-"<<vit->edges_size()<<"\n";
}
}
示例5: output
//==============================================================//
void output(graph_t& g)
{
cout<<"Betweenness Centrality Results: \n";
vertex_iterator vit;
for (vit=g.vertices_begin(); vit!=g.vertices_end(); vit++)
{
cout<<"== vertex "<<vit->id()<<": "<<vit->property().BC<<"\n";
}
}
示例6: reset_graph
void reset_graph(graph_t & g)
{
vertex_iterator vit;
for (vit=g.vertices_begin(); vit!=g.vertices_end(); vit++)
{
vit->property().root = vit->id();
}
}
示例7: output
void output(graph_t& g)
{
cout<<"WCC Results: \n";
vertex_iterator vit;
for (vit=g.vertices_begin(); vit!=g.vertices_end(); vit++)
{
cout << vit->id() << " " << vit->property().root << "\n";
}
}
示例8: output
void output(graph_t& g)
{
cout<<"Degree Centrality Results: \n";
vertex_iterator vit;
for (vit=g.vertices_begin(); vit!=g.vertices_end(); vit++)
{
cout<<"== vertex "<<vit->id()<<": in-"<<vit->property().indegree
<<" out-"<<vit->property().outdegree<<"\n";
}
}
示例9: reset_graph
void reset_graph(graph_t & g)
{
vertex_iterator vit;
for (vit=g.vertices_begin(); vit!=g.vertices_end(); vit++)
{
vit->property().degree = 0;
vit->property().removed = false;
}
}
示例10: parallel_init
void parallel_init(graph_t& g, unsigned threadnum,
vector<vector<uint64_t> >& global_input_tasks)
{
global_input_tasks.resize(threadnum);
for (vertex_iterator vit=g.vertices_begin(); vit!=g.vertices_end(); vit++)
{
vit->property().root = vit->id();
global_input_tasks[vertex_distributor(vit->id(), threadnum)].push_back(vit->id());
}
}
示例11: kcore
size_t kcore(graph_t& g, size_t k, gBenchPerf_event & perf, int perf_group)
{
size_t remove_cnt=0;
queue<vertex_iterator> process_q;
// initialize
for (vertex_iterator vit=g.vertices_begin(); vit!=g.vertices_end(); vit++)
{
size_t degree = vit->edges_size();
vit->property().degree = degree;
if (degree < k)
{
process_q.push(vit);
vit->property().removed = true;
remove_cnt++;
}
}
perf.open(perf_group);
perf.start(perf_group);
// remove vertices iteratively
while (!process_q.empty())
{
vertex_iterator vit = process_q.front();
process_q.pop();
for (edge_iterator eit=vit->edges_begin(); eit!=vit->edges_end(); eit++)
{
size_t targ = eit->target();
vertex_iterator targ_vit = g.find_vertex(targ);
if (targ_vit->property().removed==false)
{
targ_vit->property().degree--;
if (targ_vit->property().degree < k)
{
targ_vit->property().removed = true;
process_q.push(targ_vit);
remove_cnt++;
}
}
}
}
perf.stop(perf_group);
return remove_cnt;
} // end kcore
示例12: output
//==============================================================//
void output(graph_t& g)
{
cout<<"kCore Results: \n";
vertex_iterator vit;
for (vit=g.vertices_begin(); vit!=g.vertices_end(); vit++)
{
cout<<"== vertex "<<vit->id()<<": degree-"<<vit->property().degree
<<" removed-";
if (vit->property().removed)
cout<<"true\n";
else
cout<<"false\n";
}
}
示例13: parallel_kcore
size_t parallel_kcore(graph_t& g, size_t k, unsigned threadnum, gBenchPerf_multi & perf, int perf_group)
{
// initialize
size_t remove_cnt=0;
vector<vector<uint64_t> > global_input_tasks(threadnum);
vector<vector<uint64_t> > global_output_tasks(threadnum*threadnum);
for (vertex_iterator vit=g.vertices_begin(); vit!=g.vertices_end(); vit++)
{
size_t degree = vit->edges_size();
vit->property().degree = degree;
if (degree < k)
{
global_input_tasks[vertex_distributor(vit->id(), threadnum)].push_back(vit->id());
vit->property().removed = true;
remove_cnt++;
}
}
bool stop = false;
#pragma omp parallel num_threads(threadnum) shared(stop,global_input_tasks,global_output_tasks)
{
unsigned tid = omp_get_thread_num();
vector<uint64_t> & input_tasks = global_input_tasks[tid];
perf.open(tid, perf_group);
perf.start(tid, perf_group);
while(!stop)
{
#pragma omp barrier
// process local queue
stop = true;
for (unsigned i=0;i<input_tasks.size();i++)
{
uint64_t vid=input_tasks[i];
vertex_iterator vit = g.find_vertex(vid);
for (edge_iterator eit=vit->edges_begin();eit!=vit->edges_end();eit++)
{
uint64_t dest_vid = eit->target();
vertex_iterator destvit = g.find_vertex(dest_vid);
if (destvit->property().removed==false)
{
unsigned oldval = __sync_fetch_and_sub(&(destvit->property().degree), 1);
if (oldval == k)
{
destvit->property().removed=true;
__sync_fetch_and_add(&remove_cnt, 1);
global_output_tasks[vertex_distributor(dest_vid,threadnum)+tid*threadnum].push_back(dest_vid);
}
}
}
}
#pragma omp barrier
input_tasks.clear();
for (unsigned i=0;i<threadnum;i++)
{
if (global_output_tasks[i*threadnum+tid].size()!=0)
{
stop = false;
input_tasks.insert(input_tasks.end(),
global_output_tasks[i*threadnum+tid].begin(),
global_output_tasks[i*threadnum+tid].end());
global_output_tasks[i*threadnum+tid].clear();
}
}
#pragma omp barrier
}
perf.stop(tid, perf_group);
}
return remove_cnt;
}
示例14: bc
void bc(graph_t& g, bool undirected,
gBenchPerf_event & perf, int perf_group)
{
typedef list<size_t> vertex_list_t;
// initialization
size_t vnum = g.num_vertices();
vector<vertex_list_t> shortest_path_parents(vnum);
vector<size_t> num_of_paths(vnum);
vector<int8_t> depth_of_vertices(vnum); // 8 bits signed
vector<double> centrality_update(vnum);
double normalizer;
normalizer = (undirected)? 2.0 : 1.0;
perf.open(perf_group);
perf.start(perf_group);
vertex_iterator vit;
for (vit=g.vertices_begin(); vit!=g.vertices_end(); vit++)
{
size_t vertex_s = vit->id();
stack<size_t> order_seen_stack;
queue<size_t> BFS_queue;
BFS_queue.push(vertex_s);
for (size_t i=0;i<vnum;i++)
{
shortest_path_parents[i].clear();
num_of_paths[i] = (i==vertex_s) ? 1 : 0;
depth_of_vertices[i] = (i==vertex_s) ? 0: -1;
centrality_update[i] = 0;
}
// BFS traversal
while (!BFS_queue.empty())
{
size_t v = BFS_queue.front();
BFS_queue.pop();
order_seen_stack.push(v);
vertex_iterator vit = g.find_vertex(v);
for (edge_iterator eit=vit->edges_begin(); eit!= vit->edges_end(); eit++)
{
size_t w = eit->target();
if (depth_of_vertices[w]<0)
{
BFS_queue.push(w);
depth_of_vertices[w] = depth_of_vertices[v] + 1;
}
if (depth_of_vertices[w] == (depth_of_vertices[v] + 1))
{
num_of_paths[w] += num_of_paths[v];
shortest_path_parents[w].push_back(v);
}
}
}
// dependency accumulation
while (!order_seen_stack.empty())
{
size_t w = order_seen_stack.top();
order_seen_stack.pop();
double coeff = (1+centrality_update[w])/(double)num_of_paths[w];
vertex_list_t::iterator iter;
for (iter=shortest_path_parents[w].begin();
iter!=shortest_path_parents[w].end(); iter++)
{
size_t v=*iter;
centrality_update[v] += (num_of_paths[v]*coeff);
}
if (w!=vertex_s)
{
vertex_iterator vit = g.find_vertex(w);
vit->property().BC += centrality_update[w]/normalizer;
}
}
}
perf.stop(perf_group);
return;
}