コード例 #1
0
ファイル: netstats.c プロジェクト: Zsedo/ergm
void network_stats_wrapper(int *tails, int *heads, int *timings, int *time, int *lasttoggle, int *dnedges, 
			   int *dn, int *dflag,  int *bipartite,
			   int *nterms, char **funnames,
			   char **sonames, double *inputs,  double *stats)
{
  int directed_flag;
  Vertex n_nodes;
  Edge n_edges;
  Network nw[2];
  Model *m;
  Vertex bip;

/*	     Rprintf("prestart with setup\n"); */
  n_nodes = (Vertex)*dn; 
  n_edges = (Edge)*dnedges;     
  directed_flag = *dflag;
  bip = (Vertex)*bipartite;
  

  if(*lasttoggle == 0) lasttoggle = NULL;

  m=ModelInitialize(*funnames, *sonames, &inputs, *nterms);
  nw[0]=NetworkInitialize(NULL, NULL, 0,
                          n_nodes, directed_flag, bip, *timings?1:0, *timings?*time:0, *timings?lasttoggle:NULL);

  /* Compute the change statistics and copy them to stats for return
     to R.  Note that stats already has the statistics of an empty
     network, so d_??? statistics will add on to them, while s_???
     statistics will simply overwrite them. */
  SummStats(n_edges, tails, heads, nw, m, stats);
  
  ModelDestroy(m);
  NetworkDestroy(nw);
}
コード例 #2
0
ファイル: netstats.c プロジェクト: yngcan/cotergm
void network_stats_wrapper(int *tails, int *heads, int *timings, int *time, int *lasttoggle, int *dnedges, 
			   int *dn,
				int *y0tails, int *y0heads,int *y0dn,int *y0dnedges,double *y0nodalstatus,

				int *dflag,  int *bipartite,
			   int *nterms, char **funnames,
			   char **sonames, double *inputs,   double *nodalstatus, double *stats)
{
  int directed_flag;
  Vertex n_nodes;
  Edge n_edges, y0n_edges;
  Network nw[2];
  Network y0[1];
  Model *m;
  Vertex bip;

  double * negstatus;


/*	     Rprintf("prestart with setup\n"); */
  n_nodes = (Vertex)*dn; 
  Vertex y0n_nodes =  (Vertex)*y0dn;
  n_edges = (Edge)*dnedges;
  y0n_edges = (Edge)*y0dnedges;
  directed_flag = *dflag;
  bip = (Vertex)*bipartite;
  
  negstatus = (double *)malloc( n_nodes * sizeof(double));

  /*set to negative */
  for (int i=0; i<n_nodes; i++)
	  negstatus[i] = 1.0 ;

  if(*lasttoggle == 0) lasttoggle = NULL;

  m=ModelInitialize(*funnames, *sonames, &inputs, *nterms, n_nodes, nodalstatus);

  nw[0]=NetworkInitialize(NULL, NULL, 0,
                          n_nodes, directed_flag, bip, *timings?1:0, *timings?*time:0, *timings?lasttoggle:NULL, negstatus);

  y0[0]=NetworkInitialize(y0tails, y0heads, y0n_edges,
				y0n_nodes, directed_flag, bip, 0, 0, NULL, y0nodalstatus);
  /* Compute the change statistics and copy them to stats for return
     to R.  Note that stats already has the statistics of an empty
     network, so d_??? statistics will add on to them, while s_???
     statistics will simply overwrite them. */
  SummStats(n_edges, n_nodes, tails, heads, nw, m, stats, y0);
  
  ModelDestroy(m);
  NetworkDestroy(nw);
}