graph.cpp

来自「在人脸检测的基础之上,对嘴部的运动表情进行分析,进行语音模拟.」· C++ 代码 · 共 74 行

CPP
74
字号
#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 + =
减小字号Ctrl + -
显示快捷键?