Fixed first vertex bug, use pointers to track vertices (in case we want to move them easily later), and added a formula for vertex distance calculations

This commit is contained in:
2011-06-22 21:54:35 -04:00
parent bbae7690f4
commit 53f1560393
5 changed files with 78 additions and 29 deletions

18
graph.h
View File

@ -11,37 +11,41 @@
using std::list;
struct Vertex
class Vertex
{
public:
int x;
int y;
int x_min;
int x_max;
int y_min;
int y_max;
static float distance(Vertex a, Vertex b);
};
struct Edge
{
Vertex a;
Vertex b;
Vertex* a;
Vertex* b;
};
class Graph
{
public:
Graph() {}
Graph();
~Graph();
bool vertex_present(int x, int y, int size);
list<Vertex> get_vertices() { return vertices; }
list<Vertex*> get_vertices() { return vertices; }
list<Edge> get_edges() { return edges; }
void add_vertex(int x, int y, int size);
private:
Vertex last_vertex;
list<Vertex> vertices;
Vertex* last_vertex;
list<Vertex*> vertices;
list<Edge> edges;
};