/************************************************************ ************************************************************ **** **** Project2.h - This file defines some structures and **** functions that you'll be using for your **** project 2 solutions. It provides a Vertex class, a **** Graph class, a dist function, and the functions **** StaticRender and AnimateRender. **** ************************************************************ ************************************************************/ #ifndef _PROJECT2_ #define _PROJECT2_ #include #include using namespace std; /***************************************** ** class Vertex: A Vertex is simply a ** vector of int's representing the indices ** of that Vertex's neighbors. I added the ** data-members x and y to store the ** position of the vertex. *****************************************/ class Vertex : public vector { public: double x, y; // coordinates of the vertex's position }; /***************************************** ** class Graph: A Graph is simply a vector ** of Vertex's. The Vertex with index i in ** Graph G is accessed by G[i]. So, the ** number of neighbors of G[i] is ** G[i].size(), and the kth neighbor of ** vertex i is G[i][k]. *****************************************/ class Graph : public vector { public: Graph(int n) : vector(n) {} }; /*************************************** ** dist(u,v) returns the Euclidean ** distance from the point at which ** vertex u is located to the point at ** which vertex v is located. Note: ** this does not mean that there is ** actually an edge between these two ** vertices in the graph!! ***************************************/ inline double dist(Vertex &u, Vertex &v) { double x = u.x - v.x; double y = u.y - v.y; return sqrt(x*x + y*y); } /*************************************** ** These functions are called by the ** user in order to render graphs and ** minimum spanning trees. ***************************************/ extern void StaticRender(Graph &G); extern void StaticRender(Graph &G, vector &Pred); extern void AnimateRender(Graph &G, vector &Pred, vector &Ord); #endif //_PROJECT2_