📄 graph.cpp
字号:
#include "Graph.h"
BOOL Create_Active_List(struct Active_List_elem* min_cost,struct Graph_elem &first)
{
min_cost=new Active_List_elem;
min_cost->not_expanded=first;
return true;
}
BOOL Add_Active_List(struct Active_List_elem* min_cost,struct Graph_elem *newListElem)
{
struct Active_List_elem *prev,*current;
double cost=newListElem->cumul_cost;
BOOL Is_Added=false;
struct Active_List_elem* temp=new Active_List_elem;
temp->not_expanded=newListElem;
if((min_cost->not_expanded->cumul_cost)<cost)
{
temp->down=min_cost;
min_cost=temp;
Is_Added=true;
}
else if((min_cost->not_expanded->cumul_cost)==cost)
{
temp->left=min_cost;
temp->down=min_cost->down;
min_cost->down=NULL;
min_cost=temp;
Is_Added=true;
}
prev=min_cost;
current=min_cost->down;
while((current!=NULL)&&(Is_Added==false))
{
if((current->not_expanded->cumul_cost)<cost)
{
temp->down=current;
prev->down=temp;
Is_Added=true;
}
else if((current->not_expanded->cumul_cost)==cost)
{
temp->left=current;
temp->down=current->down;
current->down=NULL;
prev->down=temp;
Is_Added=true;
}
prev=current;
current=current->down;
}
if(Is_Added==false)
{
prev->down=temp;
temp->left=NULL;
temp->down=NULL;
Is_Added=true;
}
return Is_Added;
}
/*BOOL Remove_Active_List(struct Active_List_elem* min_cost,struct Graph_elem *newListElem)
{
}*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -