How to load graph from text file using graphlab create?

User 1429 | 4/30/2015, 10:00:56 AM

Sir, I have a text file which contains 1 edge in each line( like 2 4). I want to load graph from this text file. I tried with reading line by line and adding vertices and edges but it is taking too much time. please tell me the simple way to do it . Thank you


User 1768 | 4/30/2015, 10:59:19 AM

I also, have the same problem. Exactly I also, have a txt file contain in each line the ID of the source node and the ID of the destination node. How I can load graph from this text file. Please guide me.

User 1429 | 4/30/2015, 8:35:22 PM

@"Danny Bickson" sir please help us.

User 91 | 4/30/2015, 8:46:23 PM

Let us assume that I have a file as follows

src, dst 1,2 2,3

Then I can do the following

` import graphlab as gl

sf = gl.SFrame.readcsv('edges.csv') sg = gl.SGraph(edges=sf, srcfield='src', dst_field='dst') `

See for more details.

User 1429 | 4/30/2015, 9:04:26 PM

@srikris text file contains graph data in this format

Src dst

1 2 1 3 1 4

User 91 | 4/30/2015, 9:13:05 PM

You can use read_csv with delimiter = ' '

User 1768 | 5/1/2015, 9:36:22 AM

Thanks dear @Srikris, I would like to know how to load a "graph.txt" from my local computer. All examples in Graphlab Create are reading from a http:// in amazon or other sites such as: "g = graphlab.load_graph('', format='snap') , How I can give it the path from my local computer?

User 91 | 5/1/2015, 4:00:34 PM

Local path (relative or absolute) should work seamlessly.

User 1429 | 5/1/2015, 7:21:09 PM

Thank you @srikris . It is working for me. I am a master's student. I want to work on Graphlab Create as a part of my thesis. Can you please tell me on what aspects I can work? please reply as soon as possible. It will be very helpful to me. Thank You

User 91 | 5/1/2015, 7:26:32 PM

You can use the built in algorihtms (there are many) for a lot of applications.

If you want to implement your own, then the SDK is pretty flexible:

Docs: Github:

You can implement pretty much any ML algorithm using these powerful data-structures without much effort. Take a look at it and see if anything interests you.

User 1429 | 5/1/2015, 7:27:01 PM

hey @naoomi sample code. data = gl.SFrame.readcsv('wiki-Vote.txt',header=False,delimiter='\t',columntypehints={'x2':int}) sg = gl.SGraph(edges=data, srcfield='X1', dstfield='X2') pr = graphlab.pagerank.create(sg, maxiterations=10)

User 1768 | 5/3/2015, 7:35:38 AM

Thanks @Harsha and @srikris . Where I need to save "Wiki-vote.txt" or "edges.txt" in my PC. There is no need to give it a path to reach that text file? and there is no way to load the txt as graph, by comment "graph lab.loadgraph" similar to the following and giving the local path instead of URL? "g = graphlab.loadgraph('', format='snap') Please guide me.

User 1768 | 5/8/2015, 8:58:25 AM

I found it in the documentation of graph lab. I was looking for something like this::

import graphlab as gl import os

if os.path.exists('houses.csv'): sf = gl.SFrame.readcsv('houses.csv') else: dataurl = '' sf = gl.SFrame.readcsv(dataurl)'houses.csv')