[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [igraph] Edges and nodes attributes in python

From: Tamás Nepusz
Subject: Re: [igraph] Edges and nodes attributes in python
Date: Thu, 9 Feb 2012 10:39:58 +0100

Also, you can update the attributes of an entire vertex/edge sequence in a similar way. E.g., to set all the vertex attributes of a graph g at once:

g.vs["color"] = ["red", "green", "blue"]     # assuming that you have 3 vertices

This also works for subsets:

g.vs[0:5]["color"] = ["red", "green", "blue", "yellow", "black"]

or selections:

g.vs.select(_degree_gt=10)["color"] = "red"

In the latter case, one selects the vertices with a degree greater than 10 and then assigns a red color to all of them.


Sent with Sparrow

On Thursday, 9 February 2012 at 01:53, Justin McCann wrote:

On Wed, Feb 8, 2012 at 6:50 PM, kaledje blaise <address@hidden> wrote:

Is it possible to get and set nodes and edges attributes with the python

First, please excuse my original top-post. Second, I hit send too soon.

If you want to set/update attributes, you can use
v['attrname'] = value
or just
variable = v['attrname']

And the same thing works for edges, too.

If you want to just read attributes, you can use something like
attr = v.attributes()
and then look in attr, but it doesn't help for updating the attributes
on the vertex/edge, and it really doesn't buy you anything.


igraph-help mailing list

reply via email to

[Prev in Thread] Current Thread [Next in Thread]