😭
This commit is contained in:
+10
-6
@@ -69,16 +69,18 @@ public:
|
||||
throw SameNodeConnectException("禁止连接图中的同一个点",0x001);
|
||||
}
|
||||
node *current = nodes.at(id1);
|
||||
int current_id = 0;
|
||||
//跳过id节点和值节点
|
||||
for(int i=0;i<2;i++) {
|
||||
current = current->next;
|
||||
}
|
||||
while(current->next!=NULL) {
|
||||
if((current->next->data==id2)&&(current_id>1)) {
|
||||
if(current->next->data==id2) {
|
||||
if (current->next->weight==weight) {
|
||||
throw InsertExistedConnectException("禁止插入已存在的连接",0x003);
|
||||
}
|
||||
current->next->weight=weight;
|
||||
}
|
||||
current = current->next;
|
||||
current_id++;
|
||||
}
|
||||
current->next=new node();
|
||||
current->next->data=id2;
|
||||
@@ -87,16 +89,18 @@ public:
|
||||
|
||||
if (!flag) {
|
||||
node *current2 = nodes.at(id2);
|
||||
int current2_id = 0;
|
||||
//跳过id节点和值节点
|
||||
for(int i=0;i<2;i++) {
|
||||
current = current->next;
|
||||
}
|
||||
while(current2->next!=NULL) {
|
||||
if((current2->next->data==id2)&&(current2_id>1)) {
|
||||
if((current2->next->data==id2)) {
|
||||
if (current2->next->weight==weight) {
|
||||
throw InsertExistedConnectException("禁止插入已存在的连接",0x003);
|
||||
}
|
||||
current2->next->weight=weight;
|
||||
}
|
||||
current2 = current2->next;
|
||||
current2_id++;
|
||||
}
|
||||
current2->next=new node();
|
||||
current2->next->data=id1;
|
||||
|
||||
Reference in New Issue
Block a user