00001 #ifndef SOLVER_H 00002 #define SOLVER_H 00003 00004 #include <list> 00005 #include <vector> 00006 #include "unification.h" 00007 #include <ostream> 00008 using namespace std; 00009 00010 namespace Solver 00011 { 00012 class Vertex; 00013 class Edge; 00014 00015 class VariableSolution 00016 { 00017 public: 00018 bool seeoutside; 00019 Node *definition; 00020 }; 00021 00022 class Edge 00023 { 00024 public: 00025 Vertex *n1; 00026 Vertex *n2; 00027 int a; 00028 int b; 00029 }; 00030 00031 class Vertex 00032 { 00033 public: 00034 list<Edge*> in; 00035 list<Edge*> out; 00036 int variable; 00037 int count; 00038 int min; 00039 int max; 00040 bool setBounds(int min,int max); 00041 bool setBoundMin(int min); 00042 bool setBoundMax(int max); 00043 00044 Edge *father; 00045 bool visited; 00046 }; 00047 00048 class Contribution 00049 { 00050 public: 00051 Vertex *v; 00052 float a; 00053 }; 00054 00055 class SolverSolution : public Solution 00056 { 00057 public: 00058 Unification *unification; 00059 VariableSolution *variableSolution; 00060 unsigned int ndvar; 00061 bool success; 00062 void display(ostream &o); 00063 bool check(); 00064 }; 00065 00066 class Graph 00067 { 00068 public: 00069 SolverSolution *solus; 00070 Unification *unification; 00071 bool success; 00072 list<Vertex*> vertexs; 00073 list<Edge*> edges; 00074 Graph(Node* node,Unification *unification); 00075 bool explo(Node* n); 00076 SolverSolution *run(); 00077 ~Graph(); 00078 bool seekCycle(list<Vertex*> &ver,list<Edge*> &ed); 00079 void resetVisited(); 00080 void print(); 00081 00082 Vertex* addVertex(int id); 00083 Edge* addEdge(Vertex *v1,Vertex *v2,int a,int b); 00084 }; 00085 00086 }; 00087 00088 #endif 00089