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

modify

上级 ff34e071
#include "Graph.h"
int visited[MAX_VERTEX_NUM]; // 顶点访问标志数组.0 表示未访问;大于 0 表示访问的先后次序.
int visited[MAX_VERTEX_NUM]; // Array of vertex access flags.0 means no access; Greater than 0 indicates the order of access.
int main(int argc, char* argv[])
{
......@@ -9,18 +9,18 @@ int main(int argc, char* argv[])
int i;
//
// 初始化图
// Initialize the figure
//
InitGraph(&graph);
//
// 初始化访问标志数组
// Initializes an array of access flags
//
for(i=0; i<graph.length; i++)
visited[i] = 0;
//
// 深度优先搜索
// Depth-first search
//
DepthFirstSearch(&graph);
......@@ -30,7 +30,7 @@ int main(int argc, char* argv[])
OutputResult(&graph);
//
// 销毁图
// Destruction of figure
//
DeleteGraph(&graph);
......@@ -39,19 +39,19 @@ int main(int argc, char* argv[])
/*
function:
深度优先搜索.Stack implementation of non - recursive algorithm.
Depth-first search.Stack implementation of non - recursive algorithm.
parameter:
pGraph -- 图指针
pGraph -- Figure pointer
*/
void DepthFirstSearch(Graph* pGraph)
{
ArcNode* Stack[MAX_VERTEX_NUM]; // .
ArcNode* Stack[MAX_VERTEX_NUM]; // Stack.
int top = 0; // The top of the stack.0 means empty stack
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
......@@ -62,14 +62,14 @@ void DepthFirstSearch(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, 6, 1, -1} },
......@@ -79,20 +79,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++)
{
......@@ -121,10 +121,10 @@ void InitGraph(Graph* pGraph)
/*
function:
销毁图
Destruction of figure
parameter:
pGraph -- 图指针
pGraph -- Figure pointer
*/
void DeleteGraph(Graph* pGraph)
{
......@@ -149,7 +149,7 @@ function:
output result.
parameter:
pGraph -- 图指针
pGraph -- Figure pointer
*/
void OutputResult(Graph* pGraph)
{
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论