-
Notifications
You must be signed in to change notification settings - Fork 283
Expand file tree
/
Copy pathtree.h
More file actions
64 lines (33 loc) · 939 Bytes
/
tree.h
File metadata and controls
64 lines (33 loc) · 939 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#pragma once
#include <string>
#include <vector>
#include <stdint.h>
class Node{
friend class RandomTree;
private:
int32_t id = -1;
int32_t parent_id = -1;
std::vector<int32_t> prv_children = {};
int32_t depth = -1;
std::string label;
public:
Node(uint32_t in_id, int32_t in_parent_id, uint32_t in_depth);
const std::vector<int32_t>& children() const;
std::string get_label() const;
uint32_t get_id() const;
void set_label(const std::string &in_label);
};
class RandomTree{
friend class Labeler;
private:
std::vector<Node> nodes;
std::vector<std::vector<uint32_t>> levels;
uint32_t num_nodes = 0;
uint32_t tree_depth = 0;
uint32_t new_node(int32_t parent_id, uint32_t depth);
public:
RandomTree(uint32_t total_nodes);
Node & get_node(uint32_t node_id);
size_t size() const;
std::string dot_format() const;
};