dfs 深度优先搜索

#include "iostream"  
#include "cstdio"
#include "cstring"
#define max 100  
#define INF 99999  
using namespace std;    
int count,have_edge[max][max];  
bool visited[max];  
//图的存储(邻接矩阵)  
void graph()  
{ 
    cout<<"请输入总结点数:"<>count; 
    int m,n;  
    cout<<"请输入具有关系的各顶点,以“-1 -1 ”作为结束标志:"<>m>>n&&m!=-1&&n!=-1)  
    {
    	have_edge[m][n]=1; 
    	have_edge[n][m]=1;
	} 
}   
  
int firstadj(int v)  
{  
    for(int w=1;w<=count;w++)  
        if(have_edge[v][w])  
            return w;  
    return 0;  
}  
int nextadj(int v,int w)  
{  
    for(w=w+1;w<=count;w++)  
        if(have_edge[v][w])  
            return w;  
    return 0;  
}
int visite(int v)
{
	cout<>v0; 
	dfs(v0);
	return 0;
}

你可能感兴趣的:(数据结构实验,dfs)