-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNode.cpp
89 lines (73 loc) · 1.42 KB
/
Node.cpp
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
//
// Node.cpp
// Project 5
//
// Created by Benjamin Elvon Bay on 7/31/15.
// Copyright (c) 2015 Benjamin Elvon Bay. All rights reserved.
//
#include "Node.h"
Node::Node(int num_in) {
visited_marker = false;
postorder_num = -1;
name = num_in;
}
Node::~Node() {}
int Node::getName() {
return name;
}
bool Node::getMarker() {
return visited_marker;
}
int Node::getPostorder() {
return postorder_num;
}
vector<int> Node::getAdjacents() {
vector<int> vec;
for (int i : adjacent_nodes) {
vec.push_back(i);
}
return vec;
}
set<int> Node::getAdjacentsSet() {
return adjacent_nodes;
}
void Node::addAdjacent(int adjacent) {
adjacent_nodes.insert(adjacent);
}
void Node::assignPO(int i) {
postorder_num = i;
}
vector<string> Node::getAdjacentsR() {
vector<string> vec;
for (int i : adjacent_nodes) {
vec.push_back("R" + to_string(i));
}
return vec;
}
void Node::visited() {
visited_marker = true;
}
void Node::unvisit() {
visited_marker = false;
}
vector<int> Node::getAdjacentsSettoStacktoVector() {
vector<int> vec;
stack<int> s;
for (int i : adjacent_nodes) {
s.push(i);
}
while (!s.empty()) {
vec.push_back(s.top());
s.pop();
}
return vec;
}
/*
vector<int> Node::getAdjacentsSCCorder(){
vector<int> vec;
for (int i : adjacent_nodes) {
vec.push_back(i);
}
return vec;
}
*/