编译出来了

This commit is contained in:
iridiumR 2021-12-09 23:04:48 +08:00
parent 13577eb681
commit e7df0cbfcf
3 changed files with 13 additions and 11 deletions

View file

@ -1,7 +1,8 @@
#include "graph.hpp" #include "graph.hpp"
#include <stdio.h>
int main() int main()
{ {
graphVertex<int,std::string> gv; graphVertex<int,std::string> gv;
printf("OK");
return 0; return 0;
} }

View file

@ -72,7 +72,7 @@ public:
for (int j = 0; j < n; j++) for (int j = 0; j < n; j++)
delete V[j]; delete V[j];
} }
virtual Tv Vertex(int i) virtual Tv vertex(int i)
{ {
return V[i]->data; return V[i]->data;
} }
@ -88,7 +88,8 @@ public:
{ {
if (V[id] == NULL) if (V[id] == NULL)
{ {
V[id] = new ::Vertex<Tv>(value); Vertex<Tv>* temp= new Vertex<Tv>(value);
V.put(id, temp);
// E[id] = new Vector<Edge<Te>>; // E[id] = new Vector<Edge<Te>>;
} }
else else
@ -103,14 +104,14 @@ public:
if (E[id][j] != NULL) if (E[id][j] != NULL)
{ {
delete E[id][j]; delete E[id][j];
E[id][j] = NULL; E[id].put(j,NULL);
V[j]->inDegree--; V[j]->inDegree--;
} }
} }
v--; v--;
Tv temp = Vertex(id); Tv temp = vertex(id);
delete V[id]; delete V[id];
V[id] = NULL; V.put(id, NULL);
} }
// id1->id2 进行连接 // id1->id2 进行连接
@ -126,8 +127,8 @@ public:
return -2; return -2;
V[id1]->outDegree++; V[id1]->outDegree++;
V[id2]->inDegree++; V[id2]->inDegree++;
Edge<Te>* temp=new Edge<Te>(w);
E[id1][id2] = new Edge<Te>(w); E[id1].put(id2, temp);
return 0; return 0;
} }
// 解除 id1->id2 连接 // 解除 id1->id2 连接

View file

@ -6,7 +6,7 @@
template <class T> template <class T>
class Vector class Vector
{ {
public: private:
T *_v; T *_v;
int _len; int _len;
int _used; int _used;
@ -16,7 +16,7 @@ public:
void shrink(); void shrink();
void adjust(); void adjust();
public:
Vector(int len) Vector(int len)
{ {
_used = 0; _used = 0;
@ -84,7 +84,7 @@ template <class T>
void Vector<T>::put(int a, T value) void Vector<T>::put(int a, T value)
{ {
while (i >= _len) while (a >= _len)
{ {
expand(); expand();
} }