User 270 | 5/5/2014, 3:09:34 AM

I want to write an APP to convert a directed graph to an undirected graph.

The input format is adj, which means "vid nun*of*neighbors neighbor0 neighbor1 ..."

The output format I desired is directed adj, which means "vid num*of*incoming*neighbors in*neighbor0 in*neighbor1 ... num*of*outcoming*neighbors out*neighbor0 out*neighbor1 ..."

I find I can load a graph using load*format function and pass "adj" as a parameter. However, how can I store a graph using adj format? Is there a method to iterate all the incoming and outgoing edges when implementing save*vertex function?

Thanks

User 6 | 5/5/2014, 5:25:01 AM

If I got you correctly you wan to convert an undirected graph into directed (and not as you wrote).
GraphLab's save*vertex and save*edge are not guaranteed to have the ordering you like to have.
I suggest writing an update function that will go over each node and save the edges. You will need to run using --ncpus=1 for not writing in parallel into the same file. It will be fairly easy to do so with the warp engine:
http://docs.graphlab.org/using*warp*graph*vertex*program.html

User 270 | 5/5/2014, 5:38:50 AM

Oh, sorry for my previous statement, fortunately, you got me right.

In my understanding, I have to disable multi-threading in graphlab. However, if I want to do some heavy computation before writing the results to HDFS, then I have to lose multi-threading in the computation, right?

Thanks for your reply.

User 6 | 5/5/2014, 5:45:20 AM

Hi, GraphLab assumes the graph is known before computation. You can write one graphlab program that saves the graph in another format and then another graphlablab program that does computation on the output graph in parallel.

User 270 | 5/5/2014, 6:28:57 AM

Give the following function definition:
void pagerank*update*function(engine*type::context& context, graph*type::vertex_type vertex);

I do not quite understand how to save edges in the update function. Do I need to stored edge inforation on vertex first? Thanks

User 6 | 5/5/2014, 9:39:00 AM

Hi, I did not compile this code, unless there are minor typos it should work

struct pagerank*writer {
std::string save*vertex(graph*type::vertex*type v) {
std::stringstream strm;
strm << v.id() << "\t";
warp::tranform*neighborhood(vertex,
IN*EDGES,
tranform_function, strm);
return strm.str();
}

void tranform*function(graph*type::edge*type edge, graph*type::vertex_type other, std::stringstream & strm ) {
return strm << other.id() << "\t";
}

See: http://docs.graphlab.org/group__warp.html#gac9495a4c3af1033360684c67b9214423