[Top][All Lists]

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

Re: [igraph] Python bindings issue

From: Filip Hermans
Subject: Re: [igraph] Python bindings issue
Date: Wed, 4 Jun 2008 11:11:35 +0200

Dear Tamas,

Thanks for you quick respons. It was very helpfull to me and pointed out that i got the vertex_attrs dictionary concept wrong. However, it seems like the constructor of the Graph class doesn't support the keyword vertex_attrs. What does the job is something like this

>>> g = Graph(n=2, edges=[(0,1),(0,2)], directed=True)
>>> g.vs["node"] = nodes

The following code still gives the same error
>>> vattrs = {"node": nodes}
>>> g = Graph(n=2, edges=[(0,1),(0,2)], directed=True, vertex_attrs=vattrs)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'vertex_attrs' is an invalid keyword argument for this function

Because of your comments i got a way to make things work, but there is a problem with the direct initialization of the Graph.vs dictionary via the constructor. Maybe this is a problem with my configuration (i am working on a Mac), but i reinstalled igraph and the error stays.

Again, a lot of thanks,


Op 3-jun-08, om 22:29 heeft Tamas Nepusz het volgende geschreven:

Dear Filip,

# create the vertex_attrs dictionary
vattrs = {0:nodes[0],1:nodes[1],2:nodes[2]}
The vertex_attrs dictionary should map attribute names to the list of attribute values. If you use the dictionary above, igraph does not know the attribute name to which it should map the nodes[] array. A better solution is this:

>>> vattrs = {"node": nodes}

This maps the "nodes" list (or more precisely a shallow copy of that) to an attribute called "node":

>>> g = Graph(n=2, edges=[(0,1),(0,2)], directed=True, vertex_attrs=vattrs)
>>> print g.vs["node"]
[<__main__.Node instance at 0x192a3a0>, <__main__.Node instance at 0x192a300>, <__main__.Node instance at 0x192a378>]


igraph-help mailing list

reply via email to

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