Advertisement

数据结构 — 图遍历算法(C语言)

阅读量:
复制代码
    #include<stdio.h>
    #include<stdlib.h> 
    #define max 20
    //边表节点 
    typedef struct node{
    	int adjvex;
    	struct node *next; 
    }eNode;
    //头节点
    typedef struct headnode{
    	char vertex;
    	eNode *firstedge;
    }hNode; 
    //邻接表
    typedef struct{
    	hNode adjlist[max];
    	int n,e;   //顶点数,边数 
    }linkG; 
    
    //创建(邻接表) 
    linkG *creat(linkG *g,int c) //c为0表示无向图 
    {
    	int i,j,k;
    	eNode *s;
    	int n1,e1;
    	char ch;
    	g=(linkG *)malloc(sizeof(linkG));
    	printf("请输入顶点数及边数: ");
    	scanf("%d%d",&n1,&e1);
    	g->n=n1;g->e=e1;

全部评论 (0)

还没有任何评论哟~