This commit is contained in:
iridiumR 2021-12-09 23:22:41 +08:00
parent e7df0cbfcf
commit d4c6ba0eb9
3 changed files with 67 additions and 4 deletions

View file

@ -1,8 +1,41 @@
#include "graph.hpp"
#include <iostream>
#include <stdio.h>
int main()
{
graphVertex<int,std::string> gv;
printf("OK");
graphVertex<int, std::string> gv;
int op, id1, id2, w;
std::string name;
while (1)
{
printf("选择操作:1添加节点2添加边3删除节点4删除边\n");
scanf("%d", &op);
switch (op)
{
case 1:
printf("分别输入序号 节点名:");
std::cin >> id1 >> name;
gv.insect(id1, name);
break;
case 2:
printf("分别输入起始节点序号 到达节点序号 边权重:");
std::cin >> id1 >> id2 >> w;
gv.link(id1, id2, w);
break;
case 3:
printf("输入节点序号:");
std::cin >> id1;
break;
case 4:
printf("分别输入起始节点序号 到达节点序号:");
std::cin >> id1 >> id2;
gv.unlink(id1, id2);
break;
default:
break;
}
}
return 0;
}

View file

@ -136,7 +136,7 @@ public:
// -1 顶点不存在
// -2 边不存在
// 0 成功
virtual int unlink(int id1, int id2, int w)
virtual int unlink(int id1, int id2)
{
if (V[id1] == NULL || V[id2] == NULL)
return -1;

View file

@ -14,7 +14,37 @@
"stdexcept": "cpp",
"streambuf": "cpp",
"istream": "cpp",
"array": "cpp"
"array": "cpp",
"atomic": "cpp",
"cctype": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"deque": "cpp",
"unordered_map": "cpp",
"vector": "cpp",
"exception": "cpp",
"algorithm": "cpp",
"memory": "cpp",
"memory_resource": "cpp",
"optional": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"fstream": "cpp",
"initializer_list": "cpp",
"iosfwd": "cpp",
"limits": "cpp",
"new": "cpp",
"ostream": "cpp",
"typeinfo": "cpp"
}
}
}