本文整理汇总了C++中graphchi_vertex::get_vector方法的典型用法代码示例。如果您正苦于以下问题:C++ graphchi_vertex::get_vector方法的具体用法?C++ graphchi_vertex::get_vector怎么用?C++ graphchi_vertex::get_vector使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类graphchi_vertex
的用法示例。
在下文中一共展示了graphchi_vertex::get_vector方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update
void update(graphchi_vertex<VertexDataType, EdgeDataType> &vertex, graphchi_context &gcontext) {
//For iteration 0
if (gcontext.iteration == 0) {
chivector<vid_t> * v_vector = vertex.get_vector();
v_vector->clear();
/* Initialize a json object, rvec to maintain the result vector of the current node.
* Maintain the list of outedges of the current vector.
* These outedges are the children and must match the children of the query node.
* Maintain a vector for all the nodes set to false in the current iteraion.
*/
nlohmann::json rvec;
std::vector<vid_t> vertex_outedges;
std::vector<vid_t> vertex_false;
for (int i = 0; i < vertex.num_outedges(); i++) {
vertex_outedges.push_back(vertex.outedge(i)->vertex_id());
}
/*
* Iterate through all the query nodes, and check the equality with the current node.
* If the current node matches the query node, add the dependencies of the query node to the rvec.
* If the query node does not have any dependencies, set rvec[i] as true. (This implies a direct match)
* If the query node and the current node don't match, set rvec[i] to false and add i to vertex_false.
*/
for(unsigned int i=0; i < query_json["node"].size(); i++) {
if(check_equal(vertex_json[vertex.id()],query_json["node"][i])) {
unsigned int out_d = query_json["node"][i]["out_degree"];
if(out_d == 0){
rvec[i] = true;
v_vector->add(i);
}
else if(vertex_outedges.size() == 0)
{
rvec[i] = false;
vertex_false.push_back(i);
}
else
{ for(unsigned int j=0; j <query_json["edge"].size(); j++){
unsigned int source = query_json["edge"][j]["source"], target = query_json["edge"][j]["target"];
if(i == source )
rvec[i][target] = vertex_outedges;
}
v_vector->add(i);
}
}
else
{
rvec[i] = false;
vertex_false.push_back(i);
}
}
// Access the element of rvec_map with key equal to current vertex id.
// Assign rvec as the value for current vertex id.
tbb::concurrent_hash_map<unsigned int, nlohmann::json>::accessor ac;
rvec_map.insert(ac,vertex.id());
ac->second = rvec;
ac.release();
/*
* If the size of vertex_false is not zero, changes have been made in the current iteration.
* For all the inedges, add the all the elements of vertex_false to the edge vector.
* Schedule all the inedges for the next iteration.
*
*/
if(vertex_false.size() != 0) {
for(int i = 0; i < vertex.num_inedges(); i++) {
chivector<vid_t> * e_vector = vertex.inedge(i)->get_vector();
e_vector->clear();
for(unsigned int j = 0; j< vertex_false.size(); j++){
e_vector->add(vertex_false[j]);
}
gcontext.scheduler->add_task(vertex.inedge(i)->vertex_id());
}
}
}
//For iteration 1..n
else{
/*
* Retrieve the rvec for the current node from the rvec_map.
* Intialize vertex_false to maintain the vertices set to false.
*/
tbb::concurrent_hash_map<unsigned int, nlohmann::json>::accessor ac;
rvec_map.find(ac,vertex.id());
nlohmann::json rvec = ac->second;
std::vector<vid_t> vertex_false;
chivector<vid_t> * v_vector = vertex.get_vector();
//.........这里部分代码省略.........