-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNode.cpp
More file actions
41 lines (34 loc) · 802 Bytes
/
Node.cpp
File metadata and controls
41 lines (34 loc) · 802 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
//
// Node.cpp
// 7-25
//
// Created by Amit Prakash on 7/25/25.
//
#include "Node.hpp"
Node::Node(void):ancestor(nullptr), index(0), isTip(false), name(""){
}
void Node::addNeighbor(Node* p){
neighbors.insert(p);
bool found=false;
for(Node* n: p->getNeighbors())
if(n==this)
found=true;
if(found==false)
p->addNeighbor(this);
}
std::vector<Node*>& Node:: getDescendants(void){
descendants.clear();
for(Node* n: neighbors)
if(n!=ancestor)
descendants.push_back(n);
return descendants;
}
void Node::removeNeighbor(Node* p){
neighbors.erase(p);
bool found=false;
for(Node* n: p->getNeighbors())
if(n==this)
found=true;
if(found==true)
p->removeNeighbor(this);
}