[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [igraph] question re adding edges
From: |
Gábor Csárdi |
Subject: |
Re: [igraph] question re adding edges |
Date: |
Fri, 7 Sep 2012 15:21:15 -0400 |
Hi Carl, see answers below.
On Fri, Sep 7, 2012 at 11:14 AM, Carl Pearson <address@hidden> wrote:
[...]
> rg <- add.edges(rg, t(array(rg$faction[el], dim=dim(el))), faction=T)
> ## transposing
>
> But I feel like this isn't the "right" way; it doesn't seem to embrace
> the syntax provided by the library. Am I trying to use the syntax
> incorrectly? Is there a more "igraph"y way to do what I'm attempting
> here?
There reason for the need of the transpose is that edges() does not
know about edge list matrices. It assumes that the edges are given
just as a numeric or symbolic vector, or multiple vectors:
The unnamed arguments of ‘edges’ are concatenated and used as
vertex ids of the end points of the new edges. The named
arguments will be added as edge attributes.
Examples:
g <- graph.empty() + vertices(letters[1:10]) +
vertices("foo", "bar", "bar2", "foobar2")
g <- g + edge("a", "b")
g <- g + edges("foo", "bar", "bar2", "foobar2")
g <- g + edges(c("bar", "foo", "foobar2", "bar2"),
color="red", weight=1:2)
And in R, matrices are just vectors with the 'dim' attribute set.
igraph currently simply ignores the 'dim' attribute.
I agree that it would be better to handle edge list matrices, within
edges(), or even without edges(), by just simply doing
rg <- rg + array(rg$faction[el], dim=dim(el))
so I'll see whether this is possible to implement in a clean way. (It
should be.)
Best,
Gabor
[...]
--
Gabor Csardi <address@hidden> MTA KFKI RMKI