2011-06-22 21:29:41 +00:00
|
|
|
/* Represents an undirected graph.
|
|
|
|
* Also contains the vertex and edge classes
|
|
|
|
* vertexes know their center point on the SDL Surface -
|
|
|
|
* bad decoupling maybe, but not too bad, all things considered
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _GRAPH_H_
|
|
|
|
#define _GRAPH_H_
|
|
|
|
|
|
|
|
#include <list>
|
|
|
|
|
|
|
|
using std::list;
|
|
|
|
|
2011-06-23 01:54:35 +00:00
|
|
|
class Vertex
|
2011-06-22 21:29:41 +00:00
|
|
|
{
|
2011-06-23 01:54:35 +00:00
|
|
|
public:
|
2011-06-23 16:46:32 +00:00
|
|
|
Vertex(int x, int y, int r);
|
2011-06-23 03:06:23 +00:00
|
|
|
|
2011-06-22 21:29:41 +00:00
|
|
|
int x;
|
|
|
|
int y;
|
2011-06-23 16:36:40 +00:00
|
|
|
int r;
|
2011-06-22 21:29:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct Edge
|
|
|
|
{
|
2011-06-23 01:54:35 +00:00
|
|
|
Vertex* a;
|
|
|
|
Vertex* b;
|
2011-06-22 21:29:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class Graph
|
|
|
|
{
|
|
|
|
public:
|
2011-06-23 01:54:35 +00:00
|
|
|
Graph();
|
|
|
|
~Graph();
|
2011-06-22 21:29:41 +00:00
|
|
|
|
|
|
|
bool vertex_present(int x, int y, int size);
|
|
|
|
|
2011-06-23 01:54:35 +00:00
|
|
|
list<Vertex*> get_vertices() { return vertices; }
|
2011-06-22 21:29:41 +00:00
|
|
|
list<Edge> get_edges() { return edges; }
|
|
|
|
|
2011-06-23 16:36:40 +00:00
|
|
|
void select_vertex(int x, int y);
|
|
|
|
void do_vertex(int x, int y, int r);
|
2011-06-23 02:32:33 +00:00
|
|
|
Vertex* get_current_vertex() { return current_vertex; }
|
2011-06-22 21:29:41 +00:00
|
|
|
|
|
|
|
private:
|
2011-06-23 16:36:40 +00:00
|
|
|
void add_vertex(int x, int y, int r);
|
2011-06-23 02:32:33 +00:00
|
|
|
|
|
|
|
Vertex* current_vertex;
|
2011-06-23 01:54:35 +00:00
|
|
|
list<Vertex*> vertices;
|
2011-06-22 21:29:41 +00:00
|
|
|
list<Edge> edges;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|