Пример #1
0
static void visit(bd_tree_handle_t *handle,
		  int k, int tag)

{

  int i;
  bd_tree_vertex_t *v;

  push_vertex(handle, handle->vertices + k);
  
  while (!vertex_stack_empty(handle)) {
    v = pop_vertex(handle);
    if (v == NULL) {
      fprintf(stderr, "ERROR - tree:visit, popped NULL v\n");
      return;
    }
    if (!v->visited) {
      v->tag = tag;
      v->visited = 1;
      for (i = 0; i < v->nadjacent; i++) {
	if (v->adjacent[i] > handle->n_index_alloc - 1) {
	  fprintf(stderr, "ALLOC ERROR - tree.c:visit()\n");
	  fprintf(stderr, "n_alloc: %d, n_needed: %d\n",
		  handle->n_index_alloc, v->adjacent[i]);
	}
	if (handle->index[v->adjacent[i]] >= 0) {
	  push_vertex(handle, (handle->vertices +
			       handle->index[v->adjacent[i]]));
	}
      } /* i */
    }
  } /* while */

}
Пример #2
0
vertex *vertex_pool_get(vertex_pool *pool)
{
	if(vertex_stack_empty(pool->stack))
	{
		return vertex_create();
	}
	else
	{
		return vertex_stack_pop(pool->stack);
	}
}
Пример #3
0
static void visit(int k,
		  tree_vertex_t *vertices,
		  si32 tag)

{

  int i;
  tree_vertex_t *v;

  push_vertex(vertices + k);

  while (!vertex_stack_empty()) {
    v = pop_vertex();
    if (!v->visited) {
      v->tag = tag;
      v->visited = 1;
      for (i = 0; i < v->nadjacent; i++) {
	push_vertex(vertices + vertex_index(v->adjacent[i]));
      }
    } /* i */
  } /* while */

}