I wrote a shortest path code in Graphchi and I wanted to print the output of that in a file. I was trying to use the template shown in the examples but I get error if I use the sameway of writing to a file as in other examples. I have got stuck here. As the output I just want to print (vertex id,its minimum distance from source). How can i do that.
Asked
Active
Viewed 905 times
1
-
Please provide your code and what error you get. – Aapo Kyrola Aug 24 '12 at 20:45
-
Actually I was using the code from other examples so it is giving eror with that. I will look at the answer you gave and get back to you!! – ayush singhal Aug 28 '12 at 20:51
1 Answers
2
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);

Aapo Kyrola
- 1,100
- 8
- 8