图的存储—矩阵,邻接表C++
矩阵:
struct vertextype { int no; int info; }; struct matgraph { int edges[maxn][maxn];//weight int n,e; //n is vertex's number e is edges's number vertextype vexs[maxn];//information };
邻接表:
struct arcnode
{
int adjvex;
int weight;
arcnode *nextarc;
};
struct vnode
{
int info;
arcnode *firstarc;
};
struct adjgraph
{
vnode adjlist[maxn];
int n;
}adjgraph;