Skip to content

Commit

Permalink
More lightweight package
Browse files Browse the repository at this point in the history
  • Loading branch information
gvegayon committed Aug 8, 2017
1 parent f2baa8d commit 7468d50
Show file tree
Hide file tree
Showing 40 changed files with 574 additions and 559 deletions.
3 changes: 0 additions & 3 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,12 @@ README[.]md
^README\_files$
[.]travis[.]yml
^appveyor\.yml$

# Not-ready vignettes
^vignettes/simulating.+\.Rmd$
^vignettes/structural.+\.Rmd$

# CRAN
^NEWS\.md$
^cran-comments\.md$
^next_release\.md$

^src/rgraph_scale_free.+$
makefile
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2017-07-23 George G. Vega Yon <[email protected]>
* : Working on making the package more light weight.
* : Checking included datasets duplicated columns.
* : Working on documentation

2017-07-23 George G. Vega Yon <[email protected]>
* src/adjmat.cpp: rewriting egonet_attrs_cpp. Now more efficient
should correct errors produced on windows.
Expand Down
3 changes: 2 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ importFrom(igraph,graph_attr_names)
importFrom(igraph,graph_from_adjacency_matrix)
importFrom(igraph,is.loop)
importFrom(igraph,layout_nicely)
importFrom(igraph,list.edge.attributes)
importFrom(igraph,make_graph)
importFrom(igraph,permute)
importFrom(igraph,set_graph_attr)
Expand Down Expand Up @@ -238,4 +239,4 @@ importFrom(utils,getFromNamespace)
importFrom(utils,head)
importFrom(utils,str)
importMethodsFrom(Matrix,t)
useDynLib(netdiffuseR)
useDynLib(netdiffuseR, .registration = TRUE)
20 changes: 20 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
# Changes in netdiffuseR version 1.18.2999 (dev)

## New functions

## Bug fixes

* `igraph_to_diffnet` was failing with the graph had no weights.

* `drop_isolated` was not behaving well for diffnet objects.


## Other changes

* Replacing some C++ functions by R functions in cases in which there
was no decrease in performance.

* `plot_diffnet` function now has smaller margins, so looks more appealing.



# Changes in netdiffuseR version 1.18.1 (2017-07-22)

## New functions
Expand Down
90 changes: 37 additions & 53 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
@@ -1,76 +1,60 @@
# Generated by using Rcpp::compileAttributes() -> do not edit by hand
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393

toa_mat_cpp <- function(year, t0, t1) {
.Call('_netdiffuseR_toa_mat_cpp', PACKAGE = 'netdiffuseR', year, t0, t1)
}

edgelist_to_adjmat_cpp <- function(edgelist, weights = as.numeric( c()), n = 0L, undirected = FALSE, self = FALSE, multiple = FALSE) {
.Call('_netdiffuseR_edgelist_to_adjmat_cpp', PACKAGE = 'netdiffuseR', edgelist, weights, n, undirected, self, multiple)
.Call(`_netdiffuseR_edgelist_to_adjmat_cpp`, edgelist, weights, n, undirected, self, multiple)
}

adjmat_to_edgelist_cpp <- function(adjmat, undirected = TRUE) {
.Call('_netdiffuseR_adjmat_to_edgelist_cpp', PACKAGE = 'netdiffuseR', adjmat, undirected)
.Call(`_netdiffuseR_adjmat_to_edgelist_cpp`, adjmat, undirected)
}

toa_diff_cpp <- function(year) {
.Call('_netdiffuseR_toa_diff_cpp', PACKAGE = 'netdiffuseR', year)
}

isolated_cpp <- function(adjmat, undirected = TRUE) {
.Call('_netdiffuseR_isolated_cpp', PACKAGE = 'netdiffuseR', adjmat, undirected)
}

drop_isolated_cpp <- function(adjmat, isolated, undirected = TRUE) {
.Call('_netdiffuseR_drop_isolated_cpp', PACKAGE = 'netdiffuseR', adjmat, isolated, undirected)
.Call(`_netdiffuseR_toa_diff_cpp`, year)
}

egonet_attrs_cpp <- function(graph, V, outer = TRUE, self = TRUE, valued = TRUE) {
.Call('_netdiffuseR_egonet_attrs_cpp', PACKAGE = 'netdiffuseR', graph, V, outer, self, valued)
.Call(`_netdiffuseR_egonet_attrs_cpp`, graph, V, outer, self, valued)
}

approx_geodesicCpp <- function(G, n = 6L, warn = FALSE) {
.Call('_netdiffuseR_approx_geodesicCpp', PACKAGE = 'netdiffuseR', G, n, warn)
.Call(`_netdiffuseR_approx_geodesicCpp`, G, n, warn)
}

infection_cpp <- function(graph, times, normalize = TRUE, K = 1L, r = 0.5, expdiscount = FALSE, n = 0L, valued = FALSE, outgoing = TRUE) {
.Call('_netdiffuseR_infection_cpp', PACKAGE = 'netdiffuseR', graph, times, normalize, K, r, expdiscount, n, valued, outgoing)
.Call(`_netdiffuseR_infection_cpp`, graph, times, normalize, K, r, expdiscount, n, valued, outgoing)
}

susceptibility_cpp <- function(graph, times, normalize = TRUE, K = 1L, r = 0.5, expdiscount = FALSE, n = 0L, valued = FALSE, outgoing = TRUE) {
.Call('_netdiffuseR_susceptibility_cpp', PACKAGE = 'netdiffuseR', graph, times, normalize, K, r, expdiscount, n, valued, outgoing)
.Call(`_netdiffuseR_susceptibility_cpp`, graph, times, normalize, K, r, expdiscount, n, valued, outgoing)
}

select_egoalter_cpp <- function(adjmat_t0, adjmat_t1, adopt_t0, adopt_t1) {
.Call('_netdiffuseR_select_egoalter_cpp', PACKAGE = 'netdiffuseR', adjmat_t0, adjmat_t1, adopt_t0, adopt_t1)
}

sparse_indexes <- function(mat) {
.Call('_netdiffuseR_sparse_indexes', PACKAGE = 'netdiffuseR', mat)
.Call(`_netdiffuseR_select_egoalter_cpp`, adjmat_t0, adjmat_t1, adopt_t0, adopt_t1)
}

angle <- function(x0, y0, x1, y1) {
.Call('_netdiffuseR_angle', PACKAGE = 'netdiffuseR', x0, y0, x1, y1)
.Call(`_netdiffuseR_angle`, x0, y0, x1, y1)
}

sp_trimatl <- function(x) {
.Call('_netdiffuseR_sp_trimatl', PACKAGE = 'netdiffuseR', x)
.Call(`_netdiffuseR_sp_trimatl`, x)
}

sp_diag <- function(x, v) {
.Call('_netdiffuseR_sp_diag', PACKAGE = 'netdiffuseR', x, v)
.Call(`_netdiffuseR_sp_diag`, x, v)
}

unif_rand_w_exclusion <- function(n, e) {
.Call('_netdiffuseR_unif_rand_w_exclusion', PACKAGE = 'netdiffuseR', n, e)
.Call(`_netdiffuseR_unif_rand_w_exclusion`, n, e)
}

sp_as_undirected <- function(x) {
.Call('_netdiffuseR_sp_as_undirected', PACKAGE = 'netdiffuseR', x)
.Call(`_netdiffuseR_sp_as_undirected`, x)
}

bootnet_fillself <- function(graph, index, E) {
.Call('_netdiffuseR_bootnet_fillself', PACKAGE = 'netdiffuseR', graph, index, E)
.Call(`_netdiffuseR_bootnet_fillself`, graph, index, E)
}

#' Distribution over a grid
Expand Down Expand Up @@ -103,7 +87,7 @@ bootnet_fillself <- function(graph, index, E) {
#' grid_distribution(x,y,20)
#' }
grid_distribution <- function(x, y, nlevels = 100L) {
.Call('_netdiffuseR_grid_distribution', PACKAGE = 'netdiffuseR', x, y, nlevels)
.Call(`_netdiffuseR_grid_distribution`, x, y, nlevels)
}

#' Compute ego/alter edge coordinates considering alter's size and aspect ratio
Expand Down Expand Up @@ -201,19 +185,19 @@ grid_distribution <- function(x, y, nlevels = 100L) {
#' with(ecoords, arrows(x0,y0,x1,y1, length=.1))
#' @export
edges_coords <- function(graph, toa, x, y, vertex_cex, undirected = TRUE, no_contemporary = TRUE, dev = as.numeric( c()), ran = as.numeric( c())) {
.Call('_netdiffuseR_edges_coords', PACKAGE = 'netdiffuseR', graph, toa, x, y, vertex_cex, undirected, no_contemporary, dev, ran)
.Call(`_netdiffuseR_edges_coords`, graph, toa, x, y, vertex_cex, undirected, no_contemporary, dev, ran)
}

edges_arrow <- function(x0, y0, x1, y1, height, width, beta = 1.5707963267949, dev = as.numeric( c()), ran = as.numeric( c())) {
.Call('_netdiffuseR_edges_arrow', PACKAGE = 'netdiffuseR', x0, y0, x1, y1, height, width, beta, dev, ran)
.Call(`_netdiffuseR_edges_arrow`, x0, y0, x1, y1, height, width, beta, dev, ran)
}

vertices_coords <- function(x, y, size, nsides, rot, dev = as.numeric( c()), ran = as.numeric( c())) {
.Call('_netdiffuseR_vertices_coords', PACKAGE = 'netdiffuseR', x, y, size, nsides, rot, dev, ran)
.Call(`_netdiffuseR_vertices_coords`, x, y, size, nsides, rot, dev, ran)
}

rgraph_er_cpp <- function(n = 10L, p = 0.3, undirected = TRUE, weighted = FALSE, self = FALSE) {
.Call('_netdiffuseR_rgraph_er_cpp', PACKAGE = 'netdiffuseR', n, p, undirected, weighted, self)
.Call(`_netdiffuseR_rgraph_er_cpp`, n, p, undirected, weighted, self)
}

#' Ring lattice graph
Expand All @@ -232,49 +216,49 @@ rgraph_er_cpp <- function(n = 10L, p = 0.3, undirected = TRUE, weighted = FALSE,
#' @export
#' @family simulation functions
ring_lattice <- function(n, k, undirected = FALSE) {
.Call('_netdiffuseR_ring_lattice', PACKAGE = 'netdiffuseR', n, k, undirected)
.Call(`_netdiffuseR_ring_lattice`, n, k, undirected)
}

rewire_endpoints <- function(graph, p, both_ends = FALSE, self = FALSE, multiple = FALSE, undirected = FALSE) {
.Call('_netdiffuseR_rewire_endpoints', PACKAGE = 'netdiffuseR', graph, p, both_ends, self, multiple, undirected)
.Call(`_netdiffuseR_rewire_endpoints`, graph, p, both_ends, self, multiple, undirected)
}

rewire_swap <- function(graph, nsteps = 100L, self = FALSE, multiple = FALSE, undirected = FALSE, pr_rewire = 0.5) {
.Call('_netdiffuseR_rewire_swap', PACKAGE = 'netdiffuseR', graph, nsteps, self, multiple, undirected, pr_rewire)
.Call(`_netdiffuseR_rewire_swap`, graph, nsteps, self, multiple, undirected, pr_rewire)
}

rewire_ws <- function(G, K, p = 0.0, self = FALSE, multiple = FALSE) {
.Call('_netdiffuseR_rewire_ws', PACKAGE = 'netdiffuseR', G, K, p, self, multiple)
.Call(`_netdiffuseR_rewire_ws`, G, K, p, self, multiple)
}

permute_graph_cpp <- function(x, self = FALSE, multiple = FALSE) {
.Call('_netdiffuseR_permute_graph_cpp', PACKAGE = 'netdiffuseR', x, self, multiple)
.Call(`_netdiffuseR_permute_graph_cpp`, x, self, multiple)
}

rgraph_ba_cpp <- function(graph, dgr, m = 1L, t = 10L, self = TRUE) {
.Call('_netdiffuseR_rgraph_ba_cpp', PACKAGE = 'netdiffuseR', graph, dgr, m, t, self)
.Call(`_netdiffuseR_rgraph_ba_cpp`, graph, dgr, m, t, self)
}

rgraph_ba_new_cpp <- function(m0 = 1L, m = 1L, t = 10L, self = TRUE) {
.Call('_netdiffuseR_rgraph_ba_new_cpp', PACKAGE = 'netdiffuseR', m0, m, t, self)
.Call(`_netdiffuseR_rgraph_ba_new_cpp`, m0, m, t, self)
}

rgraph_sf_homo <- function(eta, graph, dgr, m = 1L, t = 10L, self = TRUE) {
.Call('_netdiffuseR_rgraph_sf_homo', PACKAGE = 'netdiffuseR', eta, graph, dgr, m, t, self)
.Call(`_netdiffuseR_rgraph_sf_homo`, eta, graph, dgr, m, t, self)
}

rgraph_sf_homo_new <- function(eta, m0 = 1L, m = 1L, t = 10L, self = TRUE) {
.Call('_netdiffuseR_rgraph_sf_homo_new', PACKAGE = 'netdiffuseR', eta, m0, m, t, self)
.Call(`_netdiffuseR_rgraph_sf_homo_new`, eta, m0, m, t, self)
}

#' @export
#' @rdname vertex_covariate_dist
vertex_covariate_dist <- function(graph, X, p = 2.0) {
.Call('_netdiffuseR_vertex_covariate_dist', PACKAGE = 'netdiffuseR', graph, X, p)
.Call(`_netdiffuseR_vertex_covariate_dist`, graph, X, p)
}

vertex_mahalanobis_dist_cpp <- function(graph, X, S) {
.Call('_netdiffuseR_vertex_mahalanobis_dist_cpp', PACKAGE = 'netdiffuseR', graph, X, S)
.Call(`_netdiffuseR_vertex_mahalanobis_dist_cpp`, graph, X, S)
}

#' Comparisons at dyadic level
Expand Down Expand Up @@ -309,27 +293,27 @@ vertex_mahalanobis_dist_cpp <- function(graph, X, S) {
#' vertex_covariate_compare(G, x, "<=")
#' @export
vertex_covariate_compare <- function(graph, X, funname) {
.Call('_netdiffuseR_vertex_covariate_compare', PACKAGE = 'netdiffuseR', graph, X, funname)
.Call(`_netdiffuseR_vertex_covariate_compare`, graph, X, funname)
}

moran_cpp <- function(x, w) {
.Call('_netdiffuseR_moran_cpp', PACKAGE = 'netdiffuseR', x, w)
.Call(`_netdiffuseR_moran_cpp`, x, w)
}

struct_equiv_cpp <- function(graph, v = 1.0, unscaled = FALSE, inv = FALSE, invrep = 0.0) {
.Call('_netdiffuseR_struct_equiv_cpp', PACKAGE = 'netdiffuseR', graph, v, unscaled, inv, invrep)
.Call(`_netdiffuseR_struct_equiv_cpp`, graph, v, unscaled, inv, invrep)
}

matrix_compareCpp <- function(A, B, fun) {
.Call('_netdiffuseR_matrix_compareCpp', PACKAGE = 'netdiffuseR', A, B, fun)
.Call(`_netdiffuseR_matrix_compareCpp`, A, B, fun)
}

struct_test_mean <- function(y, funname, self = FALSE) {
.Call('_netdiffuseR_struct_test_mean', PACKAGE = 'netdiffuseR', y, funname, self)
.Call(`_netdiffuseR_struct_test_mean`, y, funname, self)
}

struct_test_var <- function(y, funname, self = FALSE) {
.Call('_netdiffuseR_struct_test_var', PACKAGE = 'netdiffuseR', y, funname, self)
.Call(`_netdiffuseR_struct_test_var`, y, funname, self)
}

#' Computes variance of \eqn{Y} at ego level
Expand Down Expand Up @@ -363,6 +347,6 @@ struct_test_var <- function(y, funname, self = FALSE) {
#' @seealso \code{\link{struct_test}}
#' @family statistics
ego_variance <- function(graph, Y, funname, all = FALSE) {
.Call('_netdiffuseR_ego_variance', PACKAGE = 'netdiffuseR', graph, Y, funname, all)
.Call(`_netdiffuseR_ego_variance`, graph, Y, funname, all)
}

Loading

0 comments on commit 7468d50

Please sign in to comment.