SGraph.show

User 3672 | 3/17/2016, 6:09:30 AM

Gtest.py

-- coding: utf-8 --

import re import graphlab as gl import time

gl.canvas.set_target('browser')

vertices = gl.SFrame.read_csv('/opt/data/vertices.csv',nrows=100)

edges = gl.SFrame.read_csv('/opt/data/edges.csv',nrows=100)

g = gl.SGraph(vertices=vertices, vidfield='sbh',edges=edges, srcfield='src', dst_field='dst')

print g

g.show(arrows=True,vlabel='name',node_size=300,ewidth=1)

while 1: time.sleep(100000000)

vertices.csv:

nodeid,color,sbh,name 378466,C,310227738510154,上海星胜体育用品有限公司 688185,B,342501197601125016,康翔 161057,C,310115572708442,上海优萃生物科技有限公司 1017910,B,310107133060541,上海复星医药(集团)股份有限公司 499581,L,沈国均,沈国均 168397,C,310114660765121,上海深联机电科技有限公司 286381,C,310141764728288,上海金顾山国际贸易有限公司

edges.csv

src,dst,weight,color 460999,19,1,CL 461207,584,1,CL 462337,617,1,CL 462973,2760,1,CL 461546,2786,1,CL 462156,5379,1,CL 462961,6830,1,CL 461379,10035,1,CL 461183,11616,1,CL 462213,12328,1,CL

when I run the Gtest.py,I always get this answer:

Comments

User 1190 | 3/17/2016, 5:28:04 PM

Hi,

How do you "run" gtest.py? If it is run as script, the python process will terminated when browser is open. Please try ipython -i gtest.py


User 3672 | 3/18/2016, 1:48:03 PM

I run this script by using "python Gtest.py".


User 1190 | 3/19/2016, 8:27:54 PM

if you have to use python, then try the following code: ` $python

execfile( "gtest.py") ` In general, you have to keep the python session alive for the canvas to work.