00001
00002
00003
00004
00005
00006
00007
00008
00025 #ifndef IDGRAPH_H_
00026 #define IDGRAPH_H_
00027
00028 #include <iostream>
00029 #include <vector>
00030 #include <list>
00031 #include <map>
00032 #include <set>
00033 #include <string>
00034 #include <sstream>
00035 #include "include/CosiGlobal.h"
00036
00037 using namespace std;
00038
00039 namespace cosi {
00040
00041 typedef int Vertex;
00042
00043 class Edge {
00044 public:
00045 Edge() {
00046 }
00047 ;
00048 Edge(int pU, int pV);
00049 ~Edge();
00050 void U(int pU);
00051 int U() const;
00052 void V(int pV);
00053 int V() const;
00054 bool operator==(const Edge &pE) const;
00055 bool operator<(const Edge &pE) const;
00056 friend std::ostream& operator<<(std::ostream &pOs, const Edge &pE);
00057 private:
00058 int mU, mV;
00059 };
00060
00061 class IdGraph {
00062 public:
00063
00065 IdGraph(string Name);
00066
00068 virtual ~IdGraph();
00069
00071 int InDegree(int r);
00072
00074 int OutDegree(int r);
00075
00077 int Ns();
00078
00080 int Nd();
00081
00083 int Nr();
00084
00085 Vertex AddVertex();
00086
00088 void AddVertex(int Id);
00089
00091 void DeleteVertex(int Id);
00092
00094 bool InV(int V);
00095
00097 bool InE(int i, int j);
00098
00100 bool InE(Edge pE);
00101
00103 void AddEdge(int i, int j);
00104
00106 void AddEdge(Edge pE);
00107
00109 void DeleteEdge(int i, int j);
00110
00111 void DeleteEdge(Edge pE);
00112
00114 int Order();
00115
00117 int Size();
00118
00119 void Rename(int id1, int id2);
00120
00121 typedef list<int>::iterator list_iterator;
00122 typedef set<int>::iterator v_iterator;
00123
00126 list_iterator in_begin(int V);
00129 list_iterator in_end(int V);
00132 list_iterator out_begin(int V);
00135 list_iterator out_end(int V);
00137 v_iterator s_begin();
00139 v_iterator s_end();
00141 v_iterator d_begin();
00143 v_iterator d_end();
00145 v_iterator r_begin();
00147 v_iterator r_end();
00148
00150 v_iterator v_begin();
00152 v_iterator v_end();
00153
00155 string GetName() const;
00156
00158 void SetName(string pName);
00159
00161 void SetName(int V, string pName);
00162
00164 void SetName(int U, int V, string pName);
00165
00166 void SetName(Edge pE, string pName);
00167
00169 string GetName(int V);
00170
00172 string GetName(int U, int V);
00173
00174 string GetName(Edge pE);
00175
00176 int GetId(string Name ) ;
00177
00178
00179 virtual string Print();
00180
00181 virtual string PrintNode(int V);
00182
00183 virtual string PrintEdge(int U, int V);
00184
00185 virtual string PrintEdge(Edge pE);
00186
00187 int GetLastId();
00188
00189 private:
00190
00191 void UpdateVertex(int V);
00193 map< int , list<int> > mAdjList;
00195 map< int , list<int> > mRadjList;
00197 set< int > mS;
00199 set< int > mD;
00201 set< int > mR;
00203 set<int> mV;
00205 int mSize;
00207 string mName;
00208
00209 map< int , string > mNodeName;
00210 map< pair<int,int> , string > mEdgeName;
00211 map< string , int > mNodeId;
00212 map< string , pair<int,int> > mEdgeIdPair;
00213
00214 int mLastId;
00215
00216 };
00217 }
00218 #endif