Vary node size based on attribute

User 2327 | 9/27/2015, 7:12:47 AM

Hi, I'm completely new to GraphLab and SNA in general. When drawing my graph, how do I vary the node size/color depending on some attribute (e.g. degrees)? I'd like to make my graph look something more like this - http://2.bp.blogspot.com/_JWKxrhMeRdM/S9hP214XAQI/AAAAAAAAAH4/5ZFDK3epdzE/s1600/gephi+sna.PNG

Thanks.

Comments

User 4 | 9/27/2015, 4:28:36 PM

Hi @fishball, you can use the parameter highlight= on SGraph.show to provide a dictionary of vertex ID to color in RGB triple. The vertex size however cannot be varied independently (all vertices are displayed at the same size). The format of the dictionary looks like this:

sg.show(highlight={ "0": [0., 1., 0.], # green "1": [1., 0., 1.], # red "2": [0., 0., 1.], # blue "3": [0.6875, 0., 0.496] # fuchsia })

To specify the color for each vertex, ensure each vertex ID is present in that dictionary as a a key.


User 2327 | 9/27/2015, 7:05:55 PM

Thanks Zach.