Ejemplo n.º 1
0
graph kruskal(graph G, float (*pesoArco )(void *)) {
    int         nNodes  = graphCountNodes(G);
    graph       GF       = graphInit(nNodes, GRAPH_IS_NOT_ORIENTED); // e gli orientati??
    uf_handler  uf      = uf_init(graphGetMaxNodes(G));

    archInfo arco;

    coda allArcs=graphGetAllArchs(G);
    heap archHeap=heapInit(nNodes, pesoArco, HEAP_GET_MIN);

    while ((arco=codaGet(allArcs))!=NULL) {
        heapInsert(archHeap, arco);
    }

    int from, to;

    while ((arco= heapExtract(archHeap))!=NULL) {
        from=arco->fromNode;
        to= arco->toNode;

        if (uf_find(uf,from , to)) {
            uf_unionFind(uf, from, to);

            graphAddNode(GF, from, arco->fromInfo);
            graphAddNode(GF, to, arco->toInfo);
            graphAddArch(GF, from, to, arco->archInfo);
        }
    }

    return GF;

}
Ejemplo n.º 2
0
void	tf_launch(const char *name, void (*sort)(int *, size_t))
{
	t_timer	timer;
	int		ptr_int[SIZE_TAB];

	M_INFOS(name);
	uf_init(ptr_int);
	D_TIMER(start)(&timer);
	sort(ptr_int, SIZE_TAB);
	D_TIMER(pause)(&timer);
	if (uf_check_if_tab_is_sorted(ptr_int) == true)
	{
		uf_print_nbr(D_TIMER(get_ticks)(&timer));
		uf_print_str(" milliseconds\n\n");
	}
	else
		uf_print_tab(ptr_int);
}
Ejemplo n.º 3
0
void engine_init(void)
{
  region_init();

  engine_region = newregion();

  hash_table_init();
  seed_fn_ptr_table(permanent);

  banshee_region_persistence_init();
  bounds_init();
  stamp_init();
  list_init();
  uf_init();
  term_hash_init();

  rb_stack = new_persistent_banshee_rollback_stack();
  handle_error = default_error_handler;

}