-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnode.cpp
More file actions
60 lines (49 loc) · 835 Bytes
/
Copy pathnode.cpp
File metadata and controls
60 lines (49 loc) · 835 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
/**
* Name: node.cpp
* Desc: Implementation of node class described in node.h
* Auth: Stephen Thoma, 2012
**/
#include "node.h"
Node::Node(const char * newName)
{
name = newName;
cost = UNDEFINED;
edgeToMe = NULL;
}
Node::~Node()
{
delete [] name;
}
int Node::getCost()
{
return cost;
}
void Node::setCost(int newCost)
{
cost = newCost;
}
vector<Edge *> * Node::getConnections()
{
return &connections;
}
void Node::addConnection(Edge * newEdge)
{
return connections.push_back(newEdge);
}
void Node::computeCost(Edge * edgeToMe)
{
Node * nodeThatGotToMe = edgeToMe->getOtherNode(this);
cost = edgeToMe->getCost() + nodeThatGotToMe->getCost();
}
void Node::setEdgeToMe(Edge * newEdgeToMe)
{
edgeToMe = newEdgeToMe;
}
Edge * Node::getEdgeToMe()
{
return edgeToMe;
}
const char * Node::getName()
{
return name;
}