提交 abb026f2 创建 作者: 宋海霞's avatar 宋海霞

modify

上级 5e83cca8
#include "Graph.h"
int visited[MAX_VERTEX_NUM]; // 顶点访问标志数组.0 表示未访问;大于 0 表示访问的先后次序.
Queue queue; // 队列
int visited[MAX_VERTEX_NUM]; // Array of vertex access flags.0 means no access; Greater than 0 indicates the order of access.
Queue queue; // The queue
int main(int argc, char* argv[])
{
......@@ -10,23 +10,23 @@ int main(int argc, char* argv[])
int i, j;
//
// 初始化图
// Initialize the figure
//
InitGraph(&graph);
//
// 初始化队列
// Initialization queue
//
InitQueue(&queue);
//
// 初始化访问标志数组
// Initializes an array of access flags
//
for(i=0; i<graph.length; i++)
visited[i] = 0;
//
// 广度优先搜索
// Breadth-first search
//
BreadthFirstSearch(&graph);
......@@ -44,7 +44,7 @@ int main(int argc, char* argv[])
//
// 销毁图
// Destruction of figure
//
DeleteGraph(&graph);
......@@ -53,16 +53,16 @@ int main(int argc, char* argv[])
/*
function:
广度优先搜索.
Breadth-first search.
parameter:
pGraph -- 图指针
pGraph -- Figure pointer
*/
void BreadthFirstSearch(Graph* pGraph)
{
ArcNode* pArcNode; // 边(弧节点指针
int i, v; // 顶点序号.从 0 开始计数.
int nVisitCount = 0; // 访问计数器.
ArcNode* pArcNode; // Edge (arc) node pointer
int i, v; // Vertex ordinal. Counts from 0.
int nVisitCount = 0; // Access counter.
//
// TODO: Add the code here
......@@ -73,14 +73,14 @@ void BreadthFirstSearch(Graph* pGraph)
/*
function:
使用给定的数据初始化图的邻接表
Initializes the graph's adjacency list with the given data
parameter:
pGraph -- 图指针
pGraph -- Figure pointer
*/
typedef struct VertexArrayEntry {
const char* name; // 顶点名称.NULL 表示顶点序列结束.
int VexIndex[MAX_VERTEX_NUM]; // 与该顶点邻接的顶点序列.-1 表示序列结束.
const char* name; // Name of the vertices.NULL indicates the end of the vertex sequence.
int VexIndex[MAX_VERTEX_NUM]; // The sequence of vertices adjacent to this vertex.-1 indicates the end of the sequence.
}VertexArrayEntry;
const VertexArrayEntry VertexArray[] = {
{ "V0", {2, 5, 1, -1} },
......@@ -90,20 +90,20 @@ const VertexArrayEntry VertexArray[] = {
{ "V4", {1, 3, -1} },
{ "V5", {0, 6, -1} },
{ "V6", {2, 5, 0, -1} },
{ NULL } // 结束标志
{ NULL } // End mark
};
void InitGraph(Graph* pGraph)
{
int i, j;
ArcNode** pArcNodePtr; // 指向指针的指针
ArcNode** pArcNodePtr; // Pointer to pointer
//
// 重置图中的数据
// Reset the length of the data in the graph
//
pGraph->length = 0;
//
// 使用给定的数据初始化图的邻接表
// Initializes the graph's adjacency list with the given data
//
for(i=0; i<MAX_VERTEX_NUM ;i++)
{
......@@ -132,10 +132,10 @@ void InitGraph(Graph* pGraph)
/*
function:
销毁图
Destruction of figure
parameter:
pGraph -- 图指针
pGraph -- Figure pointer
*/
void DeleteGraph(Graph* pGraph)
{
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论