Creating nearest neighbor graph with igraph package

Hello all,

I am currently working on a project that involves creating a nearest neighbor graph, and I want to use the igraph package in R. While I've come across the knn function, which calculates average degrees, I haven't found a dedicated function for directly creating a nearest neighbor graph from data.

I would greatly appreciate any insights, advice, or examples that could help me in achieving this task using the igraph package. Specifically, if there are alternative functions or methods within igraph that I might have overlooked for constructing a nearest neighbor graph, I would love to hear about them.

Thank you in advance!

If you have (or can compute) the distances between pairs of nodes, why not just select the nearest neighbor pairs based on the matrix of distances and then use something like graph_from_edgelist() to build the graph?


This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.