1 Star 0 Fork 0

郑玉强/dataStructure

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
disjoint_set.h 513 Bytes
一键复制 编辑 原始数据 按行查看 历史
#pragma once
class DisjointSet
{
private:
int size_; // 数组大小
int* parents_; // 父节点数组,下标代表结点,对应下标存储的值代表父节点。如,parents_[index] = parent_index;index代表当前结点,parent_index代表当前结点的父节点
public:
explicit DisjointSet(int size);
~DisjointSet() { delete[] this->parents_; }
// 合并
void _union(int node1, int node2);
// 查找(递归)
int findRecursive(int index);
// 合并集合(Weighted)
void weightedUnion(int node1,int node2);
// 查找
int find(int index);
};
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/zheng-yuqiang_lyg_cn/data-structure.git
git@gitee.com:zheng-yuqiang_lyg_cn/data-structure.git
zheng-yuqiang_lyg_cn
data-structure
dataStructure
dev01

搜索帮助