图 邻接表表示法
基本结构:
template<typename InfoType>
struct ArcNode
{
int adjvex;
ArcNode* nextarc;
InfoType* info;
};
template<typename VertexType, typename InfoType>
struct VNode
{
VertexType data;
ArcNode<InfoType>* firstarc;
};
template<typename VertexType, typename InfoType>
using AdjList = VNode<VertexType, InfoType>[MAX_VERTEX_NUM];
template<typename VertexType, typename InfoType>
struct ALGraph
{
AdjList<VertexType, InfoType> vertices;
int vexnum, arcnum;
GraphKind kind;
};
基本操作:
初始化
初始化图的基本数据,每个顶点的指针域置空
template<typename VertexType, typename InfoType>
Status initALGraph(ALGraph<VertexType, InfoType>& ALG, GraphKind kind)//初始化
{
for (int i = 0; i < MAX_VERTEX_NUM; i++