I need to find the nearest neighbors of nodes in a network. I use the following coding from guideline of CRAN.
# 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)
It finds the neighbors for the index of the nodes which are listed in node.idxs. Can anybody explain why (1L, 5L) has L for indexes. If I remove 'L', it does't work. I need to find the nearest neighbors for all the nodes of the network which I have. I need to change this line for passing dynamic list of indexes.How can I do so?