igraph-help
[Top][All Lists]

## Re: [igraph] how to pick a node with a probability proportional to its d

 From: Simone Gabbriellini Subject: Re: [igraph] how to pick a node with a probability proportional to its degree Date: Fri, 11 Apr 2014 15:43:45 +0200

```super, thanks a lot!

2014-04-11 15:40 GMT+02:00 Gábor Csárdi <address@hidden>:
> g <- graph.tree(10, 3, mode="undirected")
> sample(V(g), 1, prob=degree(g))
> # Vertex sequence:
> # [1] 9
>
> Or, if you want vertex names:
>
> V(g)\$name <- letters[1:10]
> sample(V(g)\$name, 1, prob=degree(g))
> # [1] "b"
>
> Gabor
>
>
> On Fri, Apr 11, 2014 at 9:28 AM, Simone Gabbriellini
>>
>> Dear List,
>>
>> I am trying to pick up a vertex with a probability proportional to its
>> degree. I know that I can do:
>>
>> degs <- degree(g)
>> sample(unique(degs), 1, replace=TRUE, prob = unique(degs))
>>
>> to pick a degree with a probability proportional to its value, but how
>> then to retrieve the corresponding vertex (or one of the ones with
>> that degree value)?
>>
>> Best,
>> Simone
>>
>> --
>> -----------------------------------------------------------------
>>
>> Simone Gabbriellini, PhD
>>
>> Post-doctoral Researcher
>> ANR founded research project "DIFFCERAM"
>> GEMASS, CNRS & Paris-Sorbonne.
>>
>> mobile: +39 340 39 75 626
>>
>> _______________________________________________
>> igraph-help mailing list
>> https://lists.nongnu.org/mailman/listinfo/igraph-help
>
>
>
> _______________________________________________
> igraph-help mailing list
> https://lists.nongnu.org/mailman/listinfo/igraph-help
>

--
-----------------------------------------------------------------

Simone Gabbriellini, PhD

Post-doctoral Researcher
ANR founded research project "DIFFCERAM"
GEMASS, CNRS & Paris-Sorbonne.

mobile: +39 340 39 75 626