#include #include #include #define MAX 90000 using namespace std; class AdjMatrix {public: int n; int matrix[101][101]; int weight[101]; void CreatGraph(int num,int m); void DFSTraverse(int v1,int v2); void DFS(int v1,int v2,int visited[]); int FirstAdjVex(int v); int NextAdjVex(int v,int w); void Searchweight(); }; void AdjMatrix::Searchweight() { memset(weight,0,sizeof(weight)); int i,j; for(i=0;i>row>>col; matrix[row-1][col-1]=1; } Searchweight(); } int AdjMatrix::FirstAdjVex(int v) { for(int i=0;i>n>>m; AdjMatrix *G=new AdjMatrix; G->CreatGraph(n,m); for(int i=0;in;i++) coutweight[i]>v1>>v2; v1-=1;v2-=1; G->DFSTraverse(v1,v2); cout<<"0\n"; }
可能有点乱,给你个链接 http://pan.baidu.com/share/link?shareid=3766021313&uk=1143990708