Attach vertex label for connected component?

User 512 | 1/21/2015, 10:39:52 PM

I created a sub-graph using the largest connected component. The codes are below:

cc = gl.connectedcomponents.create(g) ccsize = cc['componentsize'] ccsize = ccsize.sort('Count', ascending=False) tgt = ccsize['componentid'][0] tgtnames = ccout[ccout['componentid'] == tgt]['__id'] subgraph = gl.SGraph() subgraph = subgraph.addedges(g.getedges(srcids=tgtnames), srcfield='srcid', dstfield='dst_id')

Then I would like to show this sub-graph on the Canvas. For each id, I have another field for its label, for example,

id id_label 1 Jack 2 Mike ...

Is there any easy way to attach the idlabel field to subgraph's vertices? Basically I want to use the label instead of id as the 'vlabel', that is,'idlabel')


User 15 | 1/21/2015, 11:57:31 PM

Hi Shuning,

Does ''idlabel')' not work? As far as I know any vertex attribute can give the key to vlabel and Canvas will show the value of the attribute. Do you have idlabel set as a vertex attribute?


User 512 | 1/22/2015, 10:24:29 PM

Never mind, I find the reason, the id_label is not an vertex attribute, and I figure out some way to include this in the vertex. Thanks for the reply!