From 403ce5391e0fecc51bf50c86070ebc0e6d7e05af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Mon, 17 Aug 2020 19:34:09 +0200 Subject: add tsp code --- labb3/tsp/src/Node.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 labb3/tsp/src/Node.cpp (limited to 'labb3/tsp/src/Node.cpp') diff --git a/labb3/tsp/src/Node.cpp b/labb3/tsp/src/Node.cpp new file mode 100644 index 0000000..3b7697b --- /dev/null +++ b/labb3/tsp/src/Node.cpp @@ -0,0 +1,32 @@ +/* + * TDDD86 TSP + * This file contains the implementation of the Node structure. + * See Node.h for comments about each member. + * Your code should work properly with an unmodified version of this file. + */ + +#include +#include +#include +#include "Node.h" + +Node::Node(Point p, Node* _next) + : point(p.x, p.y), next(_next) {} + +string Node::toString() const { + stringstream out; + out << "Node{addr=" << ((void*) this); + out << ", point=" << point; + if (next != nullptr) { + out << ", next=" << ((void*) next); + } else { + out << ", next=nullptr"; + } + out << "}"; + return out.str(); +} + +ostream& operator <<(ostream& out, const Node& node) { + out << node.toString(); + return out; +} -- cgit v1.2.1