⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test.cpp

📁 一个求无向无权图的最短路径的算法
💻 CPP
字号:
#include <iostream.h>
#include <iomanip.h>
#include <stdlib.h>
#define maxsize 1000
#define maxvertices 100
#define maxweight 10000
#include "g_graph.h"
#include "b_search.h"
void main()
{
	int n=13;
	char a[]={'A','B','C','D','F','L','M','O','P','R','S','T','Z'};
	rcw arr_rcw[]={{0,10,1},{0,11,1},{0,12,1},{1,4,1},{1,8,1},{2,8,1},
				{2,9,1},{3,6,1},{3,9,1},{4,10,1},{5,6,1},{5,11,1},
				{7,10,1},{7,12,1},{8,10,1},{9,10,1}};
				
	int e=16;
	b_search b_sea(a,n,arr_rcw,e);
	
	cout<<"vertex set is :";
	cout<<setiosflags(ios::left);
	for(int i=0;i<b_sea.graph.vertices.get_size();i++)
		cout<<setw(3)<<b_sea.graph.vertices.get_data(i)<<"  ";
	cout<<"\n";
	cout<<"weight set is:"<<"\n";
	for(i=0;i<b_sea.graph.vertices.get_size();i++)
	{
		cout<<setiosflags(ios::left);
		for(int j=0;j<b_sea.graph.vertices.get_size();j++)
			cout<<setw(6)<<b_sea.graph.edge[i][j];
		cout<<"\n";
	}
	
	b_sea.b_open_close('A','B');
	
	b_sea.find_path();
	cout<<"The shortest path is:";
	while(b_sea.stack.stack_not_empty())
	{
		cout<<b_sea.stack.stack_pop();
		if(b_sea.stack.stack_not_empty())
			cout<<" -> ";
	}
	cout<<endl;
	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -