1
#include <Rcpp.h>
2
using namespace Rcpp;
3

4
// [[Rcpp::export]]
5 1
IntegerMatrix nialgo(List adjList, IntegerVector deg) {
6 1
  int n=deg.size();
7 1
  IntegerVector marked(n);
8 1
  IntegerVector t(n);
9 1
  IntegerMatrix dom(n,n);
10 1
  for(int v = 0; v < n; ++v) {
11 1
    Rcpp::checkUserInterrupt();
12
    // IntegerVector Nv = as<IntegerVector>(adjList[v]);
13

14 1
    std::vector<int> Nv = as<std::vector<int> >(adjList[v]);
15
    //check if isolate
16 1
    if (Nv.empty()) {
17 0
      for(int j = 0; j < n; ++j){
18 0
        dom(v,j)=1;
19
      }
20 0
      dom(v,v)=0;
21
    }
22
    
23 1
    for(std::vector<int>::size_type j = 0; j!=Nv.size(); ++j){
24
    // for(int j = 0; j < NvSize; ++j) {
25 1
      int u = Nv[j];
26 1
      std::vector<int> Nu=adjList[u];
27 1
      Nu.push_back(u);
28 1
      for(std::vector<int>::size_type i = 0; i!=Nu.size(); ++i){
29
      // for(int i = 0; i<Nu.size(); ++i){
30 1
        int w=Nu[i];
31 1
        if(w!=v){
32 1
          if(marked[w]!=v){
33 1
            marked[w]=v;
34 1
            t[w]=0;
35
          }
36 1
          t[w]+=1;
37 1
          if(t[w]==deg[v]){
38 1
            dom(v,w)=1;
39
          }
40
        }
41
      }
42
    }
43
  }
44 1
  return dom;
45
}

Read our documentation on viewing source code .

Loading