/* -*- mode: C -*- */ /* IGraph R package. Copyright (C) 2005 Gabor Csardi MTA RMKI, Konkoly-Thege Miklos st. 29-33, Budapest 1121, Hungary This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "igraph.h" #include "memory.h" #include int igraph_measure_dynamics_id(const igraph_t *graph, igraph_matrix_t *ak, igraph_matrix_t *sd, igraph_matrix_t *no, igraph_vector_t *cites, igraph_vector_t *debug, igraph_integer_t debugdeg, const igraph_vector_t *st, igraph_integer_t pmaxind) { long int maxind=pmaxind; long int no_of_nodes=igraph_vcount(graph); int *indegree; igraph_matrix_t normfact; igraph_vector_t ntk, ch, notnull; igraph_vector_t neis; long int node; long int i; long int edges=0; igraph_bool_t lsd=(sd != 0); igraph_vector_init(&neis, 0); indegree=Calloc(no_of_nodes, int); igraph_matrix_resize(ak, maxind+1, 1); igraph_matrix_null(ak); if (lsd) { igraph_matrix_resize(sd, maxind+1, 1); igraph_matrix_null(sd); } igraph_vector_init(&ntk, maxind+1); igraph_vector_init(&ch, maxind+1); igraph_matrix_init(&normfact, maxind+1, 1); igraph_vector_init(¬null, maxind+1); for (node=0; node 0) { MATRIX(*sd, i, 0) = sqrt(MATRIX(*sd, i, 0)/(MATRIX(normfact, i, 0)-1)); } } } if (no) { igraph_matrix_destroy(no); *no=normfact; } else { igraph_matrix_destroy(&normfact); } if (cites) { igraph_vector_destroy(cites); *cites=notnull; } else { igraph_vector_destroy(¬null); } Free(indegree); igraph_vector_destroy(&ntk); igraph_vector_destroy(&ch); igraph_vector_destroy(&neis); return 0; } int igraph_measure_dynamics_id_expected(const igraph_t *graph, igraph_vector_t *res, const igraph_vector_t *ak, const igraph_vector_t *st, igraph_integer_t pmaxind) { long int maxind=pmaxind; igraph_vector_t ntk; igraph_vector_t indegree; igraph_vector_t neis; long int no_of_nodes=igraph_vcount(graph); long int node, i, j; IGRAPH_VECTOR_INIT_FINALLY(&ntk, maxind+1); IGRAPH_VECTOR_INIT_FINALLY(&indegree, no_of_nodes); IGRAPH_VECTOR_INIT_FINALLY(&neis, 0); IGRAPH_CHECK(igraph_vector_resize(res, maxind+1)); igraph_vector_null(res); for (node=0; node time_window) { while ( (j=igraph_dqueue_pop(&history)) != -1) { long int xidx=VECTOR(indegree)[j]; VECTOR(indegree)[j] --; VECTOR(ntk)[xidx]--; if (VECTOR(ntk)[xidx]==0) { MATRIX(normfact, xidx, 0) += (edges-VECTOR(ch)[xidx]); VECTOR(ch)[xidx]=edges; } VECTOR(ntk)[xidx-1]++; if (VECTOR(ntk)[xidx-1]==1) { VECTOR(ch)[xidx-1]=edges; } } } /* isolate node */ VECTOR(ntk)[0]++; if (VECTOR(ntk)[0]==1) { VECTOR(ch)[0]=edges; } } /* Ok, measurement done, update change */ for (i=0; i 0) { MATRIX(*sd, i, 0) = sqrt(MATRIX(*sd, i, 0)/(MATRIX(normfact, i, 0)-1)); } } } igraph_dqueue_destroy(&history); igraph_vector_destroy(¬null); igraph_matrix_destroy(&normfact); igraph_vector_destroy(&ch); igraph_vector_destroy(&ntk); igraph_vector_destroy(&indegree); igraph_vector_destroy(&neis); IGRAPH_FINALLY_CLEAN(7); return 0; } int igraph_measure_dynamics_idwindow_st(const igraph_t *graph, igraph_vector_t *res, const igraph_matrix_t *ak, igraph_integer_t time_window) { long int no_of_nodes=igraph_vcount(graph); igraph_vector_t indegree; igraph_vector_t neis; igraph_dqueue_t history; long int node; long int i, k; IGRAPH_VECTOR_INIT_FINALLY(&neis, 0); IGRAPH_DQUEUE_INIT_FINALLY(&history, time_window); IGRAPH_VECTOR_INIT_FINALLY(&indegree, no_of_nodes); IGRAPH_CHECK(igraph_vector_resize(res, no_of_nodes)); igraph_vector_null(res); VECTOR(*res)[0]=MATRIX(*ak, 0, 0); for (node=1; node time_window) { while( (k = igraph_dqueue_pop(&history)) != -1) { long int xidx=VECTOR(indegree)[k]; VECTOR(*res)[node] -= MATRIX(*ak, xidx, 0); VECTOR(*res)[node] += MATRIX(*ak, xidx-1, 0); VECTOR(indegree)[k]--; } } /* outgoing edges */ igraph_neighbors(graph, &neis, node, IGRAPH_OUT); for (i=0; i=1; k++) { long int shnode=node-binwidth*k; long int deg=indegree[shnode]; MATRIX(ntkl, deg, k-1)--; if (MATRIX(ntkl, deg, k-1)==0) { MATRIX(normfact, deg, k-1) += (edges-MATRIX(ch, deg, k-1)+1); MATRIX(ch, deg, k-1)=edges; } MATRIX(ntkl, deg, k)++; if (MATRIX(ntkl, deg, k)==1) { MATRIX(ch, deg, k)=edges; } } } /* Ok, measurement done, update change */ for (i=0; i 0) { MATRIX(*sd, i, j) = sqrt(MATRIX(*sd, i, j)/(MATRIX(normfact,i,j)-1)); } } } } if (no) { igraph_matrix_destroy(no); *no=normfact; } else { igraph_matrix_destroy(&normfact); } if (cites) { igraph_matrix_destroy(cites); *cites=notnull; } else { igraph_matrix_destroy(¬null); } Free(indegree); igraph_matrix_destroy(&ntkl); igraph_matrix_destroy(&ch); igraph_vector_destroy(&neis); return 0; } int igraph_measure_dynamics_idage_expected(const igraph_t *graph, igraph_matrix_t *res, const igraph_matrix_t *akl, const igraph_vector_t *st, igraph_integer_t pmaxind) { long int agebins=igraph_matrix_ncol(akl); long int no_of_nodes=igraph_vcount(graph); long int binwidth=no_of_nodes/agebins+1; long int maxind=pmaxind; igraph_vector_t indegree; igraph_vector_t neis; igraph_matrix_t ntkl; long int node, i, j, k; IGRAPH_VECTOR_INIT_FINALLY(&indegree, no_of_nodes); IGRAPH_MATRIX_INIT_FINALLY(&ntkl, maxind+1, agebins+1); IGRAPH_VECTOR_INIT_FINALLY(&neis, 0); IGRAPH_CHECK(igraph_matrix_resize(res, maxind+1, agebins)); igraph_matrix_null(res); for (node=0; node= 1; k++) { long int shnode=node-binwidth*k; long int deg=VECTOR(indegree)[shnode]; MATRIX(ntkl, deg, k-1) -= 1; MATRIX(ntkl, deg, k) += 1; } } igraph_vector_destroy(&neis); igraph_matrix_destroy(&ntkl); igraph_vector_destroy(&indegree); IGRAPH_FINALLY_CLEAN(3); return 0; } int igraph_measure_dynamics_idage_st(const igraph_t *graph, igraph_vector_t *res, const igraph_matrix_t *akl) { long int agebins=igraph_matrix_ncol(akl); long int no_of_nodes=igraph_vcount(graph); long int binwidth; int *indegree; igraph_vector_t neis; long int node; long int i, k; igraph_vector_init(&neis, 0); indegree=Calloc(no_of_nodes, int); binwidth=no_of_nodes/agebins+1; igraph_vector_resize(res, no_of_nodes); igraph_vector_null(res); VECTOR(*res)[0]=MATRIX(*akl, 0, 0); for (node=1; node= 1; k++) { long int shnode=node-binwidth*k; long int deg=indegree[shnode]; VECTOR(*res)[node] += -MATRIX(*akl, deg, k-1)+MATRIX(*akl, deg, k); } /* inspect the outgoing edges */ igraph_neighbors(graph, &neis, node, IGRAPH_OUT); for (i=0; i=1; k++) { long int shnode=node-binwidth*k; long int deg=indegree[shnode]; MATRIX(ntkl, deg, k-1)--; if (MATRIX(ntkl, deg, k-1)==0) { MATRIX(normfact, deg, k-1) += (edges-MATRIX(ch, deg, k-1)+1); MATRIX(ch, deg, k-1)=edges; } MATRIX(ntkl, deg, k)++; if (MATRIX(ntkl, deg, k)==1) { MATRIX(ch, deg, k)=edges; } } /* time window */ if (node > time_window) { while ( (j=igraph_dqueue_pop(&history)) != -1) { long int xidx=indegree[j]; long int yidx=(node-j)/binwidth; indegree[j]--; MATRIX(ntkl, xidx, yidx)--; if (MATRIX(ntkl, xidx, yidx)==0) { MATRIX(normfact, xidx, yidx) += (edges-MATRIX(ch, xidx, yidx)+1); MATRIX(ch, xidx, yidx)=edges; } MATRIX(ntkl, xidx-1, yidx)++; if (MATRIX(ntkl, xidx-1, yidx)==1) { MATRIX(ch, xidx-1, yidx)=edges; } } } } /* Ok, measurement done, update change */ for (i=0; i 0) { MATRIX(*sd, i, j) = sqrt(MATRIX(*sd, i, j)/(MATRIX(normfact,i,j)-1)); } } } } igraph_matrix_destroy(&normfact); igraph_dqueue_destroy(&history); Free(indegree); igraph_matrix_destroy(&ntkl); igraph_matrix_destroy(&ch); igraph_matrix_destroy(¬null); igraph_vector_destroy(&neis); return 0; } int igraph_measure_dynamics_idwindowage_st(const igraph_t *graph, igraph_vector_t *res, const igraph_matrix_t *akl, igraph_integer_t time_window) { long int agebins=igraph_matrix_ncol(akl); long int no_of_nodes=igraph_vcount(graph); long int binwidth; int *indegree; igraph_vector_t neis; long int node; long int i, k; igraph_dqueue_t history; igraph_vector_init(&neis, 0); igraph_dqueue_init(&history, time_window); indegree=Calloc(no_of_nodes, int); binwidth=no_of_nodes/agebins+1; igraph_vector_resize(res, no_of_nodes); igraph_vector_null(res); VECTOR(*res)[0]=MATRIX(*akl, 0, 0); for (node=1; node= 1; k++) { long int shnode=node-binwidth*k; long int deg=indegree[shnode]; VECTOR(*res)[node] += -MATRIX(*akl, deg, k-1)+MATRIX(*akl, deg, k); } if (node > time_window) { while ( (k=igraph_dqueue_pop(&history)) != -1) { long int xidx=indegree[k]; long int yidx=(node-k)/binwidth; VECTOR(*res)[node] -= MATRIX(*akl, xidx, yidx); VECTOR(*res)[node] += MATRIX(*akl, xidx-1, yidx); indegree[k]--; } } /* inspect the outgoing edges */ igraph_neighbors(graph, &neis, node, IGRAPH_OUT); for (i=0; i= 1; k++) { long int shnode=node-binwidth*k; long int cat=VECTOR(*cats)[shnode]; long int deg=indegree[shnode]; ARRAY3(ntkl, cat, deg, k-1)--; if (ARRAY3(ntkl, cat, deg, k-1)==0) { ARRAY3(normfact, cat, deg, k-1)+=(edges-ARRAY3(ch, cat, deg, k-1)+1); ARRAY3(ch, cat, deg, k-1)=edges; } ARRAY3(ntkl, cat, deg, k)++; if (ARRAY3(ntkl, cat, deg, k)==1) { ARRAY3(ch, cat, deg, k)=edges; } } } /* measurement done, update change */ for (k=0; k 0) { ARRAY3(*sd, k, i, j)= sqrt(ARRAY3(*sd, k, i, j)/(ARRAY3(normfact, k, i, j)-1)); } } } } } igraph_array3_destroy(&normfact); Free(indegree); igraph_array3_destroy(&ntkl); igraph_array3_destroy(&ch); igraph_array3_destroy(¬null); igraph_vector_destroy(&neis); return 0; } int igraph_measure_dynamics_citedcat_id_age_st(const igraph_t *graph, igraph_vector_t *res, const igraph_array3_t *adkl, const igraph_vector_t *cats, igraph_integer_t pno_cats) { long int agebins=igraph_array3_n(adkl, 3); long int no_of_nodes=igraph_vcount(graph); long int binwidth; int *indegree; igraph_vector_t neis; long int node; long int i, k; igraph_vector_init(&neis, 0); indegree=Calloc(no_of_nodes, int); binwidth=no_of_nodes/agebins+1; igraph_vector_resize(res, no_of_nodes); igraph_vector_null(res); VECTOR(*res)[0]=ARRAY3(*adkl, (long int)VECTOR(*cats)[0], 0, 0); for (node=1; node= 1; k++) { long int shnode=node-binwidth*k; long int cat=VECTOR(*cats)[shnode]; long int deg=indegree[shnode]; VECTOR(*res)[node] += -ARRAY3(*adkl, cat, deg, k-1)+ARRAY3(*adkl, cat, deg, k); } /* inspect the outgoing edges */ igraph_neighbors(graph, &neis, node, IGRAPH_OUT); for (i=0; i= 1; k++) { long int shnode=node-binwidth*k; long int deg=indegree[shnode]; MATRIX(ntkl, deg, k-1)--; if (MATRIX(ntkl, deg, k-1)==0) { for (j=0; j 0) { ARRAY3(*sd, k, i, j)= sqrt(ARRAY3(*sd, k, i, j)/(ARRAY3(normfact, k, i, j)-1)); } } } } } igraph_array3_destroy(&normfact); Free(indegree); igraph_matrix_destroy(&ntkl); igraph_array3_destroy(&ch); igraph_array3_destroy(¬null); igraph_vector_destroy(&neis); igraph_vector_destroy(&edges); return 0; } int igraph_measure_dynamics_citingcat_id_age_st(const igraph_t *graph, igraph_vector_t *res, const igraph_array3_t *adkl, const igraph_vector_t *cats, igraph_integer_t pno_cats) { long int agebins=igraph_array3_n(adkl, 3); long int no_of_nodes=igraph_vcount(graph); long int no_cats=pno_cats; long int binwidth; int *indegree; igraph_vector_t neis; long int node; long int i, j, k; igraph_matrix_t allst; igraph_matrix_init(&allst, no_cats, no_of_nodes+1); igraph_vector_init(&neis, 0); indegree=Calloc(no_of_nodes, int); binwidth=no_of_nodes/agebins+1; igraph_vector_resize(res, no_of_nodes); igraph_vector_null(res); for (j=0; j= 1; k++) { long int shnode=node-binwidth*k; long int deg=indegree[shnode]; for (j=0; j 0) { /* just introduced zero degree nodes to the net, update ch */ for (i=0; i 0) { MATRIX(normfact, i, j) += 1; MATRIX(normfact, j, i) = MATRIX(normfact, i, j); } } } /* Estimage Akk */ eptr_save=eptr; while (eptr < no_of_edges && VECTOR(*etime)[ (long int) VECTOR(etimeidx)[eptr] ] == timestep) { long int edge=VECTOR(etimeidx)[eptr]; long int xidx, yidx; igraph_integer_t from, to; double xk, oldakk, ntkkval; igraph_edge(graph, edge, &from, &to); xidx=VECTOR(degree)[ (long int)from ]; yidx=VECTOR(degree)[ (long int)to ]; MATRIX(notnull, xidx, yidx) += 1; MATRIX(notnull, yidx, xidx) += 1; /* bug */ ntkkval=NTKK(xidx, yidx); xk=VECTOR(*st)[timestep]/ntkkval; oldakk=MATRIX(*akk, xidx, yidx); MATRIX(*akk, xidx, yidx) = oldakk + (xk-oldakk)/(MATRIX(notnull, xidx, yidx)); MATRIX(*akk, yidx, xidx) = MATRIX(*akk, xidx, yidx); if (sd) { MATRIX(*sd, xidx, yidx) += (xk-oldakk)*(xk-MATRIX(*akk, xidx, yidx)); MATRIX(*sd, yidx, xidx) = MATRIX(*sd, xidx, yidx); } eptr++; } /* Add the edges */ eptr=eptr_save; while (eptr < no_of_edges && VECTOR(*etime)[ (long int) VECTOR(etimeidx)[eptr] ] == timestep) { long int edge=VECTOR(etimeidx)[eptr]; long int xidx, yidx; igraph_integer_t from, to; igraph_edge(graph, edge, &from, &to); xidx=VECTOR(degree)[ (long int)from ]; yidx=VECTOR(degree)[ (long int)to ]; igraph_adjacent(graph, &adjedges, from, IGRAPH_ALL); for (i=0; i 0) { */ /* MATRIX(normfact, i, j) += eptr-MATRIX(ch, i, j); */ /* MATRIX(normfact, j, i) = MATRIX(normfact, i, j); */ /* } */ /* } */ /* } */ /* } */ /* fprintf(stderr, "---------\n"); */ /* print_matrix(&normfact); */ /* Update akk, sd */ for (i=0; i 0) { MATRIX(*sd, i, j)=sqrt(MATRIX(*sd, i, j)/(MATRIX(normfact, i, j)-1)); MATRIX(*sd, j, i) = MATRIX(*sd, i, j); } } } } igraph_vector_destroy(&etimeidx); igraph_vector_destroy(&ntimeidx); igraph_vector_destroy(&added); igraph_matrix_destroy(¬null); igraph_matrix_destroy(&ch); igraph_matrix_destroy(&normfact); igraph_matrix_destroy(&ntkk); igraph_vector_destroy(&ntk); igraph_vector_destroy(°ree); igraph_vector_destroy(&adjedges); IGRAPH_FINALLY_CLEAN(10); return 0; } int igraph_measure_dynamics_d_d_st(const igraph_t *graph, /* input */ const igraph_vector_t *ntime, /* input */ const igraph_vector_t *etime, /* input */ const igraph_matrix_t *akk, /* input */ igraph_integer_t events, igraph_integer_t maxtotaldeg, igraph_vector_t *st) { /* output */ long int no_of_nodes=igraph_vcount(graph); long int no_of_edges=igraph_ecount(graph); long int timestep=0; long int nptr=0; long int eptr=0; long int maxdeg=0; igraph_vector_t degree; igraph_vector_t ntk; /* number of nodes of different types */ igraph_vector_t added; igraph_vector_t adjedges; igraph_vector_t ntimeidx; /* lookup vector for nodes */ igraph_vector_t etimeidx; /* lookup vector for edges */ long int i; /* Init everything */ IGRAPH_VECTOR_INIT_FINALLY(&ntk, maxtotaldeg+1); IGRAPH_VECTOR_INIT_FINALLY(°ree, no_of_nodes); IGRAPH_VECTOR_INIT_FINALLY(&added, no_of_edges); IGRAPH_VECTOR_INIT_FINALLY(&adjedges, 0); IGRAPH_VECTOR_INIT_FINALLY(&ntimeidx, 0); IGRAPH_VECTOR_INIT_FINALLY(&etimeidx, 0); /* Resize result */ IGRAPH_CHECK(igraph_vector_resize(st, events+1)); VECTOR(*st)[0]=0; /* Create lookup vectors */ IGRAPH_CHECK(igraph_vector_order1(ntime, &ntimeidx, events)); IGRAPH_CHECK(igraph_vector_order1(etime, &etimeidx, events)); for (timestep=0; timestep maxdeg) { maxdeg=xidx+1; } if (yidx+1 > maxdeg) { maxdeg=yidx+1; } /* Now update the edges */ igraph_adjacent(graph, &adjedges, from, IGRAPH_ALL); for (i=0; i= 1; k++) { long int shnode=node-binwidth*k; igraph_neighbors(graph, &neis, shnode, IGRAPH_OUT); for (i=0; i 0) { VECTOR(*sd)[i] = sqrt(VECTOR(*sd)[i]/(VECTOR(normfact)[i]-1)); } } } if (no) { igraph_vector_destroy(no); *no=normfact; } else { igraph_vector_destroy(&normfact); } igraph_free(lastcit); igraph_vector_destroy(&ntl); igraph_vector_destroy(&ch); igraph_vector_destroy(¬null); igraph_vector_destroy(&neis); IGRAPH_FINALLY_CLEAN(6); return 0; } int igraph_measure_dynamics_lastcit_st(const igraph_t *graph, igraph_vector_t *res, const igraph_vector_t *al) { long int no_of_nodes=igraph_vcount(graph); long int agebins=igraph_vector_size(al)-1; long int binwidth=no_of_nodes/agebins+1; long int *lastcit; igraph_vector_t neis; long int node, i, k; IGRAPH_VECTOR_INIT_FINALLY(&neis, 0); lastcit=Calloc(no_of_nodes, long int); if (!lastcit) { IGRAPH_ERROR("Cannot measure dynamics (lastcit st)", IGRAPH_ENOMEM); } IGRAPH_FINALLY(igraph_free, lastcit); igraph_vector_resize(res, no_of_nodes); igraph_vector_null(res); VECTOR(*res)[0]=VECTOR(*al)[agebins]; /* node without citation */ for (node=1; node= 1; k++) { long int shnode=node-binwidth*k; igraph_neighbors(graph, &neis, shnode, IGRAPH_OUT); for (i=0; i=1; k++) { VECTOR(ntl)[k-1]--; if (VECTOR(ntl)[k-1]==0) { VECTOR(normfact)[k-1] += (edges-VECTOR(ch)[k-1]+1); VECTOR(ch)[k-1] = edges; } VECTOR(ntl)[k]++; if (VECTOR(ntl)[k]==1) { VECTOR(ch)[k]=edges; } } } /* node 0) { VECTOR(*sd)[i] = sqrt(VECTOR(*sd)[i]/(VECTOR(normfact)[i]-1)); } } } if (no) { igraph_vector_destroy(no); *no=normfact; } else { igraph_vector_destroy(&normfact); } igraph_vector_destroy(&ntl); igraph_vector_destroy(&ch); igraph_vector_destroy(¬null); igraph_vector_destroy(&neis); IGRAPH_FINALLY_CLEAN(5); return 0; } int igraph_measure_dynamics_age_st(const igraph_t *graph, igraph_vector_t *res, const igraph_vector_t *al) { long int agebins=igraph_vector_size(al); long int no_of_nodes=igraph_vcount(graph); long int binwidth=no_of_nodes/agebins+1; long int node, k; IGRAPH_CHECK(igraph_vector_resize(res, no_of_nodes)); igraph_vector_null(res); VECTOR(*res)[0]=VECTOR(*al)[0]; for (node=1; node= 1; k++) { VECTOR(*res)[node] += -VECTOR(*al)[k-1] + VECTOR(*al)[k]; } /* inspecting outgoing edges is not needed at all */ } return 0; } int igraph_measure_dynamics_citedcat(const igraph_t *graph, const igraph_vector_t *cats, igraph_integer_t pnocats, igraph_vector_t *ak, igraph_vector_t *sd, igraph_vector_t *no, const igraph_vector_t *st) { long int nocats=pnocats; long int no_of_nodes=igraph_vcount(graph); igraph_vector_t normfact, ntk, ch, notnull; igraph_vector_t neis; long int node, i; long int edges=0; IGRAPH_VECTOR_INIT_FINALLY(&normfact, nocats); IGRAPH_VECTOR_INIT_FINALLY(&ntk, nocats); IGRAPH_VECTOR_INIT_FINALLY(&ch, nocats); IGRAPH_VECTOR_INIT_FINALLY(¬null, nocats); IGRAPH_VECTOR_INIT_FINALLY(&neis, 0); IGRAPH_CHECK(igraph_vector_resize(ak, nocats)); igraph_vector_null(ak); if (sd) { IGRAPH_CHECK(igraph_vector_resize(sd, nocats)); igraph_vector_null(sd); } for (node=0; node0) { VECTOR(*sd)[i] = sqrt(VECTOR(*sd)[i] / (VECTOR(normfact)[i]-1)); } } } if (no) { igraph_vector_destroy(no); *no=normfact; } else { igraph_vector_destroy(&normfact); } igraph_vector_destroy(&neis); igraph_vector_destroy(&ntk); igraph_vector_destroy(&ch); igraph_vector_destroy(¬null); IGRAPH_FINALLY_CLEAN(5); return 0; } int igraph_measure_dynamics_citedcat_st(const igraph_t *graph, igraph_vector_t *res, const igraph_vector_t *ak, const igraph_vector_t *cats, igraph_integer_t pnocats) { long int no_of_nodes=igraph_vcount(graph); long int node; IGRAPH_CHECK(igraph_vector_resize(res, no_of_nodes)); VECTOR(*res)[0]=VECTOR(*ak)[ (long int) VECTOR(*cats)[0] ]; for (node=1; node0) { MATRIX(*sd, i, j)= sqrt(MATRIX(*sd, i, j)/(MATRIX(normfact, i, j)-1)); } } } } igraph_vector_destroy(&edges); igraph_vector_destroy(&neis); if (no) { igraph_matrix_destroy(no); *no=normfact; } else { igraph_matrix_destroy(&normfact); } igraph_matrix_destroy(¬null); igraph_matrix_destroy(&ch); igraph_vector_destroy(&ntd); IGRAPH_FINALLY_CLEAN(6); return 0; } int igraph_measure_dynamics_citingcat_citedcat_st(const igraph_t *graph, igraph_vector_t *res, const igraph_matrix_t *agd, const igraph_vector_t *cats, igraph_integer_t pnocats) { long int no_of_nodes=igraph_vcount(graph); long int nocats=pnocats; igraph_matrix_t allst; long int j, node; IGRAPH_MATRIX_INIT_FINALLY(&allst, nocats, no_of_nodes); IGRAPH_CHECK(igraph_vector_resize(res, no_of_nodes)); for (j=0; j