-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTopo_DeleteLine.cpp
More file actions
31 lines (28 loc) · 996 Bytes
/
Topo_DeleteLine.cpp
File metadata and controls
31 lines (28 loc) · 996 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include"Topo.h"
#include<iostream>
extern bool IPcmp(int *ip1,int *ip2);
bool Topo::DeleteLine(int *IP1,int *IP2){
cout << "LiuChangHai" << endl;
Table* ptr1 = head;
Table* ptr2 = head;
for(ptr1 = head;ptr1 != nullptr;ptr1 = ptr1->next) //找路由器结点
if(IPcmp(IP1,ptr1->data->RouterIP))
break;
for(ptr2 = head;ptr2 != nullptr;ptr2 = ptr2->next) //找路由器结点
if(IPcmp(IP2,ptr2->data->RouterIP))
break;
// cout << "ptr1->data->RouterIP[0]"<<ptr1->data->RouterIP[0] << endl;
// cout <<"ptr2->data->RouterIP[0]"<< ptr2->data->RouterIP[0] << endl;
if(ptr1 != nullptr && ptr2 != nullptr)
{
// cout<<"***************"<<IP2[0]<<endl;
if(!ptr1->data->DeleteLine(ptr2->data->RouterIP)) //删除边
return false;
if(!ptr2->data->DeleteLine(ptr1->data->RouterIP))
return false;
reRTable(); //重构路由表
return true;
}
else
return false;
}