#include #include #include #include #include #include #define max(x,y) (((x)>(y))?(x):(y)) #define min(x,y) (((x)<(y))?(x):(y)) enum Logic { _NO , _YES }; enum Status { _COLORED, _NEIGHBOR, _FREE, _SELECTED }; class Vertex; struct Edge { Vertex *vert; }; class Vertex { public: long COLOR; long EDGES; Edge *edge; Status STATUS; long NEIGHBORS; long SELECTED_NEIGHBORS; long COLORED_NEIGHBORS; float OBJECTIVE_VALUE; Vertex () { COLOR = -1; EDGES = 0; edge = 0; STATUS = _FREE; SELECTED_NEIGHBORS = 0; COLORED_NEIGHBORS = 0; OBJECTIVE_VALUE = 0.; NEIGHBORS = 0; } void SelectVertex (); void ColorVertex (long ); Logic ConnectedToVertex (Vertex* ); }; class Graph { Vertex *vertex; long VERTICES; long RANDOM_1, RANDOM_2; float *rando; long LENGTH_RANDOM; long CURRENT_RANDOM; public: Graph (char* ); ~Graph () { for (long i = 0; i < VERTICES; i++) if (vertex[i].edge) delete vertex[i].edge; if (vertex) delete vertex; delete rando; } float Cost(Edge* , long ); void SetValue(Vertex* , float* , float* ); float LocalSearch(Edge* , long& , long* , Edge* , long ); void GraphColoring (long* , long& ); float Uniform(); float Get() { CURRENT_RANDOM = (CURRENT_RANDOM + 1) % LENGTH_RANDOM; return(rando[CURRENT_RANDOM]); } }; struct MaxIndSet { Edge *set; float COST; long SIZE; Logic FULL; }; class Window { public: MaxIndSet *list; long ELEMENTS; float SMALLEST_COST; Window (long , long ); ~Window (); void InsertMis (Edge* , long , float ); void BestMis (Edge* , long& , float& ); void ComputeCosts (Graph* ); };