标签:ted fst void size maxsize bfs str arc ++
void Graph::DFStra(int xuhao) {
cout << vertex[xuhao] << endl;
visited[xuhao] = 1;
for (int j = 0; j < verNum; j++) {
if (arc[xuhao][j] == 1 && visited[j] == 0)
DFStra(j);
}
}
void Graph::BFStra(int xuhao) {
int str[maxSize];
int front, rear;
front = -1; rear = -1;
str[++rear] = xuhao;
cout << vertex[xuhao];
visited[xuhao] = 1;
while (front != rear) {
xuhao=str[++front];
for (int j = 0; j < verNum; j++)
if (arc[xuhao][j] == 1 && visited[j] == 0) {
cout << vertex[j];
visited[j] = 1;
str[++rear] = j;
}
}
}
标签:ted fst void size maxsize bfs str arc ++
原文地址:http://www.cnblogs.com/jllj/p/6113194.html