差不多得了

This commit is contained in:
iridiumR 2021-12-10 17:08:32 +08:00
parent edd925d4fc
commit 6401fadc58
2 changed files with 24 additions and 0 deletions

View file

@ -26,6 +26,8 @@ int main()
case 2: case 2:
printf("分别输入起始节点序号 到达节点序号 边权重:"); printf("分别输入起始节点序号 到达节点序号 边权重:");
std::cin >> id1 >> id2 >> w; std::cin >> id1 >> id2 >> w;
if(id1==id2)
printf("失败\n");
switch (gv.link(id1, id2, w)) switch (gv.link(id1, id2, w))
{ {
case 0: case 0:

View file

@ -4,6 +4,7 @@
#include <iomanip> #include <iomanip>
#include <iostream> #include <iostream>
#include <string> #include <string>
#include "../ex10/queue.hpp"
template <class Te> template <class Te>
@ -187,6 +188,27 @@ public:
printf("\n"); printf("\n");
} }
} }
virtual void BFS(int id)
{
Queue<int> q;
q.enqueue(id);
while (!q.empty())
{
int vid = q.dequeue();
for (int j = 0; j < 100;j++)
{
if(E[id][j]!=NULL)
q.enqueue(j);
}
// std::cout << node->pos;
printf("ID: %d",q.dequeue());
}
}
}; };
#endif #endif