Skip to content

Commit

Permalink
Eliminate some gcc warnings about shadowes variables.
Browse files Browse the repository at this point in the history
  • Loading branch information
gaborcsardi committed Jun 21, 2012
1 parent 7c2098a commit ca3e5e1
Show file tree
Hide file tree
Showing 9 changed files with 186 additions and 181 deletions.
1 change: 1 addition & 0 deletions src/basic_query.c
Expand Up @@ -24,6 +24,7 @@
#include "igraph_datatype.h"
#include "igraph_types.h"
#include "igraph_interface.h"
#include "igraph_structural.h"
#include "config.h"

/**
Expand Down
1 change: 1 addition & 0 deletions src/bfgs.c
Expand Up @@ -23,6 +23,7 @@

#include "igraph_nongraph.h"
#include "igraph_interrupt_internal.h"
#include "igraph_statusbar.h"
#include "memory.h"
#include "config.h"

Expand Down
12 changes: 8 additions & 4 deletions src/cocitation.c
Expand Up @@ -248,15 +248,19 @@ int igraph_cocitation_real(const igraph_t *graph, igraph_matrix_t *res,
return 0;
}

int igraph_i_neisets_intersect(const igraph_vector_t *v1,
const igraph_vector_t *v2, long int *len_union,
long int *len_intersection);

int igraph_i_neisets_intersect(const igraph_vector_t *v1,
const igraph_vector_t *v2, long int *len_union,
long int *len_intersection) {
/* ASSERT: v1 and v2 are sorted */
long int i, j, i0, j0;
i0 = igraph_vector_size(v1); j0 = igraph_vector_size(v2);
*len_union = i0+j0; *len_intersection = 0;
long int i, j, i0, jj0;
i0 = igraph_vector_size(v1); jj0 = igraph_vector_size(v2);
*len_union = i0+jj0; *len_intersection = 0;
i = 0; j = 0;
while (i < i0 && j < j0) {
while (i < i0 && j < jj0) {
if (VECTOR(*v1)[i] == VECTOR(*v2)[j]) {
(*len_intersection)++; (*len_union)--;
i++; j++;
Expand Down
22 changes: 11 additions & 11 deletions src/components.c
Expand Up @@ -775,25 +775,25 @@ int igraph_biconnected_components(const igraph_t *graph,
}
if (component_edges) {
igraph_vector_t *nodes=VECTOR(*mycomponents)[comps-1];
igraph_vector_t *v=igraph_Calloc(1, igraph_vector_t);
long int i, no_vert=igraph_vector_size(nodes);
if (!v) { IGRAPH_ERROR("Out of memory", IGRAPH_ENOMEM); }
IGRAPH_CHECK(igraph_vector_init(v, 0));
IGRAPH_FINALLY(igraph_vector_destroy, v);
for (i=0; i<no_vert; i++) {
long int vert=VECTOR(*nodes)[i];
igraph_vector_t *vv=igraph_Calloc(1, igraph_vector_t);
long int ii, no_vert=igraph_vector_size(nodes);
if (!vv) { IGRAPH_ERROR("Out of memory", IGRAPH_ENOMEM); }
IGRAPH_CHECK(igraph_vector_init(vv, 0));
IGRAPH_FINALLY(igraph_vector_destroy, vv);
for (ii=0; ii<no_vert; ii++) {
long int vert=VECTOR(*nodes)[ii];
igraph_vector_t *edges=igraph_inclist_get(&inclist,
vert);
long int j, n=igraph_vector_size(edges);
for (j=0; j<n; j++) {
long int j, nn=igraph_vector_size(edges);
for (j=0; j<nn; j++) {
long int e=VECTOR(*edges)[j];
long int nei=IGRAPH_OTHER(graph, e, vert);
if (VECTOR(vertex_added)[nei] == comps && nei<vert) {
IGRAPH_CHECK(igraph_vector_push_back(v, e));
IGRAPH_CHECK(igraph_vector_push_back(vv, e));
}
}
}
IGRAPH_CHECK(igraph_vector_ptr_push_back(component_edges, v));
IGRAPH_CHECK(igraph_vector_ptr_push_back(component_edges, vv));
IGRAPH_FINALLY_CLEAN(1);
}
} /* record component if requested */
Expand Down
96 changes: 48 additions & 48 deletions src/games.c
Expand Up @@ -127,16 +127,16 @@ int igraph_i_barabasi_game_bag(igraph_t *graph, igraph_integer_t n,
/* The first node(s) in the bag */
if (start_from) {
igraph_vector_t deg;
long int i, j, sn=igraph_vcount(start_from);
igraph_neimode_t m= outpref ? IGRAPH_ALL : IGRAPH_IN;
long int ii, jj, sn=igraph_vcount(start_from);
igraph_neimode_t mm= outpref ? IGRAPH_ALL : IGRAPH_IN;

IGRAPH_VECTOR_INIT_FINALLY(&deg, sn);
IGRAPH_CHECK(igraph_degree(start_from, &deg, igraph_vss_all(), m,
IGRAPH_CHECK(igraph_degree(start_from, &deg, igraph_vss_all(), mm,
IGRAPH_LOOPS));
for (i=0; i<sn; i++) {
long int d=VECTOR(deg)[i];
for (j=0; j<=d; j++) {
bag[bagp++] = i;
for (ii=0; ii<sn; ii++) {
long int d=VECTOR(deg)[ii];
for (jj=0; jj<=d; jj++) {
bag[bagp++] = ii;
}
}

Expand Down Expand Up @@ -229,13 +229,13 @@ int igraph_i_barabasi_game_psumtree_multiple(igraph_t *graph,

/* first node(s) */
if (start_from) {
long int i, sn=igraph_vcount(start_from);
igraph_neimode_t m=outpref ? IGRAPH_ALL : IGRAPH_IN;
IGRAPH_CHECK(igraph_degree(start_from, &degree, igraph_vss_all(), m,
long int ii, sn=igraph_vcount(start_from);
igraph_neimode_t mm=outpref ? IGRAPH_ALL : IGRAPH_IN;
IGRAPH_CHECK(igraph_degree(start_from, &degree, igraph_vss_all(), mm,
IGRAPH_LOOPS));
IGRAPH_CHECK(igraph_vector_resize(&degree, no_of_nodes));
for (i=0; i<sn; i++) {
igraph_psumtree_update(&sumtree, i, pow(VECTOR(degree)[i], power)+A);
for (ii=0; ii<sn; i++) {
igraph_psumtree_update(&sumtree, ii, pow(VECTOR(degree)[ii], power)+A);
}
} else {
igraph_psumtree_update(&sumtree, 0, A);
Expand Down Expand Up @@ -265,9 +265,9 @@ int igraph_i_barabasi_game_psumtree_multiple(igraph_t *graph,
}
/* update probabilities */
for (j=0; j<no_of_neighbors; j++) {
long int n=VECTOR(edges)[edgeptr-2*j-1];
igraph_psumtree_update(&sumtree, n,
pow(VECTOR(degree)[n], power)+A);
long int nn=VECTOR(edges)[edgeptr-2*j-1];
igraph_psumtree_update(&sumtree, nn,
pow(VECTOR(degree)[nn], power)+A);
}
if (outpref) {
VECTOR(degree)[i] += no_of_neighbors;
Expand Down Expand Up @@ -338,13 +338,13 @@ int igraph_i_barabasi_game_psumtree(igraph_t *graph,

/* first node(s) */
if (start_from) {
long int i, sn=igraph_vcount(start_from);
igraph_neimode_t m=outpref ? IGRAPH_ALL : IGRAPH_IN;
IGRAPH_CHECK(igraph_degree(start_from, &degree, igraph_vss_all(), m,
long int ii, sn=igraph_vcount(start_from);
igraph_neimode_t mm=outpref ? IGRAPH_ALL : IGRAPH_IN;
IGRAPH_CHECK(igraph_degree(start_from, &degree, igraph_vss_all(), mm,
IGRAPH_LOOPS));
IGRAPH_CHECK(igraph_vector_resize(&degree, no_of_nodes));
for (i=0; i<sn; i++) {
igraph_psumtree_update(&sumtree, i, pow(VECTOR(degree)[i], power)+A);
for (ii=0; ii<sn; ii++) {
igraph_psumtree_update(&sumtree, ii, pow(VECTOR(degree)[ii], power)+A);
}
} else {
igraph_psumtree_update(&sumtree, 0, A);
Expand Down Expand Up @@ -384,9 +384,9 @@ int igraph_i_barabasi_game_psumtree(igraph_t *graph,
}
/* update probabilities */
for (j=0; j<no_of_neighbors; j++) {
long int n=VECTOR(edges)[edgeptr-2*j-1];
igraph_psumtree_update(&sumtree, n,
pow(VECTOR(degree)[n], power)+A);
long int nn=VECTOR(edges)[edgeptr-2*j-1];
igraph_psumtree_update(&sumtree, nn,
pow(VECTOR(degree)[nn], power)+A);
}
}
if (outpref) {
Expand Down Expand Up @@ -1349,9 +1349,9 @@ int igraph_recent_degree_game(igraph_t *graph, igraph_integer_t n,

/* update probabilities */
for (j=0; j<no_of_neighbors; j++) {
long int n=VECTOR(edges)[edgeptr-2*j-1];
igraph_psumtree_update(&sumtree, n,
pow(VECTOR(degree)[n], power)+zero_appeal);
long int nn=VECTOR(edges)[edgeptr-2*j-1];
igraph_psumtree_update(&sumtree, nn,
pow(VECTOR(degree)[nn], power)+zero_appeal);
}
if (outpref) {
VECTOR(degree)[i] += no_of_neighbors;
Expand Down Expand Up @@ -1770,12 +1770,12 @@ int igraph_grg_game(igraph_t *graph, igraph_integer_t nodes,

if (!torus) {
for (i=0; i<nodes; i++) {
igraph_real_t x1=VECTOR(*xx)[i];
igraph_real_t y1=VECTOR(*yy)[i];
igraph_real_t xx1=VECTOR(*xx)[i];
igraph_real_t yy1=VECTOR(*yy)[i];
long int j=i+1;
igraph_real_t dx, dy;
while ( j<nodes && (dx=VECTOR(*xx)[j] - x1) < radius) {
dy=VECTOR(*yy)[j]-y1;
while ( j<nodes && (dx=VECTOR(*xx)[j] - xx1) < radius) {
dy=VECTOR(*yy)[j]-yy1;
if (dx*dx+dy*dy < r2) {
IGRAPH_CHECK(igraph_vector_push_back(&edges, i));
IGRAPH_CHECK(igraph_vector_push_back(&edges, j));
Expand All @@ -1785,12 +1785,12 @@ int igraph_grg_game(igraph_t *graph, igraph_integer_t nodes,
}
} else {
for (i=0; i<nodes; i++) {
igraph_real_t x1=VECTOR(*xx)[i];
igraph_real_t y1=VECTOR(*yy)[i];
igraph_real_t xx1=VECTOR(*xx)[i];
igraph_real_t yy1=VECTOR(*yy)[i];
long int j=i+1;
igraph_real_t dx, dy;
while ( j<nodes && (dx=VECTOR(*xx)[j] - x1) < radius) {
dy=fabs(VECTOR(*yy)[j]-y1);
while ( j<nodes && (dx=VECTOR(*xx)[j] - xx1) < radius) {
dy=fabs(VECTOR(*yy)[j]-yy1);
if (dx > 0.5) {
dx=1-dx;
}
Expand All @@ -1805,9 +1805,9 @@ int igraph_grg_game(igraph_t *graph, igraph_integer_t nodes,
}
if (j==nodes) {
j=0;
while (j<i && (dx=1-x1+VECTOR(*xx)[j]) < radius &&
x1-VECTOR(*xx)[j]>=radius) {
dy=fabs(VECTOR(*yy)[j]-y1);
while (j<i && (dx=1-xx1+VECTOR(*xx)[j]) < radius &&
xx1-VECTOR(*xx)[j]>=radius) {
dy=fabs(VECTOR(*yy)[j]-yy1);
if (dy > 0.5) {
dy=1-dy;
}
Expand Down Expand Up @@ -2262,7 +2262,7 @@ int igraph_asymmetric_preference_game(igraph_t *graph, igraph_integer_t nodes,
IGRAPH_VECTOR_INIT_FINALLY(&intersect, 0);
for (i=0; i<types; i++) {
for (j=0; j<types; j++) {
long int k, l, c;
long int kk, l, c;
igraph_real_t p, last;
igraph_vector_t *v1, *v2;
long int v1_size, v2_size;
Expand Down Expand Up @@ -2296,9 +2296,9 @@ int igraph_asymmetric_preference_game(igraph_t *graph, igraph_integer_t nodes,
IGRAPH_CHECK(igraph_vector_reserve(&edges, igraph_vector_size(&edges)+l*2));

if (!loops && c>0) {
for (k=0; k<l; k++) {
long int to=floor(VECTOR(s)[k]/v1_size);
long int from=VECTOR(s)[k]-((igraph_real_t)to)*v1_size;
for (kk=0; kk<l; kk++) {
long int to=floor(VECTOR(s)[kk]/v1_size);
long int from=VECTOR(s)[kk]-((igraph_real_t)to)*v1_size;
if (VECTOR(*v1)[from] == VECTOR(*v2)[to]) {
/* remap loop edges */
to = v2_size-1;
Expand All @@ -2314,9 +2314,9 @@ int igraph_asymmetric_preference_game(igraph_t *graph, igraph_integer_t nodes,
igraph_vector_push_back(&edges, VECTOR(*v2)[to]);
}
} else {
for (k=0; k<l; k++) {
long int to=floor(VECTOR(s)[k]/v1_size);
long int from=VECTOR(s)[k]-((igraph_real_t)to)*v1_size;
for (kk=0; kk<l; kk++) {
long int to=floor(VECTOR(s)[kk]/v1_size);
long int from=VECTOR(s)[kk]-((igraph_real_t)to)*v1_size;
igraph_vector_push_back(&edges, VECTOR(*v1)[from]);
igraph_vector_push_back(&edges, VECTOR(*v2)[to]);
}
Expand Down Expand Up @@ -3057,7 +3057,7 @@ int igraph_simple_interconnected_islands_game(
int startIsland = 0;
int endIsland = 0;
int i, j, is;
double rand, last;
double myrand, last;

if (islands_n<0) {
IGRAPH_ERROR("Invalid number of islands", IGRAPH_EINVAL);
Expand Down Expand Up @@ -3105,9 +3105,9 @@ int igraph_simple_interconnected_islands_game(
// debug&tests : printf("last=%f \n", last);
while (last < maxpossibleedgesPerIsland) { // maxedgesPerIsland
IGRAPH_CHECK(igraph_vector_push_back(&s, last));
rand = RNG_GEOM(islands_pin);
last += rand; //RNG_GEOM(islands_pin);
//printf("rand=%f , last=%f \n", rand, last);
myrand = RNG_GEOM(islands_pin);
last += myrand; //RNG_GEOM(islands_pin);
//printf("myrand=%f , last=%f \n", myrand, last);
last += 1;
}

Expand Down
30 changes: 15 additions & 15 deletions src/layout.c
Expand Up @@ -1374,7 +1374,7 @@ int igraph_layout_lgl(const igraph_t *graph, igraph_matrix_t *res,

maxchange=epsilon+1;
while (it < maxit && maxchange > epsilon) {
long int j;
long int jj;
igraph_real_t t=maxdelta*pow((maxit-it)/(double)maxit, coolexp);
long int vid, nei;

Expand All @@ -1388,11 +1388,11 @@ int igraph_layout_lgl(const igraph_t *graph, igraph_matrix_t *res,
maxchange=0;

/* attractive "forces" along the edges */
for (j=0; j<igraph_vector_size(&edges); j++) {
for (jj=0; jj<igraph_vector_size(&edges); jj++) {
igraph_integer_t from, to;
igraph_real_t xd, yd, dist, force;
IGRAPH_ALLOW_INTERRUPTION();
igraph_edge(graph, VECTOR(edges)[j], &from, &to);
igraph_edge(graph, VECTOR(edges)[jj], &from, &to);
xd=MATRIX(*res, (long int)from, 0)-MATRIX(*res, (long int)to, 0);
yd=MATRIX(*res, (long int)from, 1)-MATRIX(*res, (long int)to, 1);
dist=sqrt(xd*xd+yd*yd);
Expand Down Expand Up @@ -1432,16 +1432,16 @@ int igraph_layout_lgl(const igraph_t *graph, igraph_matrix_t *res,
/* (long int) VECTOR(layers)[actlayer+1], pairs); */

/* apply the changes */
for (j=0; j<VECTOR(layers)[actlayer+1]; j++) {
long int vid=VECTOR(vids)[j];
igraph_real_t fx=VECTOR(forcex)[vid];
igraph_real_t fy=VECTOR(forcey)[vid];
for (jj=0; jj<VECTOR(layers)[actlayer+1]; jj++) {
long int vvid=VECTOR(vids)[jj];
igraph_real_t fx=VECTOR(forcex)[vvid];
igraph_real_t fy=VECTOR(forcey)[vvid];
igraph_real_t ded=sqrt(fx*fx+fy*fy);
if (ded > t) {
ded=t/ded;
fx*=ded; fy *=ded;
}
igraph_2dgrid_move(&grid, vid, fx, fy);
igraph_2dgrid_move(&grid, vvid, fx, fy);
if (fx > maxchange) { maxchange=fx; }
if (fy > maxchange) { maxchange=fy; }
}
Expand Down Expand Up @@ -1608,15 +1608,15 @@ int igraph_layout_grid_fruchterman_reingold(const igraph_t *graph,

/* update */
for (j=0; j<no_of_nodes; j++) {
long int vid=j;
igraph_real_t fx=VECTOR(forcex)[vid];
igraph_real_t fy=VECTOR(forcey)[vid];
long int vvid=j;
igraph_real_t fx=VECTOR(forcex)[vvid];
igraph_real_t fy=VECTOR(forcey)[vvid];
igraph_real_t ded=sqrt(fx*fx+fy*fy);
if (ded > t) {
ded=t/ded;
fx*=ded; fy *=ded;
}
igraph_2dgrid_move(&grid, vid, fx, fy);
igraph_2dgrid_move(&grid, vvid, fx, fy);
}
it++;

Expand Down Expand Up @@ -2579,11 +2579,11 @@ int igraph_layout_graphopt(const igraph_t *graph, igraph_matrix_t *res,

// Apply force from springs
for (edge = 0; edge < no_of_edges; edge++) {
long int this_node=IGRAPH_FROM(graph, edge);
long int other_node=IGRAPH_TO(graph, edge);
long int tthis_node=IGRAPH_FROM(graph, edge);
long int oother_node=IGRAPH_TO(graph, edge);
// Apply spring force on both nodes
igraph_i_apply_spring_force(res, &pending_forces_x, &pending_forces_y,
other_node, this_node, my_spring_length,
oother_node, tthis_node, my_spring_length,
spring_constant);
}

Expand Down

0 comments on commit ca3e5e1

Please sign in to comment.