-
Notifications
You must be signed in to change notification settings - Fork 4
/
Node.cpp
51 lines (34 loc) · 1.22 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
#include "Node.h"
#include "Edge.h"
#include <sstream>
#include <iomanip>
#include <cctype> // für isalnum() (siehe http://www.cplusplus.com/reference/cctype/isalnum/?kw=isalnum)
int Node::s_numInstances = 0;
//-------------------------------------------------------------------------------------------------
Node::Node()
{
std::stringstream s;
s << "n" << std::setw(4) << std::setfill('0') << s_numInstances;
m_id = s.str();
s_numInstances += 1;
}
//-------------------------------------------------------------------------------------------------
Node::Node(std::string id) : m_id(id)
{
s_numInstances += 1;
}
//-------------------------------------------------------------------------------------------------
std::list<Node*> Node::getNeighbours(Direction direction)
{
std::list<Node*> ret;
if (direction == DIR_OUT || direction == DIR_BOTH) {
for (Edge* pEdge : m_outEdges)
ret.push_back(&pEdge->getDstNode());
}
if (direction == DIR_IN || direction == DIR_BOTH) {
for (Edge* pEdge : m_inEdges)
ret.push_back(&pEdge->getSrcNode());
}
return ret;
}
//-------------------------------------------------------------------------------------------------