Hi Tamas, I solved my problem!
There is an issue with the "sample" fuction.
In fact, if the vector to be sampled have a certain dimension, from 2 onwards, no problem.
Otherwise, If the vector has dimension 1, so there is only one element in it (for example a vertex of the graph, and that vertex is called "8") the sample function behave differently: It will create itself a vector (referred to the previous example, it will create a vector of 8 elements, from 1 to 8) and it will sample that new vector.
I solved with an "if": if the vector has lenght>1, ok; If the vector has lenght =1, choose the single element in the vector.