#define maxnode 30
#include <stdio.h>
typedef int elemtype
typedef struct arc
{
int adjvertex;
struct arc *nextarc;
}arctype;
typedef struct{
elemtype vertex;
arctype *fistarc;
}vertextype;
typedef vertextype adjlisttype[maxnode];
main()
{
int i,j,n,e,k;
int v1,v2;
arctype *p,*q;
adjlisttype graph;
printf("/n输入图中顶点的个数n和边数e:/n");
scanf("%d%d",&n,&e);
printf("/n输入图中顶点的数据:/n");
for(k=0;k<n;k++)
{
scanf("%d",&graph[k].vertex);
graph[k].firstarc=NULL;
}
printf("/n输入图中的各边,次序为弧尾编号,弧头编号:/n")
for(k=0;k<e;k++)
{
scanf("%d%d",&v1,&v2);
i=locvertex(graph,v1);
i=locvertex(graph,v2);
q=(arctype*)malloc(sizeof
无向图邻接表的存储结构
最新推荐文章于 2023-04-30 10:56:25 发布