2012年6月16日

BFS(邻接矩阵表示)

摘要: #define _CRT_SECURE_NO_WARNINGS#include <iostream>#include <queue>using namespace std;#define VERTEX_NUM 8bool visited[VERTEX_NUM + 1]; // 访问标志数组(备忘表)int FirstAdjVex(bool G[VERTEX_NUM + 1][VERTEX_NUM + 1], int v){ for (int j = 1; j <= VERTEX_NUM; j++) { if (G[v][j] == 1) ... 阅读全文

posted @ 2012-06-16 01:40 jjtx 阅读(428) 评论(0) 推荐(0)

BFS(邻接表表示)

摘要: 纯C:#include <stdio.h>#include <stdlib.h>#include <string.h>#define VERTEX_NUM 8typedef enum {FALSE = 0, TRUE = 1}BOOL;typedef struct ArcNode { int adjvex; struct ArcNode *nextarc; // struct不能少}ArcNode;BOOL visited[VERTEX_NUM + 1]; // 访问标志数组(备忘表)int FirstAdjVex(ArcNode *G[VERTEX_NUM 阅读全文

posted @ 2012-06-16 00:59 jjtx 阅读(999) 评论(0) 推荐(0)

导航