Skip to content

Commit

Permalink
Working on travis adding source code of rgraph_ba
Browse files Browse the repository at this point in the history
  • Loading branch information
gvegayon committed Dec 2, 2015
1 parent 9979008 commit 82fc2ce
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 2 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 15,4 @@
# Misc
README[.]Rmd
README[.]md
[.]travis[.]yml
2 changes: 1 addition & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 7,7 @@ output:
variant: markdown_github
---

[![Coverage Status](https://coveralls.io/repos/USCCANA/diffusiontest/badge.svg?branch=master&service=github)](https://coveralls.io/github/USCCANA/diffusiontest?branch=master)
[![Build Status](https://travis-ci.org/USCCANA/diffusiontest.svg?branch=master)](https://travis-ci.org/USCCANA/diffusiontest)

# diffusiontest: Network Analysis for Diffusion of Innovations

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 1,4 @@
[![Coverage Status](https://coveralls.io/repos/USCCANA/diffusiontest/badge.svg?branch=master&service=github)](https://coveralls.io/github/USCCANA/diffusiontest?branch=master)
[![Build Status](https://travis-ci.org/USCCANA/diffusiontest.svg?branch=master)](https://travis-ci.org/USCCANA/diffusiontest)

diffusiontest: Network Analysis for Diffusion of Innovations
============================================================
Expand Down
24 changes: 24 additions & 0 deletions man/rgraph_ba.Rd

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

12 changes: 12 additions & 0 deletions src/rgraph_ba.h
Original file line number Diff line number Diff line change
@@ -0,0 1,12 @@
// [[Rcpp::depends(RcppArmadillo)]]
#include <RcppArmadillo.h>
#ifndef NETDIFFUSER_RAND_GRAPH_
#define NETDIFFUSER_RAND_GRAPH_
using namespace Rcpp;

arma::sp_mat rgraph_ba_cpp(
arma::sp_mat graph,
arma::colvec dgr, int m = 1, int t = 10);

arma::sp_mat rgraph_ba_new_cpp(int m0 = 1, int m = 1, int t = 10);
#endif
38 changes: 38 additions & 0 deletions src/rgraph_dyn.cpp
Original file line number Diff line number Diff line change
@@ -0,0 1,38 @@
// [[Rcpp::depends(RcppArmadillo)]]
#include <RcppArmadillo.h>
#include "rgraph_ba.h"
// #include "stats.h"

using namespace Rcpp;

// // [[Rcpp::export]]
// arma::sp_mat rgraph_dyn_next_cpp(arma::sp_mat & graph, arma::colvec & dgr, double a=.3, double p=.3, double r=.3) {
//
// }

// [[Rcpp::export]]
double persistant(const List & graph, int i, int j, int n) {
int T = graph.size();

double p = 0.0;
for(int t=(T-1);t>0;t--) {

arma::sp_mat graph_t1 = graph[t];
arma::sp_mat graph_t0 = graph[t-1];
bool prod = ((graph_t0.at(i,j) - graph_t1.at(i,j))==0) && graph_t0.at(i,j);
if (prod) p = 1.0;
}

return p;
}

/***R
library(netdiffuseR)
set.seed(123)
graph <- rgraph_ba()
graph <- list(graph, graph)
graph[[2]][1,] <- 1
graph[[3]] <- rgraph_ba()
graph
sapply(0:10, function(x) persistant(graph, 0,x ,11))
*/

0 comments on commit 82fc2ce

Please sign in to comment.