41 lines
No EOL
1 KiB
C++
41 lines
No EOL
1 KiB
C++
#include "graph.hpp"
|
|
#include <iostream>
|
|
#include <stdio.h>
|
|
|
|
int main()
|
|
{
|
|
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;
|
|
} |