graph.knn()
was renamed to knn()
to create a more
consistent API.
Arguments
- graph
The input graph. It may be directed.
- vids
The vertices for which the calculation is performed. Normally it includes all vertices. Note, that if not all vertices are given here, then both ‘
knn
’ and ‘knnk
’ will be calculated based on the given vertices only.- mode
Character constant to indicate the type of neighbors to consider in directed graphs.
out
considers out-neighbors,in
considers in-neighbors andall
ignores edge directions.- neighbor.degree.mode
The type of degree to average in directed graphs.
out
averages out-degrees,in
averages in-degrees andall
ignores edge directions for the degree calculation.- weights
Weight vector. If the graph has a
weight
edge attribute, then this is used by default. If this argument is given, then vertex strength (seestrength()
) is used instead of vertex degree. But note thatknnk
is still given in the function of the normal vertex degree. Weights are are used to calculate a weighted degree (also calledstrength()
) instead of the degree.