SHOGUN
v3.0.0
Main Page
Related Pages
Modules
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
src
shogun
structure
DisjointSet.h
Go to the documentation of this file.
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/base/SGObject.h
>
15
#include <
shogun/lib/SGVector.h
>
16
17
namespace
shogun
18
{
19
24
class
CDisjointSet
:
public
CSGObject
25
{
26
public
:
28
CDisjointSet
();
29
34
CDisjointSet
(int32_t num_elements);
35
37
~CDisjointSet
() { }
38
40
virtual
const
char
*
get_name
()
const
{
return
"DisjointSet"
; }
41
43
void
make_sets
();
44
50
int32_t
find_set
(int32_t x);
51
58
int32_t
link_set
(int32_t xroot, int32_t yroot);
59
67
bool
union_set
(int32_t x, int32_t y);
68
75
bool
is_same_set
(int32_t x, int32_t y);
76
82
int32_t
get_unique_labeling
(
SGVector<int32_t>
out_labels);
83
88
int32_t
get_num_sets
();
89
94
bool
get_connected
();
95
100
void
set_connected
(
bool
is_connected);
101
102
private
:
104
void
init();
105
106
private
:
108
int32_t m_num_elements;
109
111
SGVector<int32_t>
m_parent;
112
114
SGVector<int32_t>
m_rank;
115
117
bool
m_is_connected;
118
};
119
120
}
121
122
#endif
123
SHOGUN
Machine Learning Toolbox - Documentation