Weighted Edges TSV

User 127 | 7/9/2014, 10:59:05 PM


According to this page: http://docs.graphlab.org/graph_formats.html the formats do not support storing graph data.

I'd like to use the TSV edge list format, but with an extra digit on the end of each line to represent the edge weight. What's a way to go about doing this? Do I have to make my own parser, or are there any pre-made parsers out there that can handle this? Any built-in methods?

Thanks, Bryan


User 6 | 7/10/2014, 6:24:23 AM

Hi, You should implement a function similar to lineparser in this example: http://docs.graphlab.org/usinggraphlabdistributedgraphloaddata.html that will parse your own format.

User 127 | 7/10/2014, 4:24:03 PM

How would I go about changing the code for the graph_analytics programs to do this? It looks like it parses commandline arguments already, so do I call the my line parser for the "graph" variable in main?

User 6 | 7/10/2014, 4:41:15 PM

This line parser only parses the graph input file and not the command line arguments. This is the call which activates the line parser:

graph.load("graph.txt", line_parser);

User 127 | 7/10/2014, 6:19:03 PM

Thanks. I just implemented the line_parser function for the format I described. I ran PageRank, it seemed to work (gave me results) but there are many errors in loading the graph saying that self-edges are not allowed. When there are self-edges, will GraphLab just ignore them and move on? Self-edges shouldn't affect the PageRank calculations in theory.

Edit: here is my code bool lineparser(graphtype& graph, const std::string& filename, const std::string& textline) { std::stringstream strm(textline); graphlab::vertexidtype vidsource, viddest; std::string pagename; // first entry in the line is a vertex ID strm >> vidsource; strm >> viddest; // insert this web page graph.addvertex(vidsource); graph.addvertex(viddest); graph.addedge(vidsource, vid_dest); return true; }

User 6 | 7/10/2014, 6:36:24 PM

You can add a simple check if (vidsource != viddest) graph.add_edge(...)

to verify no self edges are added. If you need to store weight of a vertex, please store it inside the vertex data.