summaryrefslogtreecommitdiffstats
path: root/labb3/tsp/src/Tour.h
blob: 2a644b7eaff521277672c80b819ea9a82d32068e (plain) (blame)
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
/*
 * TDDD86 Lab 3b - gusso230 (group 11)
 * This file contains the tour structure.
 * You can insert points using two algorithms (nearest neighbour and smallest
 * increase), get the total length of the tour and draw the tour.
 */
#ifndef TOUR_H
#define TOUR_H

#include "Node.h"
#include "Point.h"

class Tour {
public:
    /*
     * Create an empty tour.
     */
    Tour();

    /*
     * Free all nodes in the tour.
     */
    ~Tour();

    /*
     * Print the tour to stdout.
     */
    void show() const;

    /*
     * Draw the tour to `scene`.
     */
    void draw(QGraphicsScene *scene) const;

    /*
     * Return the number of nodes in tour.
     */
    int size() const;

    /*
     * Return the total distance of the tour.
     */
    double distance() const;

    /*
     * Insert `p` using the "nearest neighbour" heuristic.
     */
    void insertNearest(Point p);

    /*
     * Insert `p` using the "smallest increase" heuristic.
     */
    void insertSmallest(Point p);

private:
    Node *first; // first node
};

#endif // TOUR_H