igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] Graph attributes in R and C


From: Matthew Walker
Subject: Re: [igraph] Graph attributes in R and C
Date: Tue, 19 Oct 2010 23:51:06 -0400
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.12) Gecko/20100915 Thunderbird/3.0.8

On 10-10-19 08:24 PM, Gábor Csárdi wrote:
Hi Matthew,

On Wed, Oct 20, 2010 at 2:00 AM, Matthew Walker
<address@hidden>  wrote:
[...]
Thus, I guess my question is: Is there a correct way to do what I am trying
to do?  Is there a way to convert an R-based-graph-with-attributes to a
C-based-graph-with-attributes?  What would you do?
You can pass the graph attributes that are important to your C
function separately, as regular arguments. The R->C glue code can take
care of this.

Another option is to use the R attribute handler from C, see the code
in foreign.c for examples. E.g. the pajek exporter writes the
attributes into the output file, even if they are defined in R.
Currently only numeric and string attributes are supported here.

Thank you very much for your help. It was very useful to have confirmed that this was indeed the problem. In the end I decided that, given it was just for debug/testing, I could use a "standard" interface: write.graph() and igraph_read_graph_graphml() ... thus converting from R-with-attributes to C-with-attributes ;o)

However, thanks again for your help.

In the process of doing this, I have discovered something interesting though:

This writes out an attribute for each vertex:
> library(igraph)
> g <- erdos.renyi.game(5, 1.0)
> V(g)$has_sensor <- 1
> write.graph(g,"test.graphml","graphml")

But this doesn't!
> library(igraph)
> g <- erdos.renyi.game(5, 1.0)
> V(g)$has_sensor <- TRUE
> write.graph(g,"test.graphml","graphml")


Thanks again for everything,

Matthew



reply via email to

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