摘要: #include #include #include #include #include #include using namespace std; const int VERTEX_NUM = 20; const int INFINITY = 0x7fffffff; // 最大int型数,表示权的无限值 bool vis[VERTEX_NUM]; class Grap... 阅读全文
posted @ 2018-03-25 20:43 GGBeng 阅读(1164) 评论(0) 推荐(0) 编辑
摘要: 递归 + 标记 一个连通图只要DFS一次,即可打印所有的点。 阅读全文
posted @ 2018-03-25 19:50 GGBeng 阅读(547) 评论(0) 推荐(0) 编辑
摘要: 邻接表 + 逆邻接表 = 十字链表 (十字链表把邻接表和逆邻接表整合在一起) 邻接表:计算出度容易,但计算入度就需要遍历全图,故衍生了十字链表。 阅读全文
posted @ 2018-03-25 16:47 GGBeng 阅读(1292) 评论(0) 推荐(0) 编辑
摘要: 顶点表 + 边表 // 前者是数组,后者是单链表 阅读全文
posted @ 2018-03-25 16:14 GGBeng 阅读(383) 评论(0) 推荐(0) 编辑
摘要: #include #include using namespace std; const int VERTEX_NUM = 20; const int INFINITY = 0x7fffffff; // 最大int型数,表示权的无限值 class Graph { public: int vexNum; int edgeNum; int vex[VERTEX_NUM]; i... 阅读全文
posted @ 2018-03-25 15:28 GGBeng 阅读(290) 评论(0) 推荐(0) 编辑
摘要: #include #include #include using namespace std; using ElemType = int; // 队列结点 class Node { public: ElemType data; Node *next; }; class Queue { public: Node *front; Node *rear; }; void in... 阅读全文
posted @ 2018-03-25 11:29 GGBeng 阅读(164) 评论(0) 推荐(0) 编辑
摘要: 【补充】 循环队列队首和队尾的一些关系(假设队首下标为front,队尾下标为rear,数组长度为MAXSIZE): 队列为空:rear == front 队列为满:(rear + 1) % MAXSIZE == front //(基于给队列留一个空闲位置而实现,不然和队列为空时条件重合) 队列长度: 阅读全文
posted @ 2018-03-25 11:13 GGBeng 阅读(4695) 评论(0) 推荐(0) 编辑
摘要: #include #include #include #include using namespace std; using ElemType = int; // 堆栈结构 class Node { public: ElemType data; Node *next; }; // 初始化栈 Node* initStack(Node *head, int n) { sr... 阅读全文
posted @ 2018-03-25 10:17 GGBeng 阅读(159) 评论(0) 推荐(0) 编辑
摘要: #include #include #include #include using namespace std; using ElemType = int; const int MAXSIZE = 20; // 堆栈结构 class Stack { public: ElemType data[MAXSIZE]; int top; }; // 初始化堆栈 void ini... 阅读全文
posted @ 2018-03-25 09:54 GGBeng 阅读(153) 评论(0) 推荐(0) 编辑
摘要: #include #include #include #include using namespace std; using ElemType = int; // 双向链表结点 class Node { public: ElemType data; Node *next; Node *prior; }; // 初始化链表 void initList(Node *h... 阅读全文
posted @ 2018-03-25 09:18 GGBeng 阅读(153) 评论(0) 推荐(0) 编辑
摘要: #include #include #include using namespace std; using ElemType = int; // 单链表结构 class Node { public: ElemType data; Node *next; }; // 初始化单链表 void initList(Node *head) { char ch; int val... 阅读全文
posted @ 2018-03-25 00:29 GGBeng 阅读(181) 评论(0) 推荐(0) 编辑