uint8_t cliques_overlap_cliques(cliques* c, int i, int j){ igraph_vector_t *i_clique, *j_clique; uint8_t overlap_size = 0; int node_it; int clique_size; i_clique = (igraph_vector_t*)VECTOR(c->plain_cliques_v_ptr)[i]; j_clique = (igraph_vector_t*)VECTOR(c->plain_cliques_v_ptr)[j]; if (i == j) return igraph_vector_size(i_clique); if( (igraph_vector_tail(i_clique) >= VECTOR(*j_clique)[0]) && (VECTOR(*i_clique)[0] <= igraph_vector_tail(j_clique))){ clique_size = igraph_vector_size(j_clique); for (node_it = 0; node_it < clique_size; node_it++) { if (VECTOR(*j_clique)[node_it] < VECTOR(*i_clique)[0]) // if the current node is lower than i_clique minimum node, then continue continue; if (VECTOR(*j_clique)[node_it] > igraph_vector_tail(i_clique)) // if the current node is greater than i_clique maximum node, than exit break; // search element node_it^th of j_clique within i_clique vector if (igraph_vector_binsearch2(i_clique, VECTOR(*j_clique)[node_it])) overlap_size++; } } return overlap_size; }
int igraph_complementer(igraph_t *res, const igraph_t *graph, igraph_bool_t loops) { long int no_of_nodes=igraph_vcount(graph); igraph_vector_t edges; igraph_vector_t neis; long int i, j; long int zero=0, *limit; IGRAPH_VECTOR_INIT_FINALLY(&edges, 0); IGRAPH_VECTOR_INIT_FINALLY(&neis, 0); if (igraph_is_directed(graph)) { limit=&zero; } else { limit=&i; } for (i=0; i<no_of_nodes; i++) { IGRAPH_ALLOW_INTERRUPTION(); IGRAPH_CHECK(igraph_neighbors(graph, &neis, (igraph_integer_t) i, IGRAPH_OUT)); if (loops) { for (j=no_of_nodes-1; j>=*limit; j--) { if (igraph_vector_empty(&neis) || j>igraph_vector_tail(&neis)) { IGRAPH_CHECK(igraph_vector_push_back(&edges, i)); IGRAPH_CHECK(igraph_vector_push_back(&edges, j)); } else { igraph_vector_pop_back(&neis); } } } else { for (j=no_of_nodes-1; j>=*limit; j--) { if (igraph_vector_empty(&neis) || j>igraph_vector_tail(&neis)) { if (i!=j) { IGRAPH_CHECK(igraph_vector_push_back(&edges, i)); IGRAPH_CHECK(igraph_vector_push_back(&edges, j)); } } else { igraph_vector_pop_back(&neis); } } } } IGRAPH_CHECK(igraph_create(res, &edges, (igraph_integer_t) no_of_nodes, igraph_is_directed(graph))); igraph_vector_destroy(&edges); igraph_vector_destroy(&neis); IGRAPH_I_ATTRIBUTE_DESTROY(res); IGRAPH_I_ATTRIBUTE_COPY(res, graph, /*graph=*/1, /*vertex=*/1, /*edge=*/0); IGRAPH_FINALLY_CLEAN(2); return 0; }
int igraph_adjlist_simplify(igraph_adjlist_t *al) { long int i; long int n=al->length; igraph_vector_t mark; IGRAPH_VECTOR_INIT_FINALLY(&mark, n); for (i=0; i<n; i++) { igraph_vector_t *v=&al->adjs[i]; long int j, l=igraph_vector_size(v); VECTOR(mark)[i] = i+1; for (j=0; j<l; /* nothing */) { long int e=VECTOR(*v)[j]; if (VECTOR(mark)[e] != i+1) { VECTOR(mark)[e]=i+1; j++; } else { VECTOR(*v)[j] = igraph_vector_tail(v); igraph_vector_pop_back(v); l--; } } } igraph_vector_destroy(&mark); IGRAPH_FINALLY_CLEAN(1); return 0; }