A Byte of my 2.2-lb Brain

Just sharing stuff…

GraphTool Vertex Attributes

It did take me some time to figure out how to obtain a node’s attribute is using Python’s graph-tool package. In this example, we have a directed graph g with a vertex property called `label`. To extract this information per node, the following code snippet would do.

for v in g.vertices():
    indegree = v.in_degree()
    label = g.vertex_properties["label"][v]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s


This entry was posted on June 23, 2015 by in Geek and tagged , , .
%d bloggers like this: