Thanks, I was not sure the second was faster as there are additional calls
in my version. Incidentally, thanks for pointing that get.vertex.attribute(g,
attr, id) suffices (instead of get.vertex.attribute(g,attr,V(
g)[which(V(g)$name==id)])). However, how does index correctly understand
that I am using attribute "name"?  How if I wanted to identify the vertex
by an another attribute?

Kindly,
Bob Pap


On 11 April 2014 02:52, Gábor Csárdi <[email protected]> wrote:

> Yes, but the second can be written as get.vertex.attribute(g, attr, id),
> which is a lot more readable and it i also slightly faster.
>
> Gabor
>
>
> On Thu, Apr 10, 2014 at 5:35 PM, Bob Pap <[email protected]> wrote:
>
>> Many thanks dear Gabor. I think the following two should do (equivalent?)
>>
>> 1. function(g,id="identifierXX",attr="betweeness") {
>>  get.vertex.attribute(g,attr)[which(V(g)$name==id)]
>> }
>>
>> 2. function(g,id="identifierXX",attr="betweeness") {
>>  get.vertex.attribute(g,attr,V(g)[which(V(g)$name==id)])
>> }
>>
>>
>> Kindly,
>> Bob Pap
>>
>>
>> On 10 April 2014 18:45, Gábor Csárdi <[email protected]> wrote:
>>
>>> On Thu, Apr 10, 2014 at 12:31 PM, Bob Pap <[email protected]> wrote:
>>>
>>>> Dear all,
>>>>
>>>> Unaware of any method for dealing with multigraphs (in my case a family
>>>> of graphs "g" indexed by time), I handle these by creating a list, indexed
>>>> by the time period, say "Mygraphs", where Mygraphs[["2014-01-01"]] returns
>>>> graph g as it was in 2014-01-01.
>>>>
>>>> I face the need to extract a combination of attributes from the series
>>>> (in the example below the vertex's "id" and "betweeness", ordered by the
>>>> index of Mygraphs), I do so for example as follows:
>>>>
>>>> sapply(
>>>> Mygraphs,
>>>> function(g,id="identifierXX",attr="betweeness") {
>>>> get.vertex.attribute(induced.subgraph(g, which(V(g)$name==id)),attr)
>>>> }
>>>> )
>>>>
>>>> I cannot help to think that the use of induced.subgraph could be
>>>> obviated by specifying the 2 dimensions (id and attr) at once in the
>>>> extraction, but I how would I restrict get.vertex.attribute to only return
>>>> the value for vertex "identifierXX" only?
>>>>
>>>
>>> See the 'index' argument of 'get.vertex.attribute'.
>>> http://igraph.org/r/doc/attributes.html
>>>
>>> Gabor
>>>
>>>
>>>>
>>>> Any guidance would be appreciated.
>>>> Kindly,
>>>> Bob Pap
>>>>
>>>> _______________________________________________
>>>> igraph-help mailing list
>>>> [email protected]
>>>> https://lists.nongnu.org/mailman/listinfo/igraph-help
>>>>
>>>>
>>>
>>> _______________________________________________
>>> igraph-help mailing list
>>> [email protected]
>>> https://lists.nongnu.org/mailman/listinfo/igraph-help
>>>
>>>
>>
>> _______________________________________________
>> igraph-help mailing list
>> [email protected]
>> https://lists.nongnu.org/mailman/listinfo/igraph-help
>>
>>
>
> _______________________________________________
> igraph-help mailing list
> [email protected]
> https://lists.nongnu.org/mailman/listinfo/igraph-help
>
>
_______________________________________________
igraph-help mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/igraph-help

Reply via email to