并查集的实现c


#ifndef _UNION_SET_H_
#define _UNION_SET_H_


#include 
#include 
#include 


/*
  *This file is about union set operations.
  *and the program is c-style,you can transfer it to 
  *cpp-style.
  *you can copy,re-write,sell this program but no need to
  *let me know this.but you need copy this comment to your
  *program's header comment.
  *hujian nankai university
  *2016/5/26
*/

#define UNION_SET_MAX_SIZE 1024*10 //the size of union.

//the parent array
int parent[UNION_SET_MAX_SIZE];

//the height of the union tree
int rank[UNION_SET_MAX_SIZE];

//the size of union
int union_size=0;


//initialze the union set
void init_set()
{
    int i;
    for(i=0;i


你可能感兴趣的:(数据结构,c/c++)