I am using the igraph package in R.
I would like to associate some data with each vertex, e.g. by adding id and description attributes to each. The attributes are determined at runtime. I have a couple of related questions about how to set and get this data.
To set a vertex's id I use (where g
is a graph):
> set.vertex.attribute(g,'id',1,'first_id') # etc
I expected to be able to read the attributes back with:
> get.vertex.attribute(g,'id',1)
But this returns NULL. Am I doing something wrong?
Further, the function with the get.vertex.attribute
call does not have access to the list of attribute names. How can I extract the attribute names from the graph g
?
Finally, I want to set/get the values of the attributes from/into a named list. Is there a simple way to do that without looping through every vertex and attribute and applying set.
- or get.vertex.attribute
?
thanks!