第四周作业--1图的表示,2无向图的DFS算法,3有向图找环;

#include 
#include 
using namespace std;

#define MAX_EDGE 100
#define SAFE_DEL(p) { if (p!=NULL) { delete [] p;}}


bool *visited;
int *pre;
int *post;
int *ccnum;
int *Descpost;

int ImportToArray(const char *filename,int *array)	//将filename内的纯数字文本导入数组array;
{
	int count=0;
	ifstream fin;
	fin.open(filename);
	if( fin.fail() )
	{
		cout<<"file read fail!"<>array[count++];
	fin.close();
	return count;
}

int ExportWithGraphArray(const char *filename,bool **GraphArray,int vertexNum)
{
	ofstream fout;
	fout.open(filename);
	if(fout.fail())
	{
		cout<<"file wirte fail"<v
{
	static int k=0;
	hoopstack[k++]=v;	//stack push
	if(v!=u)
	{
		for(int i=0;ii并且i不在stack里
				exploreHoop(GraphArray,vertexNum,u,i); //此处u,i不再做回边
		}
		k--;	//stack pop
	}
	else
	{
		for(int i=0;ij,且post[i]



一,二题结果图,右边为题图

第四周作业--1图的表示,2无向图的DFS算法,3有向图找环;_第1张图片第四周作业--1图的表示,2无向图的DFS算法,3有向图找环;_第2张图片

第三题结果图:

第四周作业--1图的表示,2无向图的DFS算法,3有向图找环;_第3张图片第四周作业--1图的表示,2无向图的DFS算法,3有向图找环;_第4张图片


你可能感兴趣的:(第四周作业--1图的表示,2无向图的DFS算法,3有向图找环;)