SHOGUN  4.1.0
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义  
DisjointSet.h
浏览该文件的文档.
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 3 of the License, or
5  * (at your option) any later version.
6  *
7  * Written (W) 2013 Shell Hu
8  * Copyright (C) 2013 Shell Hu
9  */
10 
11 #ifndef __DISJOINTSET_H__
12 #define __DISJOINTSET_H__
13 
14 #include <shogun/lib/config.h>
15 
16 #include <shogun/base/SGObject.h>
17 #include <shogun/lib/SGVector.h>
18 
19 namespace shogun
20 {
21 
26 class CDisjointSet : public CSGObject
27 {
28 public:
30  CDisjointSet();
31 
36  CDisjointSet(int32_t num_elements);
37 
40 
42  virtual const char* get_name() const { return "DisjointSet"; }
43 
45  void make_sets();
46 
52  int32_t find_set(int32_t x);
53 
60  int32_t link_set(int32_t xroot, int32_t yroot);
61 
69  bool union_set(int32_t x, int32_t y);
70 
77  bool is_same_set(int32_t x, int32_t y);
78 
84  int32_t get_unique_labeling(SGVector<int32_t> out_labels);
85 
90  int32_t get_num_sets();
91 
96  bool get_connected();
97 
102  void set_connected(bool is_connected);
103 
104 private:
106  void init();
107 
108 private:
110  int32_t m_num_elements;
111 
113  SGVector<int32_t> m_parent;
114 
116  SGVector<int32_t> m_rank;
117 
119  bool m_is_connected;
120 };
121 
122 }
123 
124 #endif
125 
virtual const char * get_name() const
Definition: DisjointSet.h:42
bool union_set(int32_t x, int32_t y)
Definition: DisjointSet.cpp:86
Class SGObject is the base class of all shogun objects.
Definition: SGObject.h:112
Class CDisjointSet data structure for linking graph nodes It's easy to identify connected graph...
Definition: DisjointSet.h:26
int32_t get_unique_labeling(SGVector< int32_t > out_labels)
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
void set_connected(bool is_connected)
bool is_same_set(int32_t x, int32_t y)
int32_t link_set(int32_t xroot, int32_t yroot)
Definition: DisjointSet.cpp:63
int32_t find_set(int32_t x)
Definition: DisjointSet.cpp:52

SHOGUN 机器学习工具包 - 项目文档