First stab at the calculate_strength() function - all it nets us is a floating point exception when compiling with -DDEBUG
This commit is contained in:
32
graph.cpp
32
graph.cpp
@ -106,7 +106,7 @@ bool Graph::add_vertex(int x, int y, int r, int colour, int score, Vertex* src)
|
||||
vertices.push_back(v);
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "debug: Graph::add_vertex(): added: x=%d, y=%d, r=%d\n", v->x, v->y, v->r);
|
||||
fprintf(stderr, "debug: Graph::add_vertex(): added: x=%d, y=%d, r=%d, score=%d\n", v->x, v->y, v->r, v->score);
|
||||
#endif
|
||||
|
||||
return true;
|
||||
@ -121,3 +121,33 @@ Vertex::Vertex(int x, int y, int r, int colour, int score)
|
||||
this->colour = colour;
|
||||
this->score = score;
|
||||
}
|
||||
|
||||
|
||||
list<Vertex*> Graph::get_colour(int colour)
|
||||
{
|
||||
list<Vertex*> answer;
|
||||
|
||||
for (list<Vertex*>::iterator cursor = vertices.begin();
|
||||
cursor != vertices.end(); cursor++)
|
||||
{
|
||||
Vertex* v = *cursor;
|
||||
if (v->colour == colour) answer.push_back(v);
|
||||
}
|
||||
|
||||
return answer;
|
||||
}
|
||||
|
||||
|
||||
list<Edge> Graph::get_vertex_edges(Vertex* v)
|
||||
{
|
||||
list<Edge> answer;
|
||||
|
||||
for (list<Edge>::iterator cursor = edges.begin();
|
||||
cursor != edges.end(); cursor++)
|
||||
{
|
||||
Edge e = *cursor;
|
||||
if (e.a == v || e.b == v) answer.push_back(e);
|
||||
}
|
||||
|
||||
return answer;
|
||||
}
|
||||
|
Reference in New Issue
Block a user