From fd18923ef1b376be4f61d20343cf600f5efcf7c6 Mon Sep 17 00:00:00 2001 From: Benjamin Auder Date: Wed, 15 Jan 2025 22:38:36 +0100 Subject: [PATCH] Add required files for a github_install --- .gitignore | 5 ----- DESCRIPTION | 7 ++++--- LICENSE | 2 +- NAMESPACE | 12 ++++++++++++ R/RcppExports.R | 7 +++++++ README.md | 1 - man/ectd.Rd | 21 +++++++++++++++++++++ man/nng.Rd | 21 +++++++++++++++++++++ src/RcppExports.cpp | 36 ++++++++++++++++++++++++++++++++++++ 9 files changed, 102 insertions(+), 10 deletions(-) create mode 100644 NAMESPACE create mode 100644 R/RcppExports.R create mode 100644 man/ectd.Rd create mode 100644 man/nng.Rd create mode 100644 src/RcppExports.cpp diff --git a/.gitignore b/.gitignore index b07def6..4905182 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,3 @@ -/NAMESPACE -/man/* -!/man/nngd-package.Rd -/R/RcppExports.R -/src/RcppExports.cpp /src/*.o /src/*.so .RData diff --git a/DESCRIPTION b/DESCRIPTION index e882735..7cabf2d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,9 @@ +Encoding: UTF-8 Package: nngd Type: Package Title: Compute distances based on the nearest-neighbors graph. -Version: 1.0 -Date: 2021-12-06 +Version: 1.0.1 +Date: 2025-01-16 Author: Benjamin Auder [aut,cre] Maintainer: Benjamin Auder Description: Only two functions for now. nng() builds the nearest-neighbors graph, @@ -11,4 +12,4 @@ Description: Only two functions for now. nng() builds the nearest-neighbors grap License: MIT + file LICENSE Imports: Rcpp, RcppEigen, igraph, pracma LinkingTo: Rcpp, RcppEigen -RoxygenNote: 7.1.2 +RoxygenNote: 7.3.2 diff --git a/LICENSE b/LICENSE index 9f4ff56..cebe631 100644 --- a/LICENSE +++ b/LICENSE @@ -1,2 +1,2 @@ -YEAR: 2021-2021 +YEAR: 2021-2025 COPYRIGHT HOLDER: Benjamin Auder diff --git a/NAMESPACE b/NAMESPACE new file mode 100644 index 0000000..6c7d3a6 --- /dev/null +++ b/NAMESPACE @@ -0,0 +1,12 @@ +# Generated by roxygen2: do not edit by hand + +export(ectd) +export(nng) +import(Rcpp) +importFrom(igraph,as_edgelist) +importFrom(igraph,components) +importFrom(igraph,graph_from_edgelist) +importFrom(igraph,is_directed) +importFrom(igraph,vcount) +importFrom(pracma,pinv) +useDynLib(nngd, .registration = TRUE) diff --git a/R/RcppExports.R b/R/RcppExports.R new file mode 100644 index 0000000..7b45931 --- /dev/null +++ b/R/RcppExports.R @@ -0,0 +1,7 @@ +# Generated by using Rcpp::compileAttributes() -> do not edit by hand +# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393 + +findNeighbors <- function(data, k, mutual) { + .Call(`_nngd_findNeighbors`, data, k, mutual) +} + diff --git a/README.md b/README.md index 7f7947a..95e9883 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,6 @@ wget https://raw.githubusercontent.com/Rookfighter/knn-cpp/master/include/knncpp ## Usage -roxygenize(".")
R CMD INSTALL .
library(nngd)
?nng
diff --git a/man/ectd.Rd b/man/ectd.Rd new file mode 100644 index 0000000..3d9e74d --- /dev/null +++ b/man/ectd.Rd @@ -0,0 +1,21 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/ectd.R +\name{ectd} +\alias{ectd} +\title{Compute the Euclidian Commute-Time Distances (ECTD) in an undirected graph.} +\usage{ +ectd(o, similarity = function(x) 1, inf.replace = TRUE) +} +\arguments{ +\item{o}{Output of \code{nng}.} + +\item{similarity}{function distance --> similarity.} + +\item{inf.replace}{Replace Inf values by large finite number ?} +} +\value{ +A distances matrix (n x n) +} +\description{ +Assuming similarity function doesn't depend on x, and undirected graph. +} diff --git a/man/nng.Rd b/man/nng.Rd new file mode 100644 index 0000000..40ea7f7 --- /dev/null +++ b/man/nng.Rd @@ -0,0 +1,21 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/nng.R +\name{nng} +\alias{nng} +\title{Compute the nearest-neighbors graph + pairwise distances.} +\usage{ +nng(data, k = ceil(sqrt(nrow(data))), mutual = TRUE) +} +\arguments{ +\item{data}{data.frame or matrix.} + +\item{k}{Number of neighbors at each point.} + +\item{mutual}{Whether or not to build mutual kNN graph.} +} +\value{ +A list with $graph and $distances. +} +\description{ +This is just a wrapper around C++/Rcpp function. +} diff --git a/src/RcppExports.cpp b/src/RcppExports.cpp new file mode 100644 index 0000000..01670fd --- /dev/null +++ b/src/RcppExports.cpp @@ -0,0 +1,36 @@ +// Generated by using Rcpp::compileAttributes() -> do not edit by hand +// Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393 + +#include +#include + +using namespace Rcpp; + +#ifdef RCPP_USE_GLOBAL_ROSTREAM +Rcpp::Rostream& Rcpp::Rcout = Rcpp::Rcpp_cout_get(); +Rcpp::Rostream& Rcpp::Rcerr = Rcpp::Rcpp_cerr_get(); +#endif + +// findNeighbors +List findNeighbors(NumericMatrix data, int k, bool mutual); +RcppExport SEXP _nngd_findNeighbors(SEXP dataSEXP, SEXP kSEXP, SEXP mutualSEXP) { +BEGIN_RCPP + Rcpp::RObject rcpp_result_gen; + Rcpp::RNGScope rcpp_rngScope_gen; + Rcpp::traits::input_parameter< NumericMatrix >::type data(dataSEXP); + Rcpp::traits::input_parameter< int >::type k(kSEXP); + Rcpp::traits::input_parameter< bool >::type mutual(mutualSEXP); + rcpp_result_gen = Rcpp::wrap(findNeighbors(data, k, mutual)); + return rcpp_result_gen; +END_RCPP +} + +static const R_CallMethodDef CallEntries[] = { + {"_nngd_findNeighbors", (DL_FUNC) &_nngd_findNeighbors, 3}, + {NULL, NULL, 0} +}; + +RcppExport void R_init_nngd(DllInfo *dll) { + R_registerRoutines(dll, NULL, CallEntries, NULL, NULL); + R_useDynamicSymbols(dll, FALSE); +} -- 2.44.0