【发布时间】:2015-04-18 18:53:35
【问题描述】:
我是一名 C 初学者,正在学习 Graph 的一些数据结构。 我今天在维基百科上阅读了一段 C 代码:
#define MAX_VERTEX_NUM 20
typedef struct ArcNode
{
int adjvex; /* Position of Arc's Vertex */
struct ArcNode *nextarc; /* Pointer to next Arc */
InfoType *info; /* Weight) */
}ArcNode; /* Node */
typedef struct
{
VertexType data; /* Vertex Information */
ArcNode *firstarc; /* Location to the first list node */
}VNode,AdjList[MAX_VERTEX_NUM]; /* Head Node */
typedef struct
{
AdjList vertices;
int vexnum,arcnum; /* Vertex count and Arc count */
GraphKind kind; /* type of Garph, directed, undirected..*/
}ALGraph;`
我在这里阅读了几篇相关的帖子,例如“typedef struct vs struct definitions”,但我对这种用法仍然有些困惑:
typedef struct {.... }VNode,AdjList[MAX_VERTEX_NUM];
那么什么是 AdjList?它是一个数组?如果是这样,这句话是什么意思:
AdjList vertices;
谢谢。 参考:http://zh.wikipedia.org/wiki/%E9%82%BB%E6%8E%A5%E8%A1%A8
【问题讨论】: