亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? algraph.cpp

?? 全國交通咨詢系統源代碼
?? CPP
字號:
// ALGraph.cpp: implementation of the ALGraph class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "map.h"
#include "ALGraph.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////


ALGraph::ALGraph():m_arcnum(0),m_vexnum(0),ID(5555)
{
	m_nowtime=0;
	isformed=NULL;
	m_tatol=0;
}

ALGraph::~ALGraph()
{
	if(isformed!=NULL) delete[] isformed;

}

bool ALGraph::InsertCity(CString cityname)
{
	if(CityLocal(cityname)) return false;
	m_vertices.SetSize(m_vertices.GetSize()+1);
	m_vertices[m_vertices.GetUpperBound()].GetCityName()=cityname;
	m_vexnum++;
	return true;
}

bool ALGraph::CityLocal(CString cityname)
{
	if(m_vertices.GetUpperBound()==-1) return false; 
	for(int i=0;i<=m_vertices.GetUpperBound();i++)
	{
		if(m_vertices[i].GetCityName()==cityname) return true;
	}
	return false;
}

bool ALGraph::InsertCity(CString city1,CString city2,InfoNode cityinfo)
{
	int pos1=-1,pos2=-1;
	POSITION temp1(NULL),temp2(NULL);
	if(!(CityLocal(city1,pos1)&&CityLocal(city2,pos2))) return false;
	cityinfo.GetCityNum()=pos2;
	CList<InfoNode,InfoNode &> & plist1=m_vertices[pos1].GetList();
	temp1=plist1.Find(cityinfo,temp1);
	if(temp1!=NULL) return false;
	plist1.AddTail(cityinfo);
	cityinfo.GetCityNum()=pos1;
	CList<InfoNode,InfoNode &> & plist2=m_vertices[pos2].GetList();
	plist2.AddTail(cityinfo);
	m_arcnum+=2;
	return true;
}

bool ALGraph::CityLocal(CString cityname, int & j)
{
	if(m_vertices.GetUpperBound()==-1) return false; 
	for(int i=0;i<=m_vertices.GetUpperBound();i++)
	{
		if(m_vertices[i].GetCityName()==cityname) {j=i;return true;}
	}
	return false;
}

bool ALGraph::DeleteCity(CString cityname)
{
	int pos=-1;
	int num=0;
	if(!CityLocal(cityname,pos)) return false;
	num=m_vertices[pos].GetList().GetCount();
	if(num!=0)
		for(int i=0;i<=m_vertices.GetUpperBound();i++)
		{
			POSITION tip;
			if(pos==i) continue;
			CList<InfoNode,InfoNode &> & plist=m_vertices[i].GetList();
			tip=plist.GetHeadPosition();
			while(tip==NULL)
			{
				if(pos==plist.GetAt(tip).GetCityNum()) 
				{plist.RemoveAt(tip);m_arcnum-=2;break;}
				plist.GetNext(tip);
			}
		}
	 m_vertices.RemoveAt(pos);
	 m_vexnum--;
	 return true;
}

	





bool ALGraph::DeleteCity(CString city1, CString city2)
{
	int i=-1,j=-1;
	if(!(CityLocal(city1,i)&&CityLocal(city2,j))) return false;
	bool temp=false;
	POSITION tp1,tp2;
	CList<InfoNode,InfoNode &> & plist1=m_vertices[i].GetList();
	CList<InfoNode,InfoNode &> & plist2=m_vertices[j].GetList();
	tp1=plist1.GetHeadPosition();
	while(tp1!=NULL)
	{
		if(plist1.GetAt(tp1).GetCityNum()==j)
		{
			POSITION temppos=tp1;
			plist1.GetNext(temppos);
			plist1.RemoveAt(tp1);
			temp=true;
			tp1=temppos;
		}
		else plist1.GetNext(tp1);
	}
	if(temp) 
	{
		for(tp2=plist2.GetHeadPosition();tp2!=NULL;)
		{
			if(plist2.GetAt(tp2).GetCityNum()==i)
			{
				POSITION temppos=tp2;
				plist2.GetNext(temppos);
				plist2.RemoveAt(tp2);
				tp2=temppos;
			}
			else plist2.GetNext(tp2);
		}
	m_arcnum-=2;
	}
	else return false;
	return true;
}

bool ALGraph::EditArc(CString city1, CString city2, InfoNode cityinfo)
{
	int num1=-1,num2=-1;
	if(!(CityLocal(city1,num1)&&CityLocal(city2,num2))) return false;
	POSITION tp;
	bool temp=false;
	for(tp=m_vertices[num1].GetList().GetHeadPosition();tp!=NULL;m_vertices[num1].GetList().GetNext(tp))
	{
		InfoNode &ptoinfo=m_vertices[num1].GetList().GetAt(tp);
		if(num2==ptoinfo.GetCityNum())
		{
			temp=true;
			ptoinfo.GetCar()=cityinfo.GetCar();
			ptoinfo.GetDistance()=cityinfo.GetDistance();
			ptoinfo.GetPlain()=cityinfo.GetPlain();
			ptoinfo.GetTrain()=cityinfo.GetTrain();
		}
	}
	if(!temp) return false;
	for(tp=m_vertices[num2].GetList().GetHeadPosition();tp!=NULL;m_vertices[num2].GetList().GetNext(tp))
	{
		InfoNode &ptoinfo=m_vertices[num2].GetList().GetAt(tp);
		if(num1==ptoinfo.GetCityNum())
		{
			ptoinfo.GetCar()=cityinfo.GetCar();
			ptoinfo.GetDistance()=cityinfo.GetDistance();
			ptoinfo.GetPlain()=cityinfo.GetPlain();
			ptoinfo.GetTrain()=cityinfo.GetTrain();
		}
	}
	return true;
}

InfoNode ALGraph::CreatInofNode(Info car, Info plain, Info train,int distance,int citynum)
{
	InfoNode temp;
	temp.GetCityNum()=citynum;
	temp.GetDistance()=distance;
	temp.GetCar()=car;
	temp.GetPlain()=plain;
	temp.GetTrain()=train;
	return temp;
}	

Info ALGraph::CreatInfo(int fee, int time, int timespend)
{
	Info temp;
	temp.SetFee(fee);
	temp.SetTime(time);
	temp.SetTimeSpend(timespend);
	return temp;

}

//DEL bool ALGraph::SaveALGraph(CStdioFile & temp)
//DEL {
//DEL 	CFileStatus status;
//DEL 	if(!temp.GetStatus(status)) return false;
//DEL 	if(temp.GetLength()!=0) return false;
//DEL 	temp.Write(&ID,sizeof(UINT));
//DEL 	temp.Write(&m_vexnum,sizeof(int));
//DEL 	temp.Write(&m_arcnum,sizeof(int));
//DEL 	for(int i=0;i<m_vexnum;i++)
//DEL 	{
//DEL 		int arc=-1;
//DEL 		ArrayElem & array=m_vertices[i];
//DEL 		temp.WriteString(array.GetCityName());
//DEL 		CList<InfoNode,InfoNode &> &list=array.GetList();
//DEL 		arc=list.GetCount();
//DEL 		temp.Write(&arc,sizeof(int));
//DEL 		POSITION pos;
//DEL 		if((pos=list.GetHeadPosition())==NULL) continue;
//DEL 		do{
//DEL 			InfoNode &node=list.GetAt(pos);
//DEL 			temp.Write(&node.GetCityNum(),sizeof(int));
//DEL 			temp.Write(&node.GetDistance(),sizeof(int));
//DEL 			node.GetCar()>>temp;
//DEL 			node.GetPlain()>>temp;
//DEL 			node.GetTrain()>>temp;
//DEL 			list.GetNext(pos);
//DEL 		}while(pos!=NULL);
//DEL 	}
//DEL 	return true;
//DEL }

//DEL bool ALGraph::OpenALGraph(CStdioFile & temp)
//DEL {
//DEL 	
//DEL 	UINT tip=0;
//DEL 	temp.Read(&tip,sizeof(UINT));
//DEL 	if(tip!=55555) return false;
//DEL 	temp.Read(&m_vexnum,sizeof(int));
//DEL 	temp.Read(&m_arcnum,sizeof(int));
//DEL 	for(int i=0;i<m_vexnum;i++)
//DEL 	{
//DEL 		int listnum=-1;
//DEL 		ArrayElem array;
//DEL 		temp.ReadString(array.GetCityName());
//DEL 		CList<InfoNode,InfoNode &> &list=array.GetList();
//DEL 		temp.Read(&listnum,sizeof(int));
//DEL 		for(int j=1;j<=listnum;j++)
//DEL 		{
//DEL 			InfoNode node;
//DEL 			temp.Read(&node.GetCityNum(),sizeof(int));
//DEL 			temp.Read(&node.GetDistance(),sizeof(int));
//DEL 			node.GetCar()<<temp;
//DEL 			node.GetPlain()<<temp;
//DEL 			node.GetTrain()<<temp;
//DEL 			list.AddTail(node);
//DEL 		}
//DEL 		m_vertices.Add(array);		
//DEL 	}
//DEL 	return true;
//DEL }

ALGraph::ALGraph(const ALGraph & temp)
{
	int num=-1;
	ID=temp.ID;
	m_arcnum=temp.m_arcnum;
	m_vexnum=temp.m_vexnum;
	num=temp.m_vertices.GetSize();
	m_vertices.SetSize(num);
	for(int i=0;i<num;i++) m_vertices[i]=temp.m_vertices[i];
}

ALGraph & ALGraph::operator =(ALGraph & temp)
{
	int num=-1;
	ID=temp.ID;
	m_arcnum=temp.m_arcnum;
	m_vexnum=temp.m_vexnum;
	num=temp.m_vertices.GetSize();
	m_vertices.SetSize(num);
	for(int i=0;i<num;i++) m_vertices[i]=temp.m_vertices[i];
	return *this;
}

void ALGraph::Serialize(CArchive &archive)
{
//	CObject::Serialize(archive);
	if(archive.IsStoring())
	{
		archive<<ID<<m_arcnum<<m_vexnum;
		for(int i=0;i<m_vexnum;i++) m_vertices[i].Serialize(archive);
	}
    else
	{
        archive>>ID>>m_arcnum>>m_vexnum;
		if(m_vexnum!=0) m_vertices.SetSize(m_vexnum);
		for(int i=0;i<m_vexnum;i++) m_vertices[i].Serialize(archive);
	}
}

//DEL int ALGraph::MatrixToInt(int, int)
//DEL {
//DEL 
//DEL }

int ALGraph::MatrixToInt(int num1, int num2)
{
	if(num1<0||num2<0) return(-1);
	return(num1*m_vexnum+num2);
}

void ALGraph::GetMGraph(int kind)//1代表距離
//2代表汽車費用,3代表汽車耗時,4代表汽車到達時刻
//5代表飛機費用,6代表飛機耗時,7代表飛機到達時刻
//8代表火車費用,9代表火車耗時,10代表火車到達時刻
{
	if(m_vexnum<=0) return;
	int *matrix=new int[m_vexnum*m_vexnum];
	for(int j=0;j<m_vexnum*m_vexnum;j++) matrix[j]=0;
	for(int i=0;i<m_vexnum;i++)
	{
		CList<InfoNode,InfoNode &> &list=m_vertices[i].GetList();
		POSITION pos;
		pos=list.GetHeadPosition();
		while(pos!=NULL)
		{
			InfoNode &temp=list.GetAt(pos);
			switch(kind)
			{
			case 1:
				{
					matrix[MatrixToInt(i,temp.GetCityNum())]=temp.GetDistance();
					break;
				}
			case 2:
				{
					matrix[MatrixToInt(i,temp.GetCityNum())]=temp.GetCar().GetFee();
					break;
				}
			case 3:
				{
					matrix[MatrixToInt(i,temp.GetCityNum())]=temp.GetCar().GetTimeSpend();
					break;
				}
			case 4:
				{
					break;
				}
			case 5:
				{
					matrix[MatrixToInt(i,temp.GetCityNum())]=temp.GetPlain().GetFee();
					break;
				}
			case 6:
				{
					matrix[MatrixToInt(i,temp.GetCityNum())]=temp.GetPlain().GetTimeSpend();
					break;
				}
			case 7:
				{
					break;
				}
			case 8:
				{
					matrix[MatrixToInt(i,temp.GetCityNum())]=temp.GetTrain().GetFee();
					break;
				}
			case 9:
				{
					matrix[MatrixToInt(i,temp.GetCityNum())]=temp.GetTrain().GetTimeSpend();
					break;
				}
			case 10:
				{
					break;
				}
			default:
				{
					isformed=NULL;
					return;
				}
			}
			list.GetNext(pos);
		}
	}
	isformed=matrix;
}

int * ALGraph::GetVector()
{
	int * temp=new int[m_vexnum];
	return temp;
}

bool ALGraph::ShortestPath(const int v, const int e,CList<int,int &> & list,int kind)
{
	if(isformed!=NULL) {delete[] isformed;isformed=NULL;}
	GetMGraph(kind);
	const int MAXNUM=2147483647;
	int fail=-10;
	if(isformed==NULL||v==e) {list.AddHead(fail);return false;}
	for(int i=0;i<m_vexnum*m_vexnum;i++) 
	{
		if(isformed[i]==0) 
			isformed[i]=MAXNUM;
	}
	int * dist=GetVector();
	int * path=GetVector();
	int * S=GetVector();
	for(i=0;i<m_vexnum;i++) path[i]=-1;
	for(i=0;i<m_vexnum;i++)
	{
		dist[i]=isformed[MatrixToInt(v,i)];
		S[i]=0;
		if(i!=v&&dist[i]<MAXNUM) path[i]=v;
		else path[i]=-1;
	}
	S[v]=1;dist[v]=0;
	for(i=0;i<m_vexnum-1;i++)
	{
		int min=MAXNUM;int u=v;
		for(int j=0;j<m_vexnum;j++)
		{
			if(!S[j]&&dist[j]<min)
			{
				u=j;
				min=dist[j];
			}
		}
		S[u]=1;
		for(int w=0;w<m_vexnum;w++)
		{
			if(!S[w]&&isformed[MatrixToInt(u,w)]<MAXNUM&&dist[u]+isformed[MatrixToInt(u,w)]<dist[w])
			{
				dist[w]=dist[u]+isformed[MatrixToInt(u,w)];
				path[w]=u;
			}
		}
	}
	i=e;
	list.AddHead(i);
	bool tip=false;
	do
	{
		i=path[i];
		list.AddHead(i);
		if(i==v) {tip=true;break;}
	}while(i!=-1);
	if(!tip) {list.RemoveAll();list.AddHead(fail);return false;}
	m_tatol=dist[e];
	delete[] dist;
	delete[] path;
	delete[] S;
	return true;
}


BOOL ALGraph::SeekShort(CString cityfirst, CString citysecond, CString & result,int kind)
{
	int v=-1,e=-1;
	if(!CityLocal(cityfirst,v)) return false;
	if(!CityLocal(citysecond,e)) return false;
	CList<int,int &> resultlist;
	if(!ShortestPath(v,e,resultlist,kind)) return false;
	const CString tip="##";
	int num=resultlist.GetCount();
	if(num==0) return false;
	POSITION pos;
	pos=resultlist.GetHeadPosition();
	result=_T("");
	while(pos!=NULL) result=result+tip+m_vertices[resultlist.GetNext(pos)].GetCityName();
	CString uite;
	MakeString(kind,uite);
	CString uites;
	uites="總共";
	uites.Format("%d",m_tatol);
	uites=uites+uite;
	result=result+tip+uites;//需要修改
	return true;
}

void ALGraph::MakeString(const int kind,CString & temp)
{
//2代表汽車費用,3代表汽車耗時,4代表汽車到達時刻
//5代表飛機費用,6代表飛機耗時,7代表飛機到達時刻
//8代表火車費用,9代表火車耗時,10代表火車到達時刻
	switch(kind)
	{
	case 1:
		{
			temp="公里";
			break;
		}
	case 5:
	case 8:
	case 2:
		{
			temp="元";
			break;
		}
	case 6:
	case 9:
	case 3:
		{
			temp="分";
			break;
		}
	case 10:
	case 7:
	case 4:
		{
			temp="分";
			break;
		}
	default:
		break;
	}
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩精品电影在线观看| 91福利在线免费观看| 欧美亚洲动漫制服丝袜| 国产婷婷色一区二区三区在线| 亚洲精品视频在线观看网站| 国产电影精品久久禁18| 日韩欧美高清dvd碟片| 亚洲一区二区三区爽爽爽爽爽| 成人美女视频在线观看18| 日韩欧美一区二区久久婷婷| 亚洲电影中文字幕在线观看| 99在线精品视频| 中文字幕的久久| 国内外精品视频| 日韩欧美亚洲另类制服综合在线| 一区二区不卡在线播放 | 欧美日韩国产影片| 日本一区二区久久| 成人在线综合网站| 国产欧美综合在线| 国产乱码精品1区2区3区| 精品少妇一区二区三区| 蜜桃av噜噜一区二区三区小说| 欧美日韩国产综合一区二区三区 | 国产精品久久一卡二卡| 国产一区二区三区蝌蚪| 久久婷婷国产综合国色天香 | 亚洲va欧美va国产va天堂影院| 不卡的电视剧免费网站有什么| 国产偷国产偷精品高清尤物 | 综合电影一区二区三区| 99久久综合狠狠综合久久| 国产精品毛片久久久久久| av中文字幕不卡| 亚洲视频一区在线| 在线亚洲欧美专区二区| 亚洲大尺度视频在线观看| 欧美亚洲禁片免费| 天天色图综合网| 日韩欧美国产成人一区二区| 国产专区综合网| 欧美激情综合五月色丁香小说| www.亚洲在线| 一区二区三区四区高清精品免费观看| 欧美性色黄大片| 蜜桃视频一区二区三区在线观看 | 成人免费观看男女羞羞视频| 中文字幕日韩一区二区| 欧美在线看片a免费观看| 亚洲地区一二三色| 精品电影一区二区三区 | 国产精品亚洲第一区在线暖暖韩国| 久久久久久亚洲综合影院红桃| 成人晚上爱看视频| 亚洲午夜激情av| 精品国内二区三区| 99这里只有精品| 日韩精品国产欧美| 中文成人综合网| 欧美精品久久99| 国产成人综合在线观看| 一区二区三区波多野结衣在线观看| 日韩一区二区三区视频| 国产白丝网站精品污在线入口 | 中文字幕精品在线不卡| 欧美在线制服丝袜| 国产精品一色哟哟哟| 亚洲一区免费在线观看| 久久精品综合网| 在线观看网站黄不卡| 国产精品一级黄| 日韩高清在线一区| 国产精品久久久久久久第一福利| 欧美精品第1页| 99国产精品99久久久久久| 久久成人免费网站| 亚洲欧美福利一区二区| 久久综合99re88久久爱| 色吊一区二区三区| www.亚洲激情.com| 经典三级一区二区| 婷婷久久综合九色综合伊人色| 国产精品国产精品国产专区不片| 欧美一级精品在线| 欧美日韩黄视频| 色拍拍在线精品视频8848| 国产一区二区三区四区五区入口 | 日韩精品在线看片z| 色先锋aa成人| av在线不卡免费看| 国产在线乱码一区二区三区| 五月激情六月综合| 亚洲一区在线电影| 中文字幕一区二区在线播放| 久久久一区二区三区捆绑**| 欧美一级高清片| 欧美高清视频一二三区| 精品视频一区二区三区免费| 97久久超碰国产精品| 成人黄色小视频| 成人午夜又粗又硬又大| 国产美女av一区二区三区| 久久se精品一区二区| 日韩精品乱码免费| 日本不卡123| 天天av天天翘天天综合网 | 国产尤物一区二区| 久久99这里只有精品| 蜜桃av一区二区在线观看| 免费人成在线不卡| 秋霞成人午夜伦在线观看| 午夜精品久久久久久不卡8050 | 亚洲另类色综合网站| 17c精品麻豆一区二区免费| 中文字幕不卡的av| 国产精品少妇自拍| 亚洲免费高清视频在线| 亚洲黄色片在线观看| 亚洲尤物视频在线| 天天免费综合色| 看片的网站亚洲| 国产高清在线精品| 成人免费视频视频在线观看免费 | 国产一区二区91| 国产成人精品一区二区三区四区 | 日本aⅴ亚洲精品中文乱码| 免费成人你懂的| 国产精品亚洲一区二区三区妖精 | 91精品国产美女浴室洗澡无遮挡| 91精品国产乱码久久蜜臀| 精品久久久久久久久久久久包黑料 | 成人v精品蜜桃久久一区| av成人动漫在线观看| 91国偷自产一区二区开放时间 | 久久日一线二线三线suv| 国产亚洲精品超碰| 国产精品久久久久一区二区三区| 日韩毛片精品高清免费| 一区二区三区电影在线播| 琪琪一区二区三区| 成人深夜福利app| 欧美日韩在线不卡| 精品国产凹凸成av人网站| 国产精品久久网站| 日韩激情在线观看| 成人美女在线观看| 88在线观看91蜜桃国自产| 久久精品夜夜夜夜久久| 亚洲一区二区在线免费看| 国内成人免费视频| 欧美伊人久久大香线蕉综合69| 欧美xxxxx裸体时装秀| 亚洲欧洲日韩一区二区三区| 日本美女一区二区| 91免费视频大全| 日韩欧美国产精品| 一区二区久久久久| 国精品**一区二区三区在线蜜桃| 色婷婷亚洲综合| 国产亚洲欧美日韩俺去了| 天堂资源在线中文精品| 99久久国产免费看| 久久久精品人体av艺术| 亚洲国产精品一区二区www在线| 国产麻豆精品久久一二三| 911精品产国品一二三产区 | 欧美精彩视频一区二区三区| 午夜伊人狠狠久久| 一本大道久久a久久综合| 久久青草国产手机看片福利盒子| 亚洲国产精品久久久久婷婷884| 高清国产午夜精品久久久久久| 91麻豆精品国产91久久久久久久久| 中文字幕一区二区三区乱码在线 | 亚洲国产精品成人久久综合一区| 无码av免费一区二区三区试看 | 色呦呦网站一区| 国产精品久久久久久久岛一牛影视 | 午夜久久久久久| 91久久精品网| 中文字幕中文字幕一区二区| 极品少妇xxxx精品少妇偷拍 | 在线国产亚洲欧美| 国产精品国产三级国产有无不卡 | 日av在线不卡| 欧美男女性生活在线直播观看| 亚洲精品伦理在线| 91丝袜高跟美女视频| 国产精品久久久久久久久免费桃花| 国产在线精品国自产拍免费| 精品久久久三级丝袜| 久久成人免费电影| 久久先锋影音av| 国产精品资源网| 久久久久国产成人精品亚洲午夜| 国产一区二区在线免费观看| 久久综合色婷婷| 国产福利精品导航| 国产精品久久久久影院老司 | 国产乱码字幕精品高清av|