# How i can calculate and plot knn(k) of outdegree?

**URL:** <https://igraph.discourse.group/t/how-i-can-calculate-and-plot-knn-k-of-outdegree/885>\
**Category:** Usage\
**Tags:** R\
**Created:** [6 October 2021 18:52 UTC](https://igraph.discourse.group/t/how-i-can-calculate-and-plot-knn-k-of-outdegree/885 "2021-10-06T18:52:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alexey\_Didorenko](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/alexey_didorenko/32/483_2.png) [@Alexey\_Didorenko](https://igraph.discourse.group/u/Alexey_Didorenko)\
**Post date:** [6 October 2021 18:52 UTC](https://igraph.discourse.group/t/how-i-can-calculate-and-plot-knn-k-of-outdegree/885/1 "2021-10-06T18:52:48Z")

</div>

I just try to calculate and plot knn(k) of outdegree using function knn(), but there is no parameter “mode” (all, out, in). How i can calculate and plot knn(k) of outdegree without knn()?

---

<div class="post-metadata">

**Author:** ![szhorvat](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/szhorvat/32/3_2.png) [@szhorvat](https://igraph.discourse.group/u/szhorvat)\
**Post date:** [6 October 2021 22:58 UTC](https://igraph.discourse.group/t/how-i-can-calculate-and-plot-knn-k-of-outdegree/885/2 "2021-10-06T22:58:00Z")

</div>

The mode argument has already been implemented and will be included in the next version. In fact, there will be two mode arguments: one controlling finding neighbours, the other for computing their degrees.

Until then, I’m afraid you need to implement it from scratch (I guess with `adjacent_vertices` and `degree`)

---

<div class="post-metadata">

**Author:** ![tamas](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/tamas/32/1261_2.png) [@tamas](https://igraph.discourse.group/u/tamas)\
**Post date:** [7 October 2021 07:11 UTC](https://igraph.discourse.group/t/how-i-can-calculate-and-plot-knn-k-of-outdegree/885/3 "2021-10-07T07:11:55Z")

</div>

Try installing the development version from Github; that one should include the `mode` and `neighbor.degree.mode` arguments:

```auto
library(devtools)
devtools::install_github("igraph/rigraph@master")

```
