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:
18
graph.h
18
graph.h
@ -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;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user