writing output to a file in Graphchi

北城余情 提交于 2019-12-02 03:25:22

Here is example how you can output values of all vertices to the console. It is easy to modify it to write the output to a file. Note that if you can handle binary files, GraphChi already has the vertex values in a file: .B.vout, where is sizeof(VertexDataType).

1) You need to define a callback-function, which will take vertex id and value as parameter

class OutputVertexCallback : public VCallback<VertexDataType> {
public:

virtual void callback(vid_t vertex_id, VertexDataType &value) {
  std::cout << vertex_id << "=" << value << std::endl;
}
 };

2) Then you need to call foreach_vertices() as follows to get the output:

OutputVertexCallback callback;
foreach_vertices<VertexDataType>(filename, 0, engine.num_vertices(), callback);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!