-
Notifications
You must be signed in to change notification settings - Fork 4
/
Edge.cpp
39 lines (25 loc) · 1006 Bytes
/
Edge.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
#include "Edge.h"
//-------------------------------------------------------------------------------------------------
Edge::Edge(Node& rSrc, Node& rDst)
: m_srcNode(rSrc), m_dstNode(rDst)
{
rSrc.getOutEdges().push_back(this);
rDst.getInEdges().push_back(this);
}
//-------------------------------------------------------------------------------------------------
Edge::~Edge()
{
m_srcNode.getOutEdges().remove(this);
m_dstNode.getInEdges().remove(this);
}
//-------------------------------------------------------------------------------------------------
bool Edge::isConnectedTo(const Node& rNode) const
{
return &m_srcNode == &rNode || &m_dstNode == &rNode;
}
//-------------------------------------------------------------------------------------------------
std::string Edge::toString() const
{
return m_srcNode.getId() + " -> " + m_dstNode.getId();
}
//-------------------------------------------------------------------------------------------------