-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Working on travis adding source code of rgraph_ba
- Loading branch information
Showing
6 changed files
with
77 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,3 15,4 @@ | |
# Misc | ||
README[.]Rmd | ||
README[.]md | ||
[.]travis[.]yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) | ||
*/ |