Skip to content

Commit

Permalink
revise docs, remove c++11
Browse files Browse the repository at this point in the history
  • Loading branch information
evanbiederstedt committed Jul 3, 2023
1 parent 655bf80 commit 087b45e
Show file tree
Hide file tree
Showing 15 changed files with 109 additions and 56 deletions.
5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Imports:
graphics,
grDevices,
igraph,
methods,
parallel,
Rcpp (>= 1.0.5),
sccore,
Expand All @@ -21,8 +22,8 @@ Suggests:
pbapply,
testthat (>= 3.1.0)
LinkingTo: Rcpp, RcppArmadillo, RcppEigen
SystemRequirements: C++11, GNU make (optional), libxml2 (optional), glpk (>= 4.57, optional)
RoxygenNote: 7.2.1
SystemRequirements: GNU make (optional), libxml2 (optional), glpk (>= 4.57, optional)
RoxygenNote: 7.2.3
URL: https://github.com/kharchenkolab/leidenAlg
BugReports: https://github.com/kharchenkolab/leidenAlg/issues
NeedsCompilation: yes
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ importFrom(igraph,V)
importFrom(igraph,induced.subgraph)
importFrom(igraph,membership)
importFrom(igraph,walktrap.community)
importFrom(methods,is)
importFrom(stats,as.dendrogram)
importFrom(stats,as.hclust)
importFrom(stats,dendrapply)
Expand Down
19 changes: 19 additions & 0 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
# Generated by using Rcpp::compileAttributes() -> do not edit by hand
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393

#' Refer to the R function find_partition()
#' For notes of the graph object, refer to https://igraph.org/c/doc/igraph-Basic.html
#'
#' @param edgelist The graph edge list
#' @param edgelist_length integer The length of the graph edge list
#' @param num_vertices integer The number of vertices in the graph
#' @param direction boolean Whether the graph is directed or undirected
#' @param edge_weights Vector of edge weights. In weighted graphs, a real number is assigned to each (directed or undirected) edge. For an unweighted graph, this is set to 1. Refer to igraph, weighted graphs.
#' @param resolution Integer resoluiton parameter controlling communities detected (default=1.0) Higher resolutions lead to more communities, while lower resolutions lead to fewer communities.
#' @param niter Number of iterations that the algorithm should be run for (default=2)
#' @return A vector of membership values
#' @examples
#' library(igraph)
#' library(leidenAlg)
#'
#' g <- make_star(10)
#' E(g)$weight <- seq(ecount(g))
#' find_partition(g, E(g)$weight)
#'
find_partition_rcpp <- function(edgelist, edgelist_length, num_vertices, direction, edge_weights, resolution = 1.0, niter = 2L) {
.Call('_leidenAlg_find_partition_rcpp', PACKAGE = 'leidenAlg', edgelist, edgelist_length, num_vertices, direction, edge_weights, resolution, niter)
}
Expand Down
7 changes: 4 additions & 3 deletions R/communities.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#' @importFrom igraph membership
#' @importFrom igraph walktrap.community
#' @importFrom igraph induced.subgraph
#' @importFrom methods is
#' @import sccore
#' @importFrom graphics par
#' @importFrom grDevices adjustcolor
Expand Down Expand Up @@ -228,7 +229,7 @@ as.dendrogram.fakeCommunities <- function(object, ...) {

#' Returns pre-calculated membership factor
#'
#' @param object fakeCommunities object
#' @param communities fakeCommunities object
#' @param ... further parameters for generic
#' @return membership factor
#' @examples
Expand All @@ -237,8 +238,8 @@ as.dendrogram.fakeCommunities <- function(object, ...) {
#'
#' @method membership fakeCommunities
#' @export
membership.fakeCommunities <- function(object, ...) {
return(object$membership)
membership.fakeCommunities <- function(communities, ...) {
return(communities$membership)
}


Expand Down
6 changes: 3 additions & 3 deletions man/find_partition.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 48 additions & 0 deletions man/find_partition_rcpp.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/leiden.community.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/membership.fakeCommunities.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions src/Makevars
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ PKG_CFLAGS += -I"./include" -I"../rigraph/include"
LDFLAGS += -lpthread



PKG_LIBS=-L/usr/lib/ -L"." -lpthread -lstdc++ -lleidenalg -lrigraph -lm `$(R_HOME)/bin/Rscript -e "Rcpp:::LdFlags()"` $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) $(SHLIB_OPENMP_CXXFLAGS)
CXX_STD = CXX11
MkInclude = $(R_HOME)/etc${R_ARCH}/Makeconf

#.PHONY: all sublibs
Expand Down
1 change: 0 additions & 1 deletion src/Makevars.win
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ LDFLAGS += -lpthread


PKG_LIBS=-L/usr/lib/ -L"." -lpthread -lstdc++ -lleidenalg -lrigraph -lm `$(R_HOME)/bin/Rscript -e "Rcpp:::LdFlags()"` $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) $(SHLIB_OPENMP_CXXFLAGS)
CXX_STD = CXX11
MkInclude = $(R_HOME)/etc${R_ARCH}/Makeconf

#.PHONY: all sublibs
Expand Down
52 changes: 19 additions & 33 deletions src/leiden.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,37 +22,6 @@ using namespace Rcpp;

// a wrapper for the Leidgen algorithm implementation (https://github.com/vtraag/leidenalg)

// REMOVED v1.1.0 with igraph (R package) v1.5.0
//
// int R_SEXP_to_vector(SEXP sv, igraph_vector_t *v) {
// v->stor_begin=REAL(sv);
// v->stor_end=v->stor_begin+GET_LENGTH(sv);
// v->end=v->stor_end;
// return 0;
// }


// int R_SEXP_to_igraph(SEXP graph, igraph_t *res) {
//
// res->n=(igraph_integer_t) REAL(VECTOR_ELT(graph, 0))[0];
// res->directed=LOGICAL(VECTOR_ELT(graph, 1))[0];
// R_SEXP_to_vector(VECTOR_ELT(graph, 2), &res->from);
// R_SEXP_to_vector(VECTOR_ELT(graph, 3), &res->to);
// R_SEXP_to_vector(VECTOR_ELT(graph, 4), &res->oi);
// R_SEXP_to_vector(VECTOR_ELT(graph, 5), &res->ii);
// R_SEXP_to_vector(VECTOR_ELT(graph, 6), &res->os);
// R_SEXP_to_vector(VECTOR_ELT(graph, 7), &res->is);
//
// /* attributes */
// REAL(VECTOR_ELT(VECTOR_ELT(graph, 8), 0))[0] = 1; /* R objects refcount */
// REAL(VECTOR_ELT(VECTOR_ELT(graph, 8), 0))[1] = 0; /* igraph_t objects */
// res->attr=VECTOR_ELT(graph, 8);
//
// return 0;
// }
//


// https://stackoverflow.com/questions/10250438/using-stdvector-with-igraph

void Stl_To_Igraph_vector_t(std::vector<int>& vectR, igraph_vector_t* v) {
Expand All @@ -68,8 +37,25 @@ void Stl_To_Igraph_vector_t(std::vector<int>& vectR, igraph_vector_t* v) {
}


// Refer to find_partition()
//
//' Refer to the R function find_partition()
//' For notes of the graph object, refer to https://igraph.org/c/doc/igraph-Basic.html
//'
//' @param edgelist The graph edge list
//' @param edgelist_length integer The length of the graph edge list
//' @param num_vertices integer The number of vertices in the graph
//' @param direction boolean Whether the graph is directed or undirected
//' @param edge_weights Vector of edge weights. In weighted graphs, a real number is assigned to each (directed or undirected) edge. For an unweighted graph, this is set to 1. Refer to igraph, weighted graphs.
//' @param resolution Integer resoluiton parameter controlling communities detected (default=1.0) Higher resolutions lead to more communities, while lower resolutions lead to fewer communities.
//' @param niter Number of iterations that the algorithm should be run for (default=2)
//' @return A vector of membership values
//' @examples
//' library(igraph)
//' library(leidenAlg)
//'
//' g <- make_star(10)
//' E(g)$weight <- seq(ecount(g))
//' find_partition(g, E(g)$weight)
//'
// [[Rcpp::export]]
std::vector<size_t> find_partition_rcpp(std::vector<int>& edgelist, int edgelist_length, int num_vertices, bool direction, std::vector<double>& edge_weights, double resolution=1.0, int niter=2) {

Expand Down
2 changes: 1 addition & 1 deletion src/leidenalg/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CXX ?= g++
PKG_CXXFLAGS = -O3 -std=c++11 -pthread -fPIC $(SHLIB_OPENMP_CXXFLAGS)
PKG_CXXFLAGS = -O3 -pthread -fPIC $(SHLIB_OPENMP_CXXFLAGS)
PKG_CXXFLAGS += -I"./include" -I"../rigraph/include"
LDFLAGS += -lpthread

Expand Down
2 changes: 1 addition & 1 deletion src/leidenalg/Makefile.win
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CXX ?= g++
PKG_CXXFLAGS = -O3 -std=c++11 -pthread -fPIC $(SHLIB_OPENMP_CXXFLAGS)
PKG_CXXFLAGS = -O3 -pthread -fPIC $(SHLIB_OPENMP_CXXFLAGS)
PKG_CXXFLAGS += -I"./include" -I"../rigraph/include"
LDFLAGS += -lpthread

Expand Down
6 changes: 3 additions & 3 deletions src/rigraph/Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
C ?= gcc
CFLAGS = -O3 -std=c11 -std=gnu11
PKG_CFLAGS = -O3 -std=c11 -std=gnu11 -pthread -fPIC
CFLAGS = -O3
PKG_CFLAGS = -O3 -pthread -fPIC
PKG_CFLAGS += -I"./include" -I"../rigraph/include"
LDFLAGS += -lpthread


CXX ?= g++
PKG_CXXFLAGS = -O3 -std=c++11 -pthread -fPIC $(SHLIB_OPENMP_CXXFLAGS)
PKG_CXXFLAGS = -O3 -pthread -fPIC $(SHLIB_OPENMP_CXXFLAGS)
PKG_CXXFLAGS += -I"./include" -I"../rigraph/include"
LDFLAGS += -lpthread

Expand Down
6 changes: 3 additions & 3 deletions src/rigraph/Makefile.win
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
C ?= gcc
CFLAGS = -O3 -std=c11 -std=gnu11
PKG_CFLAGS = -O3 -std=c11 -std=gnu11 -pthread -fPIC
CFLAGS = -O3
PKG_CFLAGS = -O3 -pthread -fPIC
PKG_CFLAGS += -I"./include" -I"../rigraph/include"
LDFLAGS += -lpthread

CXX ?= g++
PKG_CXXFLAGS = -O3 -std=c++11 -pthread -fPIC $(SHLIB_OPENMP_CXXFLAGS)
PKG_CXXFLAGS = -O3 -pthread -fPIC $(SHLIB_OPENMP_CXXFLAGS)
PKG_CXXFLAGS += -I"./include" -I"../rigraph/include"
LDFLAGS += -lpthread

Expand Down

0 comments on commit 087b45e

Please sign in to comment.