/* -*- mode: C -*- */ /* IGraph R package. Copyright (C) 2007 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 "random.h" #include /* This file contains the method for creating citation networks */ int igraph_i_create_outseq(igraph_vector_t *real_outseq, igraph_integer_t nodes, const igraph_vector_t *outseq, const igraph_vector_t *outdist, igraph_integer_t m, igraph_integer_t *edges) { long int no_of_edges=0; if (outseq && nodes != igraph_vector_size(outseq)) { IGRAPH_ERROR("Invalid out-degree sequence length", IGRAPH_EINVAL); } if (!outseq && outdist && igraph_vector_size(outdist)==0) { IGRAPH_ERROR("Invalid out-degree distribution length", IGRAPH_EINVAL); } if (!outseq && !outdist && m<0) { IGRAPH_ERROR("Invalid constant out-degree", IGRAPH_EINVAL); } if (outseq) { igraph_vector_clear(real_outseq); igraph_vector_append(real_outseq, outseq); no_of_edges=igraph_vector_sum(real_outseq)-VECTOR(*real_outseq)[0]; } else if (outdist) { igraph_vector_t cumsum; long int i, n=igraph_vector_size(outdist); IGRAPH_VECTOR_INIT_FINALLY(&cumsum, n+1); IGRAPH_CHECK(igraph_vector_resize(real_outseq, nodes)); VECTOR(cumsum)[0]=0; for (i=0; i