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.h | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 labb3/tsp/src/Node.h (limited to 'labb3/tsp/src/Node.h') diff --git a/labb3/tsp/src/Node.h b/labb3/tsp/src/Node.h new file mode 100644 index 0000000..f9908e4 --- /dev/null +++ b/labb3/tsp/src/Node.h @@ -0,0 +1,47 @@ +/* + * TDDD86 TSP + * This file contains the declaration of the Node structure. + * See Node.cpp for implementation of each member. + * Your code should work properly with an unmodified version of this file. + */ + +#ifndef NODE_H +#define NODE_H + +#include +#include "Point.h" +using namespace std; + +/* + * Each Node structure represents a single node in a circular linked list + * used in a TSP tour. + */ +struct Node { + Point point; // this nodes point + Node* next; // pointer to next node in the list (nullptr if none) + + /* + * Constructs a new node storing the given point and next pointer. + */ + Node(Point p, Node* _next = nullptr); + + /* + * Returns a string representation of the Node for debugging, such as + * "Node{addr=0x7e83f4, point=(2.5, 3.5), next=0x43b2a0}". + * + * Note that the toString output includes the node's memory address, as well + * as the memory address where its next pointer points. + * + * Keep in mind that toString won't be called if you try to print a Node*. + * You must print the node itself. + */ + string toString() const; +}; + +/* + * Outputs the given node to the given output stream (e.g. cout) in the same + * format as returned by its toString member function. + */ +ostream& operator <<(ostream& out, const Node& node); + +#endif // END NODE_H -- cgit v1.2.1