OK, after looking at the source code I see what is being calculated:

Instead of dividing the sum of neighbour strengths by the number of
neighbours, it is divided by the strength of the current node.

Thus we get (3+5)/4 = 2, (4+5)/3 = 3 and (4+3)/5 = 1.4.

That's fine, but I think that this is not at all clear from either the
documentation (C or R) or the name of the function.  This quantity
isn't really an average.  Perhaps the documentation should be
improved.

On 25 April 2017 at 20:32, Szabolcs Horvát <[email protected]> wrote:
> Hello,
>
> I am having some trouble understanding what the
> igraph_avg_nearest_neighbor_degree() function does with weights.  This
> function is called knn() in R.
>
> I thought that it simply computed the average strengths of a vertex's
> neighbours. But this does not seem to be the case.
>
> Let's make a 3-ring with edge weights 1,2,3:
>
> g<-make_ring(3)
> E(g)$weight <- c(1,2,3)
>
> The strengths are 4, 3, 5, as I expected:
>
>> strength(g)
> [1] 4 3 5
>
> knn() gives the following result:
>
>> knn(g)
> $knn
> [1] 2.0 3.0 1.4
>
> I would have expected this to be (3+5)/2 = 4, (4+5)/2 = 4.5, and
> (4+3)/2 = 3.5 for the three vertices, as each of them have two
> neighbours.
>
> What am I misunderstanding?
>
> The documentation says,
>
> "Calculate the average nearest neighbor degree of the given vertices"
>
> and
>
> "If the graph has a weight edge attribute, then this is used by
> default. If this argument is given, then vertex strength (see
> strength) is used instead of vertex degree."
>
> Szabolcs

_______________________________________________
igraph-help mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/igraph-help

Reply via email to