Removed the concept of edges in favor of a proper tree-style approach, with each vertex knowing about its neighbors. This seems to have broken both Grah::crosses_edge() and Graph::remove_vertex. and the move radius circle doesn't draw any more. Go team.
This commit is contained in:
23
graph.h
23
graph.h
@ -1,5 +1,5 @@
|
||||
/* Represents an undirected graph.
|
||||
* Also contains the vertex and edge classes
|
||||
* Also contains the vertex class
|
||||
* These are not quite traditional graph theory graphs, because they also have
|
||||
* cartesian coordinates, and can do some math to ensure planarity is preserved
|
||||
* (that is, planarity in the existant layout, not being isomorphic to a
|
||||
@ -31,21 +31,10 @@ class Vertex
|
||||
int r;
|
||||
int colour;
|
||||
int score;
|
||||
|
||||
list<Vertex*> neighbors;
|
||||
};
|
||||
|
||||
class Edge
|
||||
{
|
||||
public:
|
||||
Edge();
|
||||
Edge(Vertex* a, Vertex* b, int score = 0);
|
||||
|
||||
Vertex* a;
|
||||
Vertex* b;
|
||||
int score;
|
||||
|
||||
bool operator==(const Edge e) const;
|
||||
bool operator!=(const Edge e) const { return !(*this == e); }
|
||||
};
|
||||
|
||||
class Graph
|
||||
{
|
||||
@ -54,10 +43,7 @@ class Graph
|
||||
virtual ~Graph();
|
||||
|
||||
list<Vertex*> get_vertices() const { return vertices; }
|
||||
list<Edge> get_edges() const { return edges; }
|
||||
list<Vertex*> get_colour(int colour);
|
||||
list<Edge> get_edges(Vertex* v);
|
||||
list<Vertex*> get_neighbors(Vertex* v);
|
||||
|
||||
bool point_in_vertex(int x, int y);
|
||||
Vertex * vertex_at(int x, int y);
|
||||
@ -70,11 +56,10 @@ class Graph
|
||||
|
||||
protected:
|
||||
list<Vertex*> vertices;
|
||||
list<Edge> edges;
|
||||
|
||||
private:
|
||||
bool vertex_would_overlap(int x, int y, int r);
|
||||
bool crosses_edge(Edge e);
|
||||
bool crosses_edge(Vertex* a, Vertex* b);
|
||||
bool planar;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user