Пример #1
0
graph_t *KCoreGraph::subgraph(IntStack *vset) {
	
	assert(!vset->empty());
	
	graph_t *g = graph_new(maxsize());
	IntStack *nb;
	
	int val,preval,val2,preval2;
	
	val = vset->head();
	preval = val-1;
	while (val != preval) {
		nb = neighbourhoods.at(val);
		if (!nb->empty()) {
			val2 = nb->head();
			preval2 = val2-1;
			while (val2 != preval2) {
				if ((val > val2) && vset->contain(val2)) GRAPH_ADD_EDGE(g,val,val2);
				preval2 = val2;
				val2 = nb->next(preval2);
			}
		}
		preval = val;
		val = vset->next(preval);
	}
	
	return g;
};
Пример #2
0
int main()
{
	IntStack intStack;
	intStack.push(1);
	intStack.push(2);
	intStack.push(3);
	while (!intStack.empty())
	{
		int t = intStack.top();
		intStack.pop();
		printf("%d\n", t);
	}
	intStack.push(4);
	intStack.push(5);
	while (!intStack.empty())
	{
		int t = intStack.top();
		intStack.pop();
		printf("%d\n", t);
	}
	return 0;
}
Пример #3
0
void KCoreGraph::remove_vertex(const int idvert) {
	assert(neighbourhoods.at(idvert) != NULL);
	
	/* Vertex to be removed */
	IntStack *vn = neighbourhoods.at(idvert);
	
	/* Remove the edges between vn and its neighbors */
	int val;
	while (!vn->empty()) {
		val = vn->head();
		neighbourhoods.at(val)->remove(idvert);
		if (((int)(neighbourhoods.at(val)->size)) < k) {
			if (!tbr->contain(val)) tbr->add(val);
		}
		vn->remove(val);
	}
	
	/* Remove vn */
	neighbourhoods.at(idvert) = NULL;
	delete(vn);
};