#include "stdafx.h"
#include <iostream>
#include <vector>
using namespace std;
/*图的遍历
深度优先遍历(前序遍里):邻接矩阵(无向图,对称)
广度优先遍历(分层遍历)
*/
/*struct Node
{
int elem;
Node *link;
};*/
class Node
{
public:
Node(char data = 0);
char m_data;
bool m_visited ;
};
Node::Node(char data )
{
m_data = data;
m_visited = false;
}
class Map
{
public:
Map(int size);
~Map();
bool addNode(Node *pNode); //添加节点
void resetNode(); //重置结点
bool setdirectmatrix(int row, int col, int val = 1); //有向图邻接矩阵
bool setnodirectmatrix(int row, int col, int val = 1); //无向图邻接矩阵
void printMtrix();
//深度优先搜索
void depthfirsttraverse(int nodeindex);
//广度优先搜索
void breadthfirsttraverse(int nodeindex);
void breadthfirsttraverseimpl(vector<int> prevec);
private:
int m_size; //容量
int m_length; //现有容量
Node *Nodearray; // 顶点矩阵
int *m_matrix; //邻接矩阵
bool getvalue