graph_adj_link.cpp 文件
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
#define Vertex_MAX 50
#define Edge_MAX 50*(50-1)
int Vertex_n1 = 0;
int Edge_n1 = 0;
typedef int elemtype;
char Visited[Vertex_MAX + 1] ={
0};
//定义链表类型
struct link
{
link* next;
elemtype data;
};
//定义邻接表的表头类型
struct node
{
link *next;
elemtype v; //顶点信息
}a[Vertex_MAX+1];
void UDcreateadj_link()
{
int i,j,k;
link* s;
//输入顶点个数和边的个数
printf("请输入顶点个数:");
cin>>Vertex_n1;
printf("请输入边的个数:");
cin>>Edge_n1;
//建立邻接表头节点
printf("已自动按序号1~%d生成顶点;\n",Vertex_n1);
for (i = 1; i <= Vertex_n1; i ++)
{
a[i].v = i;