For every node in a set of nodes the graph gets traversed along
the node's shortest paths to its neighbors. Nearest neighbors are added
until a maximum depth of `k`

is reached. For settings where there are more
than `k`

neighbors having the same distance, all neighbors are returned.

1 | ```
nearest.neighbors(nodes, graph, k = 1L, ...)
``` |

`nodes` |
a |

`graph` |
an ( |

`k` |
the depth of the nearest neighbor search, e.g. the depth of the graph traversal |

`...` |
additional parameters |

returns the kNN nodes as list of integer vectors of node indexes

Simon Dirmeier, simon.dirmeier@gmx.de

1 2 3 4 5 6 7 8 | ```
# count of nodes
n <- 10
# indexes (integer) of nodes for which neighbors should be searched
node.idxs <- c(1L, 5L)
# the adjaceny matrix (does not need to be symmetric)
graph <- rbind(cbind(0, diag(n-1)), 0)
# compute the neighbors until depth 3
neighs <- nearest.neighbors(node.idxs, graph, 3)
``` |

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.