igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] average neighbors' degree on bipartite networks


From: Simone Gabbriellini
Subject: Re: [igraph] average neighbors' degree on bipartite networks
Date: Fri, 1 Feb 2013 12:36:18 +0100

a related question in order to complete my calculations: now that I
have the 2-dist-nei for each node in set1, I need to apply graph.knn
to each list of 2-dist-nei and calculate its average so to have the
average degree of 2-dist neighbors.

I know how to retrieve this info in non-R style:

for(i in V(g)[which(V(g)$type==FALSE)]$nei2){
        print(mean(graph.knn(g, i)$knn))
}

but how to compact this in order to write:

V(g)[which(V(g)$type==FALSE)]$nei2deg<-COMPACTFORM

Thank you,
Simone

2013/2/1 Simone Gabbriellini <address@hidden>:
> ok, found it:
>
> mapply(setdiff, nei2, nei1)
>
> thanks,
> Simone
>
> 2013/2/1 Simone Gabbriellini <address@hidden>:
>> Hi Gabor,
>>
>> thanks for the info, I got the logic... still have a difficult with
>> basic R commands, I suppose, because I don't know how to filter two
>> lists of lists, i.e. the result of neighborhood():
>>
>> nei1<-neighborhood(g, 1, V(g)[which(V(g)$type==FALSE)])
>> nei2<-neighborhood(g, 2, V(g)[which(V(g)$type==FALSE)])
>>
>> then I tried:
>>
>> V(g)[which(V(g)$type==FALSE)]$nei2<-nei2[which(nei2!=nei1)]
>>
>> or
>>
>> V(g)[which(V(g)$type==FALSE)]$nei2<-lapply(nei2, setdiff, nei1)
>>
>> with no success... tried to google it, but no luck either... If you
>> have suggestions, I'll be happy to hear...
>>
>> Best,
>> Simone
>>
>> 2013/1/31 Gábor Csárdi <address@hidden>:
>>> Hi Simone,
>>>
>>> On Thu, Jan 31, 2013 at 11:14 AM, Simone Gabbriellini
>>> <address@hidden> wrote:
>>>>
>>>> Hello List,
>>>>
>>>> I have a question regarding graph.knn() if applied on bipartite
>>>> networks. When I calculate this:
>>>>
>>>> graph.knn(g, V(g)[type==FALSE])
>>>>
>>>> $knn
>>>>      u43      u62       u9      u17      u19     u102     u127
>>>> u142      u64     u137
>>>> 3.750000 4.250000 4.181818 4.571429 5.600000 5.200000 6.000000
>>>> 5.333333 5.166667 6.000000
>>>
>>> [...]
>>>
>>>>
>>>> what these numbers represents? for each node of set1, I have the
>>>> average degree of the nodes in set2?
>>>
>>>
>>> The average degree of the neighbors of the node. Since your graph is
>>> bipartite, yes, all these neighbors are in set 2.
>>>
>>>>
>>>> if yes, is it possible to extend
>>>> this concept to check for the average degree of dist-2 neighbors -
>>>> i.e. nodes still belonging to set1?
>>>
>>>
>>> Yes, but this is not in igraph and you need to code it for yourself,
>>> probably using neighborhood() is easiest. For bipartite graphs it might be
>>> very easy, actually, because all you need to do for a vertex in set 1 is
>>> taking an order 2 neighborhood, and then removing all vertices from set 2
>>> (first neighbors) and the maybe the node itself, and you end up with the
>>> dist-2 neighbors.
>>>
>>> G.
>>>
>>>>
>>>>
>>>> Many thanks,
>>>> Simone
>>>>
>>>>
>>>> --
>>>> Simone Gabbriellini, PhD
>>>>
>>>> address@hidden, University of Bologna
>>>> mobile: +39 340 39 75 626
>>>> email: address@hidden
>>>> home: www.digitaldust.it
>>>>
>>>> DigitalBrains srl
>>>> Amministratore
>>>> mobile: +39 340 39 75 626
>>>> email: address@hidden
>>>> home: www.digitalbrains.it
>>>>
>>>> _______________________________________________
>>>> igraph-help mailing list
>>>> address@hidden
>>>> https://lists.nongnu.org/mailman/listinfo/igraph-help
>>>
>>>
>>>
>>>
>>> --
>>> Gabor Csardi <address@hidden>     MTA KFKI RMKI
>>>
>>> _______________________________________________
>>> igraph-help mailing list
>>> address@hidden
>>> https://lists.nongnu.org/mailman/listinfo/igraph-help
>>>
>>
>>
>>
>> --
>> Simone Gabbriellini, PhD
>>
>> address@hidden, University of Bologna
>> mobile: +39 340 39 75 626
>> email: address@hidden
>> home: www.digitaldust.it
>>
>> DigitalBrains srl
>> Amministratore
>> mobile: +39 340 39 75 626
>> email: address@hidden
>> home: www.digitalbrains.it
>
>
>
> --
> Simone Gabbriellini, PhD
>
> address@hidden, University of Bologna
> mobile: +39 340 39 75 626
> email: address@hidden
> home: www.digitaldust.it
>
> DigitalBrains srl
> Amministratore
> mobile: +39 340 39 75 626
> email: address@hidden
> home: www.digitalbrains.it



-- 
Simone Gabbriellini, PhD

address@hidden, University of Bologna
mobile: +39 340 39 75 626
email: address@hidden
home: www.digitaldust.it

DigitalBrains srl
Amministratore
mobile: +39 340 39 75 626
email: address@hidden
home: www.digitalbrains.it



reply via email to

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