编译出来了

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 <stdio.h>
int main()
{
graphVertex<int,std::string> gv;
printf("OK");
return 0;
}

View file

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

View file

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